Skip to content

perf: parallelize sequential awaits with asyncio in async_subtensor#3275

Open
altis0725 wants to merge 1 commit intoopentensor:stagingfrom
altis0725:feat/async-gather-optimization
Open

perf: parallelize sequential awaits with asyncio in async_subtensor#3275
altis0725 wants to merge 1 commit intoopentensor:stagingfrom
altis0725:feat/async-gather-optimization

Conversation

@altis0725
Copy link

@altis0725 altis0725 commented Feb 25, 2026

Fixes #3129

Summary

Apply asyncio.gather to three methods to run sequential RPC calls concurrently:

  • get_all_dynamic_info: runtime_call and get_subnet_prices in parallel
  • blocks_since_last_update: get_block_number and get_hyperparameter in parallel, with pre-resolved block_hash for chain state consistency
  • blocks_until_next_epoch: dynamic gather for get_block_number and tempo when both need fetching

Each parallelized pair saves ~1 RPC round-trip (50-200ms depending on node latency).

Test plan

  • Updated test_blocks_since_last_update_success and test_blocks_since_last_update_no_last_update for new calling convention
  • CI passes

Copy link
Collaborator

@basfroman basfroman left a comment

Choose a reason for hiding this comment

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

Could you pls explain the real benefit of this pr?

Apply asyncio.gather to three methods for concurrent RPC execution:

- get_all_dynamic_info: run runtime_call and get_subnet_prices concurrently
- blocks_since_last_update: run get_block_number and get_hyperparameter
  concurrently, pre-resolve block_hash for chain state consistency
- blocks_until_next_epoch: dynamically gather block and tempo lookups

Fixes opentensor#3129

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@altis0725 altis0725 force-pushed the feat/async-gather-optimization branch from 4b35a56 to 209e0c3 Compare February 26, 2026 01:19
@altis0725
Copy link
Author

Hi @basfroman, thanks for the feedback. I've rebased the branch to a single clean commit.

This PR implements the two items from #3129:

  1. asyncio.gather applied to 3 methods — each saves ~1 RPC round-trip by running sequential substrate calls concurrently
  2. determine_block_hash improvement — pre-resolve block_hash in blocks_since_last_update before parallel calls to ensure both reference the same chain state

The previous version had too many incremental commits that obscured the intent — apologies for the noise.

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