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 revert_to_private_mode() member which would require MAP_FIXED to work reliably. #26

Merged
merged 1 commit into from
Oct 26, 2023
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
4 changes: 0 additions & 4 deletions include/chainbase/chainbase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,6 @@ namespace chainbase {
_read_only_mode = false;
}

void revert_to_private_mode() {
_db_file.revert_to_private_mode();
}

size_t check_memory_and_flush_if_needed() {
return _db_file.check_memory_and_flush_if_needed();
}
Expand Down
1 change: 0 additions & 1 deletion include/chainbase/pinnable_mapped_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class pinnable_mapped_file {
~pinnable_mapped_file();

segment_manager* get_segment_manager() const { return _segment_manager;}
void revert_to_private_mode();
size_t check_memory_and_flush_if_needed();


Expand Down
20 changes: 0 additions & 20 deletions src/pinnable_mapped_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,6 @@ void pinnable_mapped_file::setup_copy_on_write_mapping() {
}
}

// this is called after loading a snapshot, when database-map-mode was switched from `mapped_private` to
// `mapped` to avoid running out of memory (because loading a snapshot causes all state pages to be modified).
// This provides an opportunity to revert back to the `mapped_private` mode with it friendlier disk
// usage characteristics.
void pinnable_mapped_file::revert_to_private_mode() {
if (!_sharable)
return;

// do synchronous flush of all modified pages of our mapping
if(_file_mapped_region.flush(0, 0, false) == false)
std::cerr << "CHAINBASE: ERROR: syncing buffers failed" << '\n';
else {
// disk db file is up to date (with dirty bit set to true)
// we can kill the RW (`shared`) mapping and recreate a `copy_on_write` one.
_file_mapped_region = bip::mapped_region();
setup_copy_on_write_mapping();
_sharable = false;
}
}

// returns the number of pages flushed to disk
size_t pinnable_mapped_file::check_memory_and_flush_if_needed() {
size_t written_pages {0};
Expand Down