Skip to content

Conversation

@mbjorkqvist
Copy link
Contributor

Change the synchronous functions in ICRC Rosetta that call SQLite to perform database I/O to be asynchronous and use tokio::task::spawn_blocking to run the task on a thread in a thread pool, rather than using one of the few asynchronous worker threads. For ICRC Rosetta instances with many (tens of) tokens, this can help to avoid situations where the worker threads are all busy servicing long-running SQLite requests, and there are no available threads to serve e.g., simple endpoint requests such as network/status, or for running the watchdog threads to see if some of the block synchronization threads have gotten stuck. Using a thread pool for spawning threads to serve the SQLite requests will use more memory, which needs to be taken into account when dimensioning the system where Rosetta is running. The features in the previously proposed PRs for limiting the SQLite cache size, and for reducing the balance sync batch size, can be used as a counter-balance.

…setta-sqlite-cache-size-limit-and-flushing

# Conflicts:
#	rs/rosetta-api/local/cluster/README.md
#	rs/rosetta-api/local/cluster/deploy.sh
#	rs/rosetta-api/local/cluster/templates/rosetta-icrc.yaml
#	rs/rosetta-api/local/cluster/values.yaml
…cache-size-limit-and-flushing' into mathias-DEFI-2452-add-configurable-icrc-rosetta-batch-size

# Conflicts:
#	rs/rosetta-api/icrc1/src/common/storage/storage_client.rs
#	rs/rosetta-api/icrc1/src/common/storage/storage_operations.rs
#	rs/rosetta-api/icrc1/src/config.rs
#	rs/rosetta-api/icrc1/src/main.rs
#	rs/rosetta-api/local/cluster/README.md
#	rs/rosetta-api/local/cluster/deploy.sh
#	rs/rosetta-api/local/cluster/templates/rosetta-icrc.yaml
#	rs/rosetta-api/local/cluster/values.yaml
…ize' into mathias-DEFI-2452-spawn-blocking-for-sqlite

# Conflicts:
#	rs/rosetta-api/icrc1/src/common/storage/storage_client.rs
…cache-size-limit-and-flushing' into mathias-DEFI-2452-add-configurable-icrc-rosetta-batch-size

# Conflicts:
#	rs/rosetta-api/local/cluster/deploy.sh
#	rs/rosetta-api/local/cluster/templates/rosetta-icrc.yaml
…ize' into mathias-DEFI-2452-spawn-blocking-for-sqlite
@github-actions github-actions bot added the feat label Nov 18, 2025
Base automatically changed from mathias-DEFI-2452-add-configurable-icrc-rosetta-batch-size to master November 25, 2025 16:28
# Conflicts:
#	rs/rosetta-api/icrc1/src/common/storage/storage_client.rs
#	rs/rosetta-api/icrc1/src/config.rs
#	rs/rosetta-api/local/cluster/README.md
#	rs/rosetta-api/local/cluster/values.yaml
@mbjorkqvist mbjorkqvist marked this pull request as ready for review November 25, 2025 18:07
@mbjorkqvist mbjorkqvist requested a review from a team as a code owner November 25, 2025 18:07

// As long as there are blocks to be fetched, keep on iterating over the blocks in the database with the given BATCH_SIZE interval
while !rosetta_blocks.is_empty() {
let mut account_balances_cache: HashMap<Account, BTreeMap<u64, Nat>> = HashMap::new();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we move this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks! I had moved it in an earlier commit of the PR this PR was stacked on top of. I later reverted the change here since I realized it didn't make sense, but I must have missed it when merging in the latest changes from master and fixing merge conflicts. I moved it back outside the while loop now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants