[8.14] TBS: Optimize for ReadTraceEvents miss (backport #13464) #13474
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.
Motivation/summary
When a sampling decision is received from a remote apm-server, if the trace is not stored locally, prefetching values in the iterator is causing mmap vlog to be read for no value, resulting in high memory usage and disk read IO.
Add an initial pass with PrefetchValues=false to optimize for a miss in ReadTraceEvents.
e.g. if there are 10 apm-servers all running TBS and synced via ES, and all transactions/spans from a trace are always sent to in 1 apm-server (i.e., a single trace never stored across multiple apm-servers), this PR should cut disk read IO related to sampling decision handling to 1/10 of before.
Benchmark results
Since the benchmark runs badger DB with in-memory mode, I expect in reality,
hit=false after this fix
will stay the same, while all the other numbers to be 1 order of magnitude slower. i.e. the performance gain from this PR will be even greater.Checklist
- [ ] Update CHANGELOG.asciidocRequire backport release changelog- [ ] Documentation has been updatedFor functional changes, consider:
How to test these changes
See benchmark
Related issues
Closes #13463
This is an automatic backport of pull request #13464 done by [Mergify](https://mergify.com).