perf(v2): initialize dataset segment head lazily #4274
Merged
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.
It's been observed that under certain conditions, segment-writer latency might have spikes, even when there are enough CPU resources. The mutex delay profile shows an unusual pattern that fully correlates with the observed latency increase:
I see three potential issues here:
NewHead
is responsible for about 1% of all allocations.That said, I find it hard to believe these are causing what the profile shows. Even with artificial load tests, I wasn't able to reproduce the problem (the branch version is at least twice as fast in all scenarios). I've seen much more heavily loaded instances that don't show any issues like this. Therefore, I believe it may not fully address the problem.