Skip to content
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

Remove WAL contention between ingest and searches #1076

Merged
merged 8 commits into from
Oct 26, 2021

Conversation

mdisibio
Copy link
Contributor

@mdisibio mdisibio commented Oct 25, 2021

What this PR does:
This PR contains 2 search-related changes:

  1. Remove the most of the WAL contention between the write path and searches, by removing the block-level mutex from the ingest path. It is safe for search to read from the WAL while ingest is appending to it, as search gets a copy of the index and will never attempt to read beyond the flushed portion of the file. The single block-level mutex is replaced with shorter-lived mutexes around the index and block header (tags).
  2. SearchDataMap is the underlying structure for several operations: deduping and flushing trace segments, and block headers. This PR changes its internal structure from slice to map-based to better handle tags with many values. Benchmarks show that the slice-based approach is competitive up to ~20 values (i.e. it is as fast to iterate the slice than do a single map-lookup). Beyond that the map-based approach is significantly better, and testing it on realistic workloads shows a reduction in ingester CPU of 15+%, and 15+% working set.

Which issue(s) this PR fixes:
n/a

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@mdisibio mdisibio mentioned this pull request Oct 25, 2021
12 tasks
Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

Two quick questions, but lgtm.

Would like input from one of the other maintainers more closely aligned with search.

modules/ingester/instance.go Show resolved Hide resolved
pkg/tempofb/searchdatamap.go Show resolved Hide resolved
Copy link
Member

@kvrhdn kvrhdn left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

modules/ingester/instance_search_test.go Outdated Show resolved Hide resolved
@mdisibio mdisibio merged commit 3407b35 into grafana:main Oct 26, 2021
@mdisibio mdisibio deleted the searchdatamap-v3 branch April 25, 2023 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants