Refactor validator to use async/parallel processing for GitHub API calls #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the validator's reward mechanism to address performance bottlenecks caused by sequential, blocking GitHub API calls. By moving to
aiohttpand parallel processing, we significantly reduce the time required to evaluate miners, especially as the subnet scales.Key Changes
Async/Parallel Miner Evaluation:
gittensor/validator/evaluation/reward.pyto evaluate all miners concurrently usingasyncio.gather.forloop with parallel task execution, drastically reducing total epoch time.Non-Blocking GitHub API Client:
gittensor/utils/github_api_tools.pyto useaiohttpinstead ofrequests.ClientSessionapproach inscore_pull_requeststo reuse TCP connections for multiple file checks within a single miner evaluation, reducing handshake overhead.Robust Error Handling & Retry Logic:
get_pull_request_file_changesandget_user_merged_prs_graphql.Testing:
tests/utils/test_github_api_tools.pyto useunittest.IsolatedAsyncioTestCasefor rigorous async testing.gittensor-venvenvironment.Performance Impact
Dependencies
aiohttp==3.11.11torequirements.txt.