perf: read JS/TS files once during discovery export checks#2136
Merged
aseembits93 merged 2 commits intoperf/discovery-ast-cachefrom May 8, 2026
Merged
perf: read JS/TS files once during discovery export checks#2136aseembits93 merged 2 commits intoperf/discovery-ast-cachefrom
aseembits93 merged 2 commits intoperf/discovery-ast-cachefrom
Conversation
This was referenced May 7, 2026
dcc5bea to
9164a8d
Compare
5ab7ec3 to
084f79c
Compare
This was referenced May 7, 2026
9164a8d to
120ea4b
Compare
084f79c to
5356817
Compare
120ea4b to
beac23d
Compare
5356817 to
2d9fd1e
Compare
The _is_js_ts_function_exported and _is_js_ts_function_exists_but_not_exported helpers each read the file from disk independently, causing up to 2 extra reads per file during get_functions_to_optimize. Add an optional `source` parameter to both functions so callers can pass pre-read content. The main call site now reads the file once and passes it to both helpers. Also fixes pre-existing mypy error in _find_all_functions_via_language_support where discover_functions was called with wrong argument order. Signatures changed: - _is_js_ts_function_exported(file_path, function_name, source=None) - _is_js_ts_function_exists_but_not_exported(file_path, function_name, source=None)
The --file path was calling file.read_text() directly even though find_all_functions_in_file() already primed the discovery cache. Now uses read_file_cached() to hit the cache with zero disk I/O.
beac23d to
93763a3
Compare
2d9fd1e to
39d49b1
Compare
aseembits93
approved these changes
May 8, 2026
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.
Parent PR
#2132 — perf: targeted performance improvements for E2E pipeline hot path
Summary
source: str | Noneparameter to_is_js_ts_function_exported()and_is_js_ts_function_exists_but_not_exported()read_file_cached()when not providedChanges
_is_js_ts_function_exported(): accepts optionalsourceparam_is_js_ts_function_exists_but_not_exported(): accepts optionalsourceparamtests/test_js_ts_export_helpers.py(15 tests)Stack
mainperf/discovery-prefilterperf/discovery-ast-cache