Skip to content

perf: Implemented custom storage for transactions hashes#5405

Merged
dima74 merged 2 commits intohyperledger-iroha:mainfrom
dima74:diralik/state-transactions-memory-usage
May 7, 2025
Merged

perf: Implemented custom storage for transactions hashes#5405
dima74 merged 2 commits intohyperledger-iroha:mainfrom
dima74:diralik/state-transactions-memory-usage

Conversation

@dima74
Copy link
Copy Markdown
Contributor

@dima74 dima74 commented Apr 28, 2025

Context

This PR reduces memory usage of Iroha ~3 times.

  • Currently:
    • ~270 bytes per transaction
    • ~2.7 GB after 10 million transactions
  • This PR:
    • ~80 bytes per transaction
    • ~0.9 GB after 10 million transactions

(numbers for "bytes per transaction" correspond only to transaction hashes map, without actual transaction details; numbers for "after 10 million transactions" correspond to total Iroha memory usage)

Related: #5083 (comment)
Related: #5378 (comment)

Solution

Implement custom version of storage for State::transactions map. It uses concurrent map from dashmap crate to implement memory efficient storage for transaction hashes.

Review notes

This PR can be divided into two parts

  1. Remove transactions field from StateTransaction, since it is not used there and implementation will be simpler without it.
  2. Actual implementation of transactions hashes storage in crates/iroha_core/src/state/storage_transactions.rs

Checklist

  • I've read CONTRIBUTING.md.
  • (optional) I've written unit tests for the code changes.
  • All review comments have been resolved.
  • All CI checks pass.

@dima74 dima74 added the Performance non-functional label Apr 28, 2025
@dima74 dima74 self-assigned this Apr 28, 2025
Comment thread crates/iroha_core/src/state/storage_transactions.rs
Comment thread crates/iroha_core/src/state/storage_transactions.rs
@s8sato s8sato self-assigned this Apr 30, 2025
@0x009922 0x009922 self-assigned this May 1, 2025
Comment thread crates/iroha_core/src/state/storage_transactions.rs
Comment thread crates/iroha_core/src/state/storage_transactions.rs
Comment thread crates/iroha_core/src/state/storage_transactions.rs
Comment thread crates/iroha_core/src/state/storage_transactions.rs Outdated
@dima74 dima74 force-pushed the diralik/state-transactions-memory-usage branch 2 times, most recently from ecfad69 to b303692 Compare May 2, 2025 21:08
dima74 added 2 commits May 7, 2025 22:29
Expected ~3x improvement of Iroha memory usage

Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
@dima74 dima74 force-pushed the diralik/state-transactions-memory-usage branch from b303692 to 30c67b0 Compare May 7, 2025 19:29
@dima74 dima74 merged commit 3f039a3 into hyperledger-iroha:main May 7, 2025
15 checks passed
@dima74 dima74 deleted the diralik/state-transactions-memory-usage branch May 7, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance non-functional

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants