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

Compactor Memory Improvements/Bug fix #1130

Merged
merged 5 commits into from
Nov 22, 2021

Conversation

joe-elliott
Copy link
Member

@joe-elliott joe-elliott commented Nov 19, 2021

What this PR does:

  • Improves memory usage
  • Possibly fixes a bug with calling b.clear() on bookmarks that did not represent the lowest id.
    • Edit: Testing the old code with the new TestSameIDCompaction does show errors. This probably resulted in some lost spans.
  • Added a gross, but important test that tests full object recombination across 5 blocks simultaneously compacted.

Which issue(s) this PR fixes:
Fixes #

Checklist

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

Signed-off-by: Joe Elliott <[email protected]>
@joe-elliott joe-elliott changed the title Compactor Memory Improvements Compactor Memory Improvements/Bug fix Nov 19, 2021
Signed-off-by: Joe Elliott <[email protected]>
Copy link
Member

@mapno mapno left a comment

Choose a reason for hiding this comment

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

I have a question about the iterator's logic, but LGTM overall.

return
}
for _, b := range lowestBookmarks {
b.clear()
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the logic here. Why are we appending to lowestBookmarks if we clear them before using them in the log? Could we use a counter instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

lowestBookmarks is a slice that contains bookmark structs that "point to" the next lowest object for compaction. Clearing them just tells them to move past their current object. The reason we do it here is b/c if the condition below hits and we continue then we need to be sure that we've moved these bookmarks to the next thing or we will just get in an infinite loop.

Honestly unsure about the quality of that log. Might make more sense to just log len(lowestBookmarks). The only thing I really wanted was info about why the condition evaluated to true.

Copy link
Contributor

Choose a reason for hiding this comment

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

The log message previously printed lowestBookmark, which mainly was to distinguish between nil or not (when not nil it just prints unsupported object type). It would be similar here, printing nil/empty slice/nil/non-nil entries quite messily.... but quite frankly since we haven't determined root cause for the empty objects yet, I am ok with that and prefer it over a simple len().

Copy link
Contributor

@mdisibio mdisibio left a comment

Choose a reason for hiding this comment

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

Great fix and improvement, lgtm.

@joe-elliott joe-elliott merged commit c2c84ae into grafana:main Nov 22, 2021
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.

3 participants