-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(core): Account for size change on json object defragment #6053
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,14 +351,20 @@ std::optional<CollectedPageStats> EngineShard::DoDefrag(CollectPageStats collect | |
| uint64_t attempts = 0; | ||
|
|
||
| PageUsage page_usage{collect_page_stats, threshold}; | ||
| DbTable* db_table = slice.GetDBTable(defrag_state_.dbid); | ||
| do { | ||
| cur = prime_table->Traverse(cur, [&](PrimeIterator it) { | ||
| // for each value check whether we should move it because it | ||
| // seats on underutilized page of memory, and if so, do it. | ||
| bool did = it->second.DefragIfNeeded(&page_usage); | ||
| const ssize_t original_size = it->second.MallocUsed(); | ||
| const bool did = it->second.DefragIfNeeded(&page_usage); | ||
| attempts++; | ||
| if (did) { | ||
| reallocations++; | ||
| if (const ssize_t delta = it->second.MallocUsed() - original_size; | ||
| delta != 0 && db_table != nullptr) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably not but I added it to be defensive as we access a field via the pointer.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i usually do not like these things as it raises questions where this state is possible. it's better to DCHECK to assert the precondition than have such ifs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I will remove it in a follow up |
||
| db_table->stats.AddTypeMemoryUsage(it->second.ObjType(), delta); | ||
| } | ||
| } | ||
| }); | ||
| traverses_count++; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.