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

Eliminate some obviously useless threading #4219

Merged
merged 2 commits into from
Jan 3, 2025

Conversation

alexpyattaev
Copy link

@alexpyattaev alexpyattaev commented Dec 28, 2024

Problem

pub fn ed25519_verify_disabled(batches: &mut [PacketBatch]) in perf/src/sigverify.rs
does pretty much no work (sets a boolean flag for each Packet in PacketBatch) and yet it creates doubly nested parallel iterators to achieve this results. It further does this on rayon's global thread pool so it is impossible to do accounting on this activity.

Summary of Changes

Changed the function to set the flags in single flattened iterator using appropriate pool, this also matches the behavior of ed25519_verify for consistency.

Copy link

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Hi @alexpyattaev - The PR description and code changes don't match; the problem description refers to sigverify but the actual diff is touching rocksdb.

Ignoring that and responding to the rocksdb changes, I still think wiring things up to be configurable (on the CLI for now since that is where everything else is) is the right move for now to allow some customization & leave an escape hatch for later.

I have #4214 which does that; I opened this a couple days ago but didn't add reviewers and/or draw attention to it in light of the holidays. I think our efforts were mostly tangential here, but we can make sure to coordinate better in Slack to avoid any duplicated efforts moving forwards

@alexpyattaev
Copy link
Author

Sorry I have pushed the wrong diff. Should not make PRs late at night. Especially the "small and trivial" ones.

@alexpyattaev alexpyattaev requested a review from steviez January 1, 2025 08:18
KirillLykov
KirillLykov previously approved these changes Jan 2, 2025
@steviez
Copy link

steviez commented Jan 2, 2025

Unless there are several thousands of packets in those batches, this will be faster.

I'm not sure if this function can actually get called in production, but if you look at SigverifyStage, 1000's of packets is not completely unexpected

// 50ms/(10us/packet) = 5000 packets
const MAX_SIGVERIFY_BATCH: usize = 5_000;

@alexpyattaev
Copy link
Author

I guess the whole point was to save resources by skipping verify in some debug/devel runs. I guess if we are dealing with truly huge numbers of packets parallelizing it may still be wise. Changed to act same as the "real" version, which works without nested parallel iterators.

@steviez
Copy link

steviez commented Jan 3, 2025

Changed to act same as the "real" version, which works without nested parallel iterators.

Yeah, this seems like a reasonable change; make it somewhat match the real one. Would you mind updating the problem description / summary of changes to more accurately reflect the new change ? I know this is a fairly minor change, but I think it is nice to have PR descriptions match the underlying code change incase we're bisecting or doing something else that involves looking through history

Copy link

@steviez steviez left a comment

Choose a reason for hiding this comment

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

LGTM

@alexpyattaev alexpyattaev merged commit 106a927 into anza-xyz:master Jan 3, 2025
40 checks passed
@alexpyattaev alexpyattaev deleted the useless_threads branch January 3, 2025 21:31
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.

3 participants