-
Notifications
You must be signed in to change notification settings - Fork 208
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
Implement naive clamping of the chunk cache size for mining worker #660
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
integer_to_binary/1, binary_to_integer/1, pick_random/1, pick_random/2, | ||
encode/1, decode/1, safe_encode/1, safe_decode/1, timestamp_to_seconds/1, | ||
parse_peer/1, peer_to_str/1, parse_port/1, safe_parse_peer/1, format_peer/1, | ||
unique/1, count/2, | ||
unique/1, count/2, clamp_lower/2, clamp_upper/2, clamp/3, | ||
genesis_wallets/0, pmap/2, pfilter/2, | ||
do_until/3, block_index_entry_from_block/1, | ||
bytes_to_mb_string/1, cast_after/3, encode_list_indices/1, parse_list_indices/1, | ||
|
@@ -381,3 +381,23 @@ assert_file_exists_and_readable(FilePath) -> | |
io:format("~nThe filepath ~p doesn't exist or isn't readable.~n~n", [FilePath]), | ||
erlang:halt(1) | ||
end. | ||
|
||
%% @doc Clamp a value to a lower bound. | ||
%% If the value is less than the lower bound, return the lower bound. | ||
clamp_lower(Value, LowerBound) when Value < LowerBound -> | ||
LowerBound; | ||
clamp_lower(Value, _LowerBound) -> | ||
Value. | ||
|
||
%% @doc Clamp a value to an upper bound. | ||
%% If the value is greater than the upper bound, return the upper bound. | ||
clamp_upper(Value, UpperBound) when Value > UpperBound -> | ||
UpperBound; | ||
clamp_upper(Value, _UpperBound) -> | ||
Value. | ||
|
||
%% @doc Clamp a value to a lower and upper bound. | ||
%% If the value is less than the lower bound, return the lower bound. | ||
%% If the value is greater than the upper bound, return the upper bound. | ||
clamp(Value, LowerBound, UpperBound) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: Can you add a comment to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, didn't see the existing one, okay. |
||
clamp_lower(clamp_upper(Value, UpperBound), LowerBound). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key change: do not let the sub_chunk_cache_size go below zero, as this does not make any sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we fighting the symptom? Perhaps, let's leave a comment this is a temporary measure until we figure out why we subtract more than we add, if that is the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, yes, you're right; proper fix will require the deep (sub)chunk cache refactoring, which is out of scope for this task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shizzard what about adding a log_warning message whenever CacheSize+Delta is below zero? We do want to fix the OOMs as quick as possible and clamping may help there, but I'm a little worried we may also lose this valuable signal that something is wrong. Which may make tracking down the true root cause harder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slacked with some more information that might help with reproducing the negative cache size (and so might help get at the root cause)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a very good idea, will do.