Skip to content

Commit

Permalink
Merge pull request #26 from AntelopeIO/gh_1764
Browse files Browse the repository at this point in the history
Remove `revert_to_private_mode()` member which would require `MAP_FIXED` to work reliably.
  • Loading branch information
greg7mdp authored Oct 26, 2023
2 parents 13c9c35 + 3896d7f commit 7615dda
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 25 deletions.
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

0 comments on commit 7615dda

Please sign in to comment.