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

multi threaded snapshot loading #440

Merged
merged 6 commits into from
Aug 12, 2024
Merged

multi threaded snapshot loading #440

merged 6 commits into from
Aug 12, 2024

Conversation

spoonincode
Copy link
Member

Add multi threaded snapshot loading.

Different environments will have different performance uplifts, but in my environment with a recent EOS snapshot, loading time decreased from 90 seconds to 60 seconds.

This implements a very simple parallelization scheme where each snapshot section (which roughly corresponds to each chainbase table) is loaded in parallel. To get better parallelization we will need to load a single chainbase table in parallel since the contract table far outweighs the other tables. That is certainly doable, but far more complex.

Resolves #437

@spoonincode spoonincode linked an issue Jul 30, 2024 that may be closed by this pull request
authorization.read_from_snapshot(snapshot, rows_loaded, snapshot_load_ctx);
resource_limits.read_from_snapshot(snapshot, rows_loaded, snapshot_load_ctx);

constexpr unsigned max_snapshot_load_threads = 4;
Copy link
Member Author

Choose a reason for hiding this comment

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

There is diminishing returns beyond this. Really even 2 or 3 is probably similar performance to 4 with current EOS data set.


std::vector<std::promise<void>> thread_promises(snapshot_load_threads);
std::list<std::thread> threads;
//this scoped_exit can go away with jthread; but still marked experimental in libc++18
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess I goofed this up before making #400. I thought I tested locally with libc++18 I could use jthread but clearly that isn't the case.

@ericpassmore
Copy link
Contributor

Note:start
group: STABILITY
category: PERFORMANCE
summary: Reduce snapshot loading time by utilizing multiple threads.
Note:end

libraries/chain/controller.cpp Outdated Show resolved Hide resolved
Base automatically changed from raf_nothrow_dtor to main August 8, 2024 17:29
@spoonincode spoonincode merged commit ad7eea8 into main Aug 12, 2024
36 checks passed
@spoonincode spoonincode deleted the threaded_snap_load branch August 12, 2024 18:22
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.

Make snapshot loading multi-threaded
4 participants