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

Improve LocalIndexStatsTest#testMemoryCostTracking [HZ-861] #20573

Merged
merged 1 commit into from Feb 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -383,29 +383,33 @@ public void testMemoryCostTracking() {
assertTrue(keyEmptyCost > 0);
assertTrue(valueEmptyCost > 0);

for (int i = 0; i < 100; ++i) {
for (int i = 0; i < 10000; ++i) {
map.put(i, i);
}
long keyFullCost = keyStats().getMemoryCost();
long valueFullCost = valueStats().getMemoryCost();
assertTrue(keyFullCost > keyEmptyCost);
assertTrue(valueFullCost > valueEmptyCost);

for (int i = 0; i < 50; ++i) {
for (int i = 0; i < 5000; ++i) {
map.remove(i);
}
long keyHalfFullCost = keyStats().getMemoryCost();
long valueHalfFullCost = valueStats().getMemoryCost();
assertTrue(keyHalfFullCost > keyEmptyCost && keyHalfFullCost < keyFullCost);
// keyHalfFullCost < keyFullCost does not necessarily hold, since
// keys are inlined and b+ tree nodes are deleted only when they become
// fully empty
assertTrue(keyHalfFullCost > keyEmptyCost);
assertTrue(valueHalfFullCost > valueEmptyCost && valueHalfFullCost < valueFullCost);

for (int i = 0; i < 50; ++i) {
// 'force' some extra pages to be allocated
for (int i = 10000; i < 15000; ++i) {
map.put(i, i);
}
assertTrue(keyStats().getMemoryCost() > keyHalfFullCost);
assertTrue(valueStats().getMemoryCost() > valueHalfFullCost);

for (int i = 0; i < 50; ++i) {
for (int i = 0; i < 5000; ++i) {
map.set(i, i * i);
}
assertTrue(keyStats().getMemoryCost() > keyHalfFullCost);
Expand Down