-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Skip indexing points for seq_no in tsdb and logsdb #128139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I benchmarked this change: Indexing time increased from 320 minutes to 333 minutes, while merge times decreased from 150 minutes to 88 minutes (throttling reduced from 42 to 13 minutes). Store decreased from 24.3116GB to 23.9251GB. I believe the retention query with The TSDB codec uses less storage for the "_seq_no": {
"total": "287.6mb",
"total_in_bytes": 301624995,
"inverted_index": {
"total": "0b",
"total_in_bytes": 0
},
"stored_fields": "0b",
"stored_fields_in_bytes": 0,
"doc_values": "287.6mb",
"doc_values_in_bytes": 301624995,
"points": "0b",
"points_in_bytes": 0,
"norms": "0b",
"norms_in_bytes": 0,
"term_vectors": "0b",
"term_vectors_in_bytes": 0,
"knn_vectors": "0b",
"knn_vectors_in_bytes": 0
} "_seq_no": {
"total": "933.7mb",
"total_in_bytes": 979066601,
"inverted_index": {
"total": "0b",
"total_in_bytes": 0
},
"stored_fields": "0b",
"stored_fields_in_bytes": 0,
"doc_values": "383.8mb",
"doc_values_in_bytes": 402479840,
"points": "549.8mb",
"points_in_bytes": 576586761,
"norms": "0b",
"norms_in_bytes": 0,
"term_vectors": "0b",
"term_vectors_in_bytes": 0,
"knn_vectors": "0b",
"knn_vectors_in_bytes": 0
} |
Not too bad! You may also check the following index in
|
Thanks @dnhatn for working on this!
This is great, I initially assumed tsdb doc values codec for
What kind of optimizations are thinking about? We don't sort by |
@kkrik-es @martijnvg Thanks for looking! I may have reached a conclusion too quickly. Since there are no deletes or recovery_source in the track, the retention query should be a no-op in both cases. So I re-ran the benchmark using the standard codec for seq_no, and the results look better. I think we can proceed with disabling points for seq_no in tsdb and logsdb, but using the standard codec. We can switch the codec in a follow-up after further testing.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Nhat for iterating here!
So I re-ran the benchmark using the standard codec for seq_no, and the results look better.
So the only change was that _seqno field uses stock lucene doc values codec? The benchmark ran with the same track params as before? I don't think with logsdb we ever have recovery source anymore.
I think we can proceed with disabling points for seq_no in tsdb and logsdb, but using the standard codec.
Should we maybe put this behind a feature flag, so that we can see how it affects other benchmarks? I'm particularly interested in how this change affects the elastic/logs ccr benchmark.
private static Query rangeQueryForSeqNo(boolean withPoints, long lowerValue, long upperValue) { | ||
if (withPoints) { | ||
// TODO: Use IndexOrDocValuesQuery | ||
return LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, lowerValue, upperValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the TODO here and wrap this query here in IndexOrDocValuesQuery
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a small change, but it may impact performance. I prefer to make it in a separate PR to avoid introducing noise. We can do it either before or after this change.
Thanks @martijnvg
That's correct. The TSDB codec likely uses more CPU to produce a more compact encoding than the standard codec.
I considered this as well, but CCR can break if the feature is enabled on one cluster and not on another. For example, if the leader cluster enables the feature and doesn't index points for seq_no, but the follower disables it and does index points, this leads to inconsistent field infos. Should we run the elastic/logs CCR benchmark before merging this change, instead of introducing a feature flag? |
Right, in a follow up, we can maybe investigate to apply only some of the encoding techniques that tsdb doc values codec uses for the
Right, that can get messy and lead to hard to debug bugs. However, at least in production that shouldn't be an issue given that feature flags shouldn't be used in production. The same applies for snapshot builds.
👍 that also sounds good with me. |
Rally compare with current main as baseline and this change as contender: (median indexing throughput is ~12% slower, however this statistic is a bit noisy) CCR performance results between current main and this PR: https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/2eb4019c-95ac-4a05-9990-cd85b22bbaeb?_g=h@1dbd48d CCR replication is little bit slower (~19%) with this PR, but it is much better as it was before with the decompression issue fixed (#128473): https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/r/s/iAxiI But given that #128473 improved performance significantly, this change should be a good trade off. |
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
Hi @dnhatn, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@martijnvg @kkrik-es Thank you so much for your review and for helping to unblock this PR. Should we backport this change to 8.19? |
I don't think that this is possible given that doc value skippers are not available in the 8.19 branch. |
What's the storage reduction per document for this change? |
The total final disk usage in the tsdb benchmark reduced by ~10% (4.6GB to
4.1GB)
…On Tue, Jun 3, 2025 at 5:25 PM Felix Barnsteiner ***@***.***> wrote:
*felixbarny* left a comment (elastic/elasticsearch#128139)
<#128139 (comment)>
What's the storage reduction per document for this change?
—
Reply to this email directly, view it on GitHub
<#128139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAENWROFS7DKCAZ53BI3XZ33BW47FAVCNFSM6AAAAAB5OBKYN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMZVHE2TQMBVGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'm specifically curious about the reduction in bytes per document. Do you know how many documents we have ingested in the track? The relative reduction in the total size of the data set depends on how many fields are stored per document. The reduction in bytes per doc should stay consistent, no matter the data set. |
I don't have that number, since it each document has a different number of metric fields. I think we need to run the metricsgen with the index setting that this pr enabled and than another run with that that index setting disabled to get a more accurate view what the savings are on a per metric basis.
This depends on how sequence numbers get encoded in the bkd tree. I don't know what compression schemes are used. |
This change skips indexing points for the seq_no field in tsdb and logsdb indices to reduce storage requirements and improve indexing throughput. Although this optimization could be applied to all new indices, it is limited to tsdb and logsdb, where seq_no usage is expected to be limited and storage requirements are more critical.