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 optimization on blk free operation #645

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "6.6.19"
version = "6.6.20"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
28 changes: 2 additions & 26 deletions src/lib/blkalloc/append_blk_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,33 +127,9 @@ void AppendBlkAllocator::cp_flush(CP* cp) {
}
}

//
// free operation does:
// 1. book keeping "total freeable" space
// 2. if the blk being freed happens to be last block, move last_append_offset backwards accordingly;
//
// free operation books keeping "total freeable" space
void AppendBlkAllocator::free(const BlkId& bid) {
// If we are freeing the last block, just move the offset back
blk_num_t cur_last_offset = m_last_append_offset.load();
auto const input_last_offset = bid.blk_num() + bid.blk_count();
blk_num_t new_last_offset;
bool freeing_in_middle{false};
do {
if (input_last_offset == cur_last_offset) {
new_last_offset = bid.blk_num();
freeing_in_middle = false;
} else {
new_last_offset = cur_last_offset;
freeing_in_middle = true;
}
} while (!m_last_append_offset.compare_exchange_weak(cur_last_offset, new_last_offset));

if (freeing_in_middle) {
// Freeing something in the middle, increment the count
m_freeable_nblks.fetch_add(bid.blk_count());
} else {
m_commit_offset.store(m_last_append_offset.load());
}
m_freeable_nblks.fetch_add(bid.blk_count());
m_is_dirty.store(true);
}

Expand Down
Loading