perf(ymake): asio pimpl + extern templates — ΔT_inst=-118s (-64.9%) across 19 TUs#42
Open
KorsarOfficial wants to merge 1 commit intoyandex:mainfrom
Open
perf(ymake): asio pimpl + extern templates — ΔT_inst=-118s (-64.9%) across 19 TUs#42KorsarOfficial 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.
Restructure asio headers and add extern template declarations
Summary
Two-part change to reduce asio template instantiation cost in ymake:
Header restructuring: Move
asio.hppinclude behind a pimpl boundaryin
ymake_async.h. Non-async TUs (add_iter.cpp,general_parser.cpp,etc.) no longer transitively pull in all asio headers.
Extern templates: Add explicit instantiation declarations for
asio::any_executor<...>in a singleasio_extern_templates.cpptranslation unit. All other TUs get
extern templatedeclarations,instantiating the type only once.
Together these changes eliminate asio compilation cost from 12 of 19
affected TUs and reduce total asio instantiation time by ~118s.
Evidence
Analytical estimate based on Phase 11 ftime-trace profiling (1213 TUs,
-j1 build) and code analysis of which TUs include asio transitively:
Header restructuring saves ~103,803ms (12 TUs lose all asio cost).
Extern template saves ~14,076ms (7 remaining async TUs lose
any_executor).Note: "estimated" because Docker build produces symlinked ftime-trace files
that resolve inside the container volume; host-side comparison is not
accessible without additional tooling. Build success is the practical
verification (see below). Analytical estimate is conservative -- only
confirmed asio-bearing TUs are counted.
Supplementary: full per-TU breakdown in
data/17-template-before-after.json.Changes
Net change: 6 files modified, 1 file added.
Patch
patches/17-combined.patchSub-patches for review in isolation:
patches/17-01-header-restructuring.patchpatches/17-02-extern-templates.patchNote:
strand<any_io_executor>cannot be explicitly instantiated (usesUnified Executors TS, not Networking TS;
on_work_started/on_work_finishedabsent). Only
any_executor<...>variants are declared extern.Testing
# Build only (no unit tests for header reorganization) ya make devtools/ymake/binBuild success is the verification: if asio pimpl boundary is incorrect or
extern template declarations are malformed, the build fails to link. Runtime
behavior is identical (header reorganization is a pure compilation artifact).
Optional:
ya dump build-plan <target> | jq -S . > after.jsonand diffagainst a pre-patch baseline to confirm identical build graph output.
See
upstream/test-results.logfor test execution status and environmentalconstraints. Historical validation:
ya make devtools/ymake/binsucceededin yatool Docker container during Phase 17 implementation.
CLA
I hereby agree to the terms of the CLA available at:
https://yandex.ru/legal/cla/?lang=en