Skip to content

Parallelize audit node preload#456

Merged
afterdusk merged 3 commits intofacebook:mainfrom
afterdusk:parallelism-optimization
Nov 21, 2024
Merged

Parallelize audit node preload#456
afterdusk merged 3 commits intofacebook:mainfrom
afterdusk:parallelism-optimization

Conversation

@afterdusk
Copy link
Member

@afterdusk afterdusk commented Nov 19, 2024

Overview

Perform the same optimization in #454, but for audit node preloading. This involved rewriting the audit node preloading path to be more similar to the regular node preloading path, which should help readability and maintinability. We could likely refactor this even further to reduce code duplication in future.

Benchmark

Ran the azks benchmark on my 10-core Macbook Pro, on trunk (7fea6be) and on this PR:

cargo bench -p akd --bench azks -F bench

Audit Generation (1000 Leaves)
Trunk:
image

This PR:
image

Audit Generation (50,000 Leaves)
Trunk:
image

This PR:
image

Audit Generation (100,000 Leaves)
Trunk:
image

This PR:
image

Performance does regress at small load levels, and that's because we're overly parallel and the overhead outweighs any benefits. I plan to introduce a change that will allow users to configure parallelism levels based on their expected load size, overriding the current mechanism where parallelism is automatically determined by the core count of the system.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 19, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 95.61404% with 5 lines in your changes missing coverage. Please review.

Project coverage is 88.15%. Comparing base (3ce5335) to head (3cc5f8d).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
akd/src/append_only_zks.rs 95.61% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #456      +/-   ##
==========================================
- Coverage   88.61%   88.15%   -0.47%     
==========================================
  Files          39       38       -1     
  Lines        9109     8346     -763     
==========================================
- Hits         8072     7357     -715     
+ Misses       1037      989      -48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Comment on lines +328 to +331
info!(
"Preload of nodes for insert ({} objects loaded) completed.",
load_count
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to log this as an INFO level log? Although this will arguably be much less hot than a read path, it may be possible for this to become noisy.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually intentional, we we switched the previous preload log to DEBUG, we lost visibility on how long node preloading was taking during sequencing (and how many objects were loaded).


// preload the nodes that we will visit during the insertion
let (_, time_s) =
let (fallable_load_count, time_s) =
Copy link
Contributor

Choose a reason for hiding this comment

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

If the first item in the tuple is intended to be named in a manner indicating that it can fail, I believe we may want to rename this fallible_load_count.

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 copied this from elsewhere in the file, but I will edit both to use the right spelling :)

.filter(|node| {
node.node_type != TreeNodeType::Leaf
&& node.get_latest_epoch() > start_epoch
&& node.min_descendant_epoch < end_epoch
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be <=? Previously, we were returning an empty vec when determining retrieval nodes in cases where the min descendant epoch was strictly greater than the end epoch. Since we're doing the inverse here, shouldn't we be less than or equal to?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch!

@afterdusk afterdusk merged commit 0feee6e into facebook:main Nov 21, 2024
@afterdusk afterdusk deleted the parallelism-optimization branch November 21, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants