Skip to content

Remove samplesPerChunk from memSeries#12390

Merged
jesusvazquez merged 1 commit intoprometheus:mainfrom
leizor:leizor/prometheus/issues/12009
May 25, 2023
Merged

Remove samplesPerChunk from memSeries#12390
jesusvazquez merged 1 commit intoprometheus:mainfrom
leizor:leizor/prometheus/issues/12009

Conversation

@leizor
Copy link
Copy Markdown
Contributor

@leizor leizor commented May 24, 2023

Follow-up to #12055, specifically #12055 (comment).

Removing samplesPerChunk from memSeries as it implies that it's a value that can change per memSeries and this saves 8 bytes per series in memory.

I think it might still be conceptually murky to be passing in the samplesPerChunk value into the append functions, but there's precedent in how we're passing chunkRange in; it's also a value that is configured in HeadOptions and AFAICT doesn't vary between different memSeries.

Signed-off-by: Justin Lei <justin.lei@grafana.com>
@leizor leizor requested a review from jesusvazquez as a code owner May 24, 2023 22:23
Copy link
Copy Markdown
Contributor

@colega colega left a comment

Choose a reason for hiding this comment

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

FWIW LGTM.

Maybe at this point we could consider creating a struct:

type appendOpts struct {
    chunkDiskMapper *chunks.ChunkDiskMapper
    chunkRange      int64
    samplesPerChunk int
}

Because those 3 are passed down through a lot of methods and it would make them more readable IMO:

-func (s *memSeries) append(t int64, v float64, appendID uint64, chunkDiskMapper *chunks.ChunkDiskMapper, chunkRange int64, samplesPerChunk int) (sampleInOrder, chunkCreated bool)
+func (s *memSeries) append(t int64, v float64, appendID uint64, opts appendOpts) (sampleInOrder, chunkCreated bool)

Edit: maybe chunkOpts:

type chunkOpts struct {
    diskMapper *chunks.ChunkDiskMapper
    range      int64
    samples    int
}

Because those 3 are passed down through a lot of methods and it would make them more readable IMO:

-func (s *memSeries) append(t int64, v float64, appendID uint64, chunkDiskMapper *chunks.ChunkDiskMapper, chunkRange int64, samplesPerChunk int) (sampleInOrder, chunkCreated bool)
+func (s *memSeries) append(t int64, v float64, appendID uint64, chunk chunkOpts) (sampleInOrder, chunkCreated bool)

Copy link
Copy Markdown
Member

@jesusvazquez jesusvazquez left a comment

Choose a reason for hiding this comment

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

LGTM nice catch @colega and work @leizor

I'm going to approve and merge this one for now because it brings the optimization now() and also because I leave for a short vacation tomorrow. That said, I also like the idea of grouping the arguments in a struct to only pass that struct down. So lets see if we can have this done in a separate PR :)

@jesusvazquez jesusvazquez merged commit 89af351 into prometheus:main May 25, 2023
@leizor leizor deleted the leizor/prometheus/issues/12009 branch May 25, 2023 15:06
@leizor
Copy link
Copy Markdown
Contributor Author

leizor commented May 25, 2023

I like the chunkOpts suggestion @colega! I'll do another followup PR.

bboreham pushed a commit to bboreham/prometheus that referenced this pull request Jul 24, 2023
Signed-off-by: Justin Lei <justin.lei@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants