tsdb [PERF]: move lastHistogramValue/lastFloatHistogramValue from memSeries to appenders#18515
Draft
tsdb [PERF]: move lastHistogramValue/lastFloatHistogramValue from memSeries to appenders#18515
Conversation
…to appenders Store the last appended histogram and float histogram in the HistogramAppender and FloatHistogramAppender respectively, instead of keeping redundant pointers in memSeries. HistogramAppender gains LastHistogram()/SetLastHistogram() and FloatHistogramAppender gains LastFloatHistogram()/SetLastFloatHistogram(). All callers in head_append.go, head.go, head_read.go and head_wal.go are updated to type-assert on series.app and call the new accessors. The chunkSnapshotRecord fields are left unchanged (WAL on-disk format must not change); snapshot load now initialises the appender from the snapshot record via the new setters. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: György Krajcsovits <[email protected]>
…astValue into appenders Add two methods to the chunkenc.Appender interface: - IsStaleLastValue() bool — replaces per-type stale checks scattered across head.go, head_read.go, head_append.go and head_wal.go. - IsEqual(v float64, h *histogram.Histogram, fh *histogram.FloatHistogram) bool — replaces type assertions in appendableHistogram and appendableFloatHistogram. xorAppender and xor2Appender implement IsStaleLastValue using the existing a.v field (the last appended float), making it the canonical storage for the last float value within the appender. HistogramAppender and FloatHistogramAppender use their existing lastValue fields. All callers are updated: the five separate stale checks in head.go, head_read.go, head_append.go and head_wal.go collapse to isStaleLastValue() calls; the duplicate-detection type assertions in appendableHistogram and appendableFloatHistogram are replaced with IsEqual; and stale-transition tracking in commitHistograms, commitFloatHistograms and WAL replay becomes a single IsStaleLastValue() call per block. The isHistogramStale helper is removed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: György Krajcsovits <[email protected]>
…ppender; remove memSeries.lastValue Replace the two helper methods IsStaleLastValue() and IsEqual() on the chunkenc.Appender interface with a single LastValue() method that returns (v float64, h *histogram.Histogram, fh *histogram.FloatHistogram). This lets callers inspect the last appended value without a type switch and without maintaining a separate copy of the last float value in memSeries. The field s.lastValue float64 is removed from memSeries as a result. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: György Krajcsovits <[email protected]>
Member
Author
|
/prombench main |
Contributor
|
⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️ Compared versions: After the successful deployment (check status here), the benchmarking results can be viewed at: Available Commands:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lastHistogramValue *histogram.HistogramandlastFloatHistogramValue *histogram.FloatHistogramfrommemSeries, reducing its size by two pointer fields (16 bytes on 64-bit).lastValuetoHistogramAppenderandFloatHistogramAppender(set on everyappendHistogram/appendFloatHistogramcall), withLastHistogram()/SetLastHistogram()andLastFloatHistogram()/SetLastFloatHistogram()accessors.series.app; a newisHistogramStale()helper onmemSeriesde-duplicates the four stale-check locations.chunkSnapshotRecordWAL format is unchanged; snapshot load now restores appender state via the new setters.Signed-off-by: György Krajcsovits [email protected]
Coded with Claude Sonnet 4.6.