Skip to content

perf(github-api): add optional session parameter to GraphQL utility functions - #697

Closed
mkdev5 wants to merge 2 commits into
entrius:testfrom
mkdev5:fix/repo-scan-session-pooling
Closed

perf(github-api): add optional session parameter to GraphQL utility functions#697
mkdev5 wants to merge 2 commits into
entrius:testfrom
mkdev5:fix/repo-scan-session-pooling

Conversation

@mkdev5

@mkdev5 mkdev5 commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an optional session: Optional[requests.Session] = None parameter to execute_graphql_query, _search_issue_referencing_prs_graphql, and find_solver_from_cross_references in gittensor/utils/github_api_tools.py.

When a caller supplies a pooled requests.Session, execute_graphql_query uses session.post(...) instead of the top-level requests.post(...), allowing urllib3 to reuse the underlying TCP + TLS connection across calls. The default None preserves all existing callers — no behavioural or scoring changes.

Related Issues

Closes #696

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • Tests added/updated
  • Manually tested

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

@xiao-xiao-mao xiao-xiao-mao Bot added the enhancement New feature or request label Apr 22, 2026
@mkdev5 mkdev5 changed the title perf: pool HTTP connections across issue discovery scan round perf(issue-discovery): pool HTTP connections across scan_closed_issues round Apr 22, 2026
The scan_closed_issues path issues hundreds of REST pagination calls and up to 1500 GraphQL solver lookups per validator round. Each call went through the top-level requests.get/post API, which creates and closes a fresh Session per call, so every request paid a new TCP and TLS handshake to api.github.com.

Wrap the scan in a single requests.Session() and thread it through _fetch_closed_issues and find_solver_from_cross_references (via execute_graphql_query and _search_issue_referencing_prs_graphql) so urllib3 keeps the underlying connection pool alive for the whole round. All helpers accept an optional session kwarg that defaults to None, preserving existing callers and tests.
@mkdev5
mkdev5 force-pushed the fix/repo-scan-session-pooling branch from a3435f8 to 99dc5ee Compare April 24, 2026 09:36
…on-pooling

# Conflicts:
#	gittensor/validator/issue_discovery/repo_scan.py
#	tests/validator/test_issue_discovery_repo_scan.py
#	tests/validator/test_repo_scan.py
@mkdev5 mkdev5 changed the title perf(issue-discovery): pool HTTP connections across scan_closed_issues round perf(github-api): add optional session parameter to GraphQL utility functions Apr 28, 2026
@anderdc

anderdc commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Duplicate of #687 which is better scoped/implemented. Closing.

@anderdc anderdc closed this Apr 28, 2026
@anderdc anderdc reopened this Apr 28, 2026
@mkdev5
mkdev5 marked this pull request as draft April 28, 2026 21:35
@anderdc

anderdc commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Closing — current diff doesn't address #696. Please open a fresh issue + PR if the session-pooling change is still wanted.

@anderdc anderdc closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(cache): shallow-copy cache helpers miss mirror PR lists

2 participants