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

Set EOS VM OC max mirroring pages to a small number for read-only threads #1488

Merged
merged 4 commits into from
Aug 14, 2023

Conversation

linh2931
Copy link
Member

@linh2931 linh2931 commented Aug 13, 2023

A part of eosnetworkfoundation/product#149.

Per the design in https://github.com/eosnetworkfoundation/product/blob/main/transactions/read-only/memory.md, to conserve virtual memory to support more threads, we need to reduce the threshold where EOS VM OC transitions from mirroring to mprotect().

We plan to keep 528 pages (529 slices) for the main-thread memory (currently used for anything other then read-only transaction threads); this ensures maximum performance for EVM transactions. For each read-only thread, we set 10 pages (11 slices) (10 pages covers 99% native actions and 56% EVM actions, from data collected by in #1159).

With maximum 256 read-only threads , virtual memory required by OC is 26 TB (OC's main thread uses 4TB VM (by 529 slices) and the read-only threads use 22TB (256 * 11 * 8GB)). It is about 20% of total VM space in a 64-bit Linux machine (about 128TB).

The coding is much simpler.

Resolves #645

// Set mirroring_pages_for_ro_thread to a small number to save upfront virtual memory
// consumption. Usage beyond this limit will be handled by mprotect.
constexpr uint32_t mirroring_pages_for_ro_thread = 10;
thread_local eosvmoc::memory eosvmoc_runtime::mem_thread_local{mirroring_pages_for_ro_thread};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of surprised this works... but best I can tell from reading the code thoroughly is that it does what we want correctly.

I may suggest we change the name of the ctor parameter,

memory::memory(uint64_t max_pages) {

from max_pages to sliced_pages (or something else). It probably was "max pages" in 2.0, but its meaning has changed in 2.1/3.0.5.

I'd also suggest we remove

void memory::reset(uint64_t max_pages) {

afaict it isn't used (I removed it locally and the build worked at least).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I made the suggested changes. The code is even cleaner.

@linh2931 linh2931 merged commit 8c769a1 into main Aug 14, 2023
22 checks passed
@linh2931 linh2931 deleted the OC_RO_thread_mem_config branch August 14, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce EOS VM OC's memory slice count allowing for higher parallelization
3 participants