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

removes unnecessary allocations in shreds ingestion path #4530

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

behzadnouri
Copy link

@behzadnouri behzadnouri commented Jan 18, 2025

Problem

Ingesting shreds unnecessarily allocates a HashSet to remove invalid repair-meta:
https://github.com/anza-xyz/agave/blob/0f56076a2/core/src/window_service.rs#L250

and a separate vector for repair flags:
https://github.com/anza-xyz/agave/blob/0f56076a2/core/src/window_service.rs#L338-L341

Similarly Blockstore::insert_shreds (called in broadcast-stage to insert own shreds during leader slots), allocates a vector for repair flags:
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L1381

All can be avoided if blockstore insert_shreds... api are updated to take an argument of type

shreds: impl ExactSizeIterator<Item = (Shred, /*is_repaired:*/ bool)>,

Summary of Changes

Removed unnecessary allocations in shreds ingestion path.

@behzadnouri behzadnouri force-pushed the rm-shreds-ingest-allocs branch 2 times, most recently from d9e5512 to c1b1ef1 Compare January 18, 2025 16:14
@behzadnouri behzadnouri force-pushed the rm-shreds-ingest-allocs branch 2 times, most recently from fad5cb1 to 482b9db Compare January 19, 2025 22:19
Ingesting shreds unnecessarily allocates a HashSet to remove invalid
repair-meta:
https://github.com/anza-xyz/agave/blob/0f56076a2/core/src/window_service.rs#L250

and a separate vector for repair flags:
https://github.com/anza-xyz/agave/blob/0f56076a2/core/src/window_service.rs#L338-L341

Similarly Blockstore::insert_shreds (called in broadcast-stage to insert
own shreds during leader slots), allocates a vector for repair flags:
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L1381

All can be avoided if blockstore insert_shreds api are updated to take
an argument of type

    shreds: impl ExactSizeIterator<Item = (Shred, /*is_repaired:*/ bool)>,
@behzadnouri behzadnouri force-pushed the rm-shreds-ingest-allocs branch from 482b9db to 22ab610 Compare January 20, 2025 13:40
@behzadnouri behzadnouri merged commit 8b9dbd8 into anza-xyz:master Jan 21, 2025
47 checks passed
@behzadnouri behzadnouri deleted the rm-shreds-ingest-allocs branch January 21, 2025 13:14
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.

2 participants