Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Align series to 8/16 byte padding to increase addressable space #248

Merged
merged 7 commits into from
Jan 13, 2018

Conversation

shubheksha
Copy link
Contributor

Fixes #238

Copy link
Contributor

@fabxc fabxc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

index/index.go Outdated
// offset references in v1 are only 4 bytes large.
// Once we move to compressed/varint representations in those areas, this limitation
// can be lifted.
if w.pos > math.MaxUint32 {
if w.pos > 16*math.MaxUint32 {
return errors.Errorf("exceeding max size of 4GiB")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"of 64GiB"

index/index.go Outdated
SetSymbolTable(t map[uint32]string)
Postings(b []byte) (int, Postings, error)
Series(b []byte, lbls *labels.Labels, chks *[]chunks.Meta) error
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably skip making this an interface if v2 and thus DecoderV1 vs DecoderV2 is not necessary.
But generally, exported interfaces should not have any unexported methods.

index/index.go Outdated
@@ -250,6 +250,7 @@ func (w *Writer) writeMeta() error {
return w.write(w.buf1.get())
}

//AddSeries adds the series one at a time along with its chunks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after //

block.go Outdated
@@ -151,6 +151,9 @@ type BlockMeta struct {

// Information on compactions the block was created from.
Compaction BlockMetaCompaction `json:"compaction"`

// Version of the index format
Version int `json:"version"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally 👍 for making this explicit here. But I'm wondering whether we actually need to bump the format. The serialisation is certainly different with the padding, but it seems like DecoderV2 below doesn't do anything differently than DecoderV1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, fair enough. I'll just rename it to Decoder instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, the main issue with having two different formats/versions was how to make them configurable. Currently, the value is being hardcoded as 1. However, picking it up from BlockMeta itself makes the test fail as there is no value specified in the test files and the default value is 0. How can that be fixed?

Copy link
Collaborator

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just glossed over because I couldn't fall asleep. Mostly nits, will give a thorough review tomorrow, but looks good so far :)

index/index.go Outdated
w.seriesOffsets[ref] = w.pos
w.addPadding(16)
w.seriesOffsets[ref] = w.pos / 16
w.Version = 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant

index/index.go Outdated
@@ -852,9 +866,13 @@ func (r *Reader) LabelIndices() ([][]string, error) {
return res, nil
}

// Series the series with the given ID and writes its labels and chunks into lbls and chks.
// Reads the series with the given ID and writes its labels and chunks into lbls and chks.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In go the comments need to start with the function name. Series reads the.....

block.go Outdated
@@ -151,6 +151,9 @@ type BlockMeta struct {

// Information on compactions the block was created from.
Compaction BlockMetaCompaction `json:"compaction"`

// Version of the index format
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fullstop after comment.

index/index.go Outdated
@@ -563,27 +572,32 @@ func (b realByteSlice) Sub(start, end int) ByteSlice {
}

// NewReader returns a new IndexReader on the given byte slice.
func NewReader(b ByteSlice) (*Reader, error) {
return newReader(b, nil)
func NewReader(b ByteSlice, v int) (*Reader, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name accepted argument version everywhere. Will become much clearer.

@shubheksha shubheksha changed the title [WIP]: Align series to 8/16 byte padding to increase addressable space Align series to 8/16 byte padding to increase addressable space Jan 10, 2018
@gouthamve
Copy link
Collaborator

Also, the docs need to be updated about the format.

Copy link
Collaborator

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll replace a Prometheus running 2.0 with a prometheus having these changes and will let you know!

@fabxc You might want to take a look.

index/index.go Outdated
return newReader(b, nil, version)
}

func NewReaderV1(b ByteSlice, c io.Closer, version int) (*Reader, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this function with the above definition already doing the same thing? I know I was leaning towards a NewReaderV1 and NewReaderV2, but that doesn't look necessary right now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if its V1 why is it taking a version ;)?

}

func newReader(b ByteSlice, c io.Closer) (*Reader, error) {
func newReader(b ByteSlice, c io.Closer, version int) (*Reader, error) {
r := &Reader{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if the version is 1 or 2 and return an error if its neither?

@fabxc
Copy link
Contributor

fabxc commented Jan 11, 2018

Per my comment in the first review, do we really need to bump the version?

Nevermind that comment. Not sure where my head was.

index/index.go Outdated
}

// NewFileReader returns a new index reader against the given index file.
func NewFileReader(path string) (*Reader, error) {
func NewFileReader(path string, version int) (*Reader, error) {
if version != 1 && version != 2 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this check into newReader? Because there is another caller above for which we are not doing any checks :)

@gouthamve gouthamve merged commit 8d373c7 into prometheus-junkyard:master Jan 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants