Repository navigation
Do not keep in memory what result cache symbol tracking does not need - #7057
Merged
Merged
Conversation
…s not extend ObjectType::isOffsetAccessible() asked ClassReflection::is() about each of EXTRA_OFFSET_CLASSES - DOMNodeList, ResourceBundle, PDORow, FFI\CData and others - for every object type that is not an ArrayAccess. That looked each class up, and every lookup is a dependency of the analysed file now: a class found was expanded like a referenced one, resolving the PHPDoc of the built-in class from its PhpStorm stub file and keeping it in memory, and a class missing, like Dom\NodeList, became a value dependency of nearly every file. The answer depends only on the ancestors of the class, which are tracked already, so it is found among them instead, with the same result as is(). Amp-Thread-ID: https://ampcode.com/threads/T-01a1d4f2-262c-75e2-9f82-27a5c05cebf6
OptimizedDirectorySourceLocatorGroup built a map of the symbols of all its locators, a second copy of every class, function and constant name for the rest of the process. It checks the maps of the locators themselves now, shared instead of copied, and still asks only the locators declaring the name. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d4f2-262c-75e2-9f82-27a5c05cebf6
Nearly all of them are lowercase in PhpStormStubsMap already and are looked up there directly; only the others are kept lowercased. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d4f2-262c-75e2-9f82-27a5c05cebf6
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.
The Benchmarks workflow on 2.3.x started failing at 2418876: bug-13218 peakMemory went from 39.2 MB to 43.2 MB (+10.2 %, the limit is ±10 %), and every other benchmark grew by about 2.5 MB. Bisecting locally put the growth in three commits. Each is fixed here in its own commit, and the result cache tracks what it did before:
ObjectType::isOffsetAccessible()askedClassReflection::is()about each ofEXTRA_OFFSET_CLASSES. Since lookups are tracked, each class found was expanded like a referenced class, which resolved its PHPDoc from the whole PhpStorm stub file (intl.phpalone is ~835 KB). The answer depends only on the class's ancestors, which are already tracked, so it now finds the class among them, with the same result asis(). The turbo-ext mirror is changed the same way. This also drops four "missing" value dependencies per file (Dom\NamedNodeMap,Dom\NodeList,Dom\HTMLCollection,Dom\DtdNamedNodeMap).OptimizedDirectorySourceLocatorGroupkept a merged copy of the symbol maps of all its locators. It now checks each locator's own maps, which are shared rather than copied. Locally, 20,000 names declared in none of 44 locators take ~21 ms, against ~4.6 ms with the merged map and ~190 ms when asking each locator in turn (before 8435dd9).CachedPhpInternalSourceLocator::isStubFunction()kept a lowercased copy of all PhpStorm stub functions. It now looks up the stub map directly and keeps only the 335 names that aren't lowercase there.Local peak memory, from
tests/bench/measure.php(the second of two runs):tests/bench/expected.neonis unchanged.Verified locally: the full test suite with and without the turbo extension loaded, the turbo strict build with
smoke.phpand the side-by-side and signature parity checks,bin/phpstan, phpcs, and the result-cache e2e suites for symbol lookups, missing classes, autoload entries, vendor classes and dependency types.