-
Notifications
You must be signed in to change notification settings - Fork 73
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
Update chainbase to tip (reduce memory usage) #1575
Conversation
Should we consider adding a validation on |
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 think @spoonincode idea of a limit would be good. Otherwise, LGTM.
The new limit for chainbase addressable memory is 8TB, so that would be 8388608mb I believe. |
ah wow didn't realize we reduced the max to 8TB |
chain_config->state_size = options.at( "chain-state-db-size-mb" ).as<uint64_t>() * 1024 * 1024; | ||
EOS_ASSERT( chain_config->state_size <= 8ull * 1024 * 1024 * 1024 * 1024, plugin_config_exception, | ||
"The maximum supported size for the chain state db is 8TiB" ); |
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.
imo it would be nice for this error message to expressly refer to chain-state-db-size-mb
somehow, so the user knows exactly what knob is set too far. But, users can probably figure it out in this case anyways
This updates the chainbase submodule to include the memory reduction optimization. Description copied below.
Reduce offset_node_base memory usage inside the RBtree of chainbase
This PR will reduce the chainbase memory usage
old implementation:
_parent
,_left
,_right
,_color
consume 32 bytes together (8 bytes each).new implementation
_parent
,_left
,_right
,_color
consume 16 bytes (42 + 42 + 42 + 2 bits) together.erased_flag
since _color is a 2 bit signed int.limitations:
_parent
,_left
&_right
only have signed 42-bit each (so 41-bit absolute value), shifted by two bits thanks to alignment, implying a maximum of chainbase size of 2^43 = 8TB.offset_node_base
objects must always be allocated within the same segment due to the 42-bit offset limit. Using a stack variable ofoffset_node_base
is no longer valid (as stack address starts from 0x7fffxxxxxxxx which is too far away from heap addresses).tested results:
using mainnet snapshot snapshot-308122667.bin.tar.gz:
28799134736
23136280976
(around 20% reduction)[greg 8/21/2023] retested with the current PR version and confirmed the memory savings as reported by
curl -X POST http://127.0.0.1:8888/v1/db_size/get
after loading snapshot.