-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add live graphic visualization of memory allocated/freed while nodeos is running #1041
Conversation
b0bebe1
to
9b12e69
Compare
Note:start |
There are still build issues when testing reference contracts using libtester, but since we don't plan on merging this PR there is no point in wasting time fixing these. Branch can be built and used for memory usage visualization, but will not be merged. Closing the issue as completed. |
Please note that we do not intend to merge this PR, in only exists as documentation of the work done, and as a base for further developments if warranted.
Resolves #974.
This change is mostly done in two separate parts:
Boost interprocess memory occupancy tracking
The Boost interprocess library (which is used to manage memory within the shared memory segment allocated by chainbase) can use multiple memory allocation managers.
Chainbase, and therefore nodeos, use the
rbtree_best_fit
algorithm which keeps track of free areas using a rbtree (the nodes of the rbtree are intrusively stored in the free areas themselves, so there is no additional memory cost for this tree, besides the fact that it requires a minimum allocation size).This PR adds a new member in the memory segment header managed by the
interprocess
library, of the type:and updates this occupancy vector:
bool initialize_occupancy();
is calledAs we cannot add these changes in the original boost repo, this PR links to a private repo which includes the changes in the
interprocess
library. These changes are also included in the following file:ip.txt
Use the occupancy vector maintained by
Boost interprocess
to update a texture and visualize it on-screenThe visualization is implemented using
OpenGL
. This required adding some dependencies to chainbase:glad
header files describing the OpenGL interface used. These were generated from https://gen.glad.sh/, specifyinggl 4.6
andglx 1.4
,compat profile
,header only
,GL_ARB_direct_state_access
extension.glfw.txt
The visualization is implemented in the new files
mem_visualizer[.hpp, .cpp]
, and takes place on a separate thread.Notes
rbtree_best_fit
memory allocator (as chainbase does), the minimum size of a block is 48 bytes. When allocating 8 bytes, the overhead is 40 bytes. When allocating 32 bytes or more, the overhead is 16 bytes.m_prev_size
andm_size
) with two 1 bit flags encoded in the lower two bits ofm_size
(m_prev_allocated
andm_allocated
).