perf(ya): defer heavy imports at startup — Δ=-38ms (p=0.0026, BCa CI [12ms, 58ms])#40
Open
KorsarOfficial wants to merge 1 commit intoyandex:mainfrom
Open
perf(ya): defer heavy imports at startup — Δ=-38ms (p=0.0026, BCa CI [12ms, 58ms])#40KorsarOfficial wants to merge 1 commit intoyandex:mainfrom
KorsarOfficial wants to merge 1 commit intoyandex:mainfrom
Conversation
Author
Evidence ReportFull statistical analysis for this optimization: Also available:
All reports: https://github.com/KorsarOfficial/yatool/releases/tag/v1.0-perf-analysis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Defer tier-1 Python imports for faster bootstrap
Summary
Move heavy tier-1 imports (
devtools.ya.core.report,app_config) behindimportlib.import_module()call sites and add PEP 562__getattr__lazyre-exports to four modules in
devtools/ya/core. This eliminates eagerimport graph traversal during
ya --helpand reduces bootstrap overhead.Evidence
Inner-container wall-clock timing (docker exec, n=20, 3 warmup runs):
Statistical validation:
Disclosure: outer Docker timing (measuring container startup + Python)
shows p = 0.091 (not significant). Container startup overhead dominates
at that granularity (~2.4s total vs 38ms signal). Inner-container timing
isolates Python execution and is the authoritative measurement.
Supplementary: full statistical analysis available in the rendered
optimization evidence report (
reporting/output/07-optimization-evidence.tex).Changes
Net change: 4 files modified, ~40 lines changed.
Patches
patches/15-01-task1-defer-tier1-imports.patch(apply first)patches/15-01-task2-pep562-lazy-reexports.patch(apply second)Task 2 must follow task 1. Both patches together constitute this PR.
Testing
See
upstream/test-results.logfor test execution status and environmentalconstraints. Historical validation: patch applied in yatool Docker container
during Phase 15 implementation;
ya make devtools/ya/binsucceeded.CLA
I hereby agree to the terms of the CLA available at:
https://yandex.ru/legal/cla/?lang=en