Skip to content
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
31 changes: 11 additions & 20 deletions src/dbzero/object_model/LangCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,32 +297,23 @@ namespace db0

void LangCacheView::clear(bool expired_only, bool as_defunct)
{
// copy for erase safety
auto objects = std::move(m_objects);
m_objects = {};

// erase expired objects only
if (expired_only) {
// optimized clear when lang cache view size >> cache size
if (m_objects.size() > m_cache.size() * 4) {
std::unordered_set<Address> non_expired_objects;
for (auto addr: m_objects) {
if (!m_cache.erase(m_fixture_id, addr, true, as_defunct)) {
non_expired_objects.insert(addr);
}
}
m_objects = std::move(non_expired_objects);
} else {
auto it = m_objects.begin();
while (it != m_objects.end()) {
if (m_cache.erase(m_fixture_id, *it, true, as_defunct)) {
it = m_objects.erase(it);
} else {
++it;
}
std::unordered_set<Address> non_expired_objects;
for (auto addr: objects) {
if (!m_cache.erase(m_fixture_id, addr, true, as_defunct)) {
non_expired_objects.insert(addr);
}
}
m_objects = std::move(non_expired_objects);
} else {
for (auto addr: m_objects) {
for (auto addr: objects) {
m_cache.erase(m_fixture_id, addr, false, as_defunct);
}
m_objects.clear();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/object_model/tags/ObjectIterable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace db0::object_model
TypeObjectPtr getLangType() const;

// NOTE: ObjectIterable might be related with a specific context / scope (e.g. snapshot)
// to prevend context deletion before the query, it's important to attach it
// to prevent context deletion before the query, it's important to attach it
// otherwise a segfault might happen when query iterated over, after closing the context
void attachContext(ObjectPtr) const;

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/workspace/Fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ namespace db0
// Flush using registered flush handlers
for (auto &handler: m_flush_handlers) {
handler();
}
}
m_lang_cache.clear(true);
// lock for exclusive access
{
Expand Down
3 changes: 2 additions & 1 deletion src/dbzero/workspace/GC0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,6 @@ namespace db0

std::unique_ptr<GC0::CommitContext> GC0::beginCommit() {
return std::make_unique<CommitContext>(*this);
}
}

}
Loading