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

New mapped_private mode: avoid crash by flushing dirty pages when memory pressure gets high. #1725

Closed
wants to merge 13 commits into from
Closed
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
16 changes: 13 additions & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3488,10 +3488,20 @@ void controller::validate_db_available_size() const {
const auto guard = my->conf.state_guard_size;
EOS_ASSERT(free >= guard, database_guard_exception, "database free: ${f}, guard size: ${g}", ("f", free)("g",guard));

// give a change to chainbase to write some pages to disk if memory becomes scarce.
// give chainbase a chance to flush its private pages to disk if memory becomes scarce.
if (is_write_window()) {
if (auto flushed_pages = mutable_db().check_memory_and_flush_if_needed()) {
ilog("CHAINBASE: flushed ${p} pages to disk to decrease memory pressure", ("p", flushed_pages));
auto check_time = fc::time_point::now();
if (auto res = mutable_db().check_memory_and_flush_if_needed()) {
if (res->num_pages_written > 0) {
auto duration = (fc::time_point::now() - check_time).count()/1000; // in milliseconds
wlog("chainbase: oom = ${oom_prev}, flushed ${p} state pages to disk (in ${dur} ms) to decrease memory pressure",
("oom_prev", res->oom_score_before)("p", res->num_pages_written)("dur", duration));
wlog("chainbase: oom score after flush: ${oom_post}", ("oom_post", res->oom_score_after));
wlog("chainbase: The system is running low in memory for running nodeos. "
"If this is not a temporary condition, consider increasing the available RAM");
} else {
ilog("chainbase: oom_score = ${oom_prev} within acceptable range, no action taken", ("oom_prev", res->oom_score_before));
}
}
}
}
Expand Down