Skip to content

Conversation

whankinsiv
Copy link
Collaborator

The stake_addresses field in accounts_state was previously using a Mutex<HashMap> to store stake address state. As the new StateQuery message type is adopted, read access to stake_addresses is becoming increasingly frequent, a trend that will continue as additional cross-module queries are implemented.

This PR refactors stake_addresses to use DashMap instead of Mutex<HashMap>, enabling fine-grained locking for writes and allowing fully concurrent reads. This significantly reduces contention under load, such as when syncing to tip.

I had observed that some StateQuery messages from drep_state to accounts_state were timing out. After switching to DashMap, these timeouts were resolved.

Signed-off-by: William Hankins <william@sundae.fi>
@whankinsiv whankinsiv marked this pull request as draft August 13, 2025 00:00
…te (WIP)

Signed-off-by: William Hankins <william@sundae.fi>
@whankinsiv
Copy link
Collaborator Author

whankinsiv commented Aug 28, 2025

The switch from Mutex<HashMap> to Dashmap may no longer be required as we are considering using historical states exclusively for StateQuery responses. This would make switching the live state unnecessary for the initial purposes of this PR. Any needed data structure changes will be included in the accounts_state refactor for expanding state to align with data required for Blockfrost. Closing this PR.

@whankinsiv whankinsiv closed this Aug 28, 2025
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.

1 participant