Repository navigation
Release 0.18.0: faster Laravel hot paths, split generated dispatch, symfony-demo serves every page - #605
Merged
Conversation
…ted table per class instead of a strcmp chain: it ran on every $o->$name and was a quarter of a Laravel /api/notes request
… class behind the dispatcher switch instead of every class's property walk inlined in one function (360K IR lines in a Laravel build)
…wd(3) opens directories on macOS, and the HTTP server asked it per request (7% of a Laravel /api/ping)
…ery caller's shape, and __mc_static_callable's $mono$ clone was another 308K IR lines in a Laravel build
… arm The largest functions clang held in a Laravel build were generated dispatch with every class's body inline: __mc_static_callable (308K IR lines), __mir_clone_erased (178K), the erased spread-call arms (2x165K), class_uses (155K), __mc_unser_alloc and __mc_refl_alloc (128K each), __mc_dyn_spread_fallback (104K). - __mc_static_callable: each class's method tree is its own function - erased clone: a class-id switch calling one function per class, not a chain of descriptor compares over every class - vdisp arm spread unpack: one out-of-line fill per callee (not for by-ref params) - class_uses: data (a static map of trait users + a set of the other names) - unserialize / newInstanceWithoutConstructor: one shared allocator per class - dynamic spread fallback: a name tree over per-(class, method) functions
…ude frame of the site that asked first The variadic pack and default pad arms are kept out of linkonce_odr prelude bodies. The shared __mir_erinv_* helper (hidden, per module) inherited that rule from whichever site built it first: in symfony-demo that was the prelude CallbackFilterIterator::accept, so every erased call of a variadic closure lost its pack - EventDispatcher's optimized listener (...$args) took the event object as its pack and the first request crashed in __mir_array_compact.
…ceWithoutConstructor: a static name map and an integer tree instead of two crc32/string-compare trees (2 x 112K IR lines in a Laravel build)
A foreach whose body unsets from the array it walks iterates a copy, and a foreach over a fresh array owns it. Inside a generator both owners were allocas, dead after the resume switch: the loop end released stack garbage (symfony-demo's ArrayAdapter::generateItems, the first Doctrine metadata lookup, SIGSEGV in __mir_array_release). They now live in frame slots, and a generator destroyed while suspended in such a loop releases them, as a return would.
…defined() into a name map print_r and var_export switched over every class in one function (76K and 107K IR lines in Laravel); they now pick a bucket of at most 64 classes by id range, each bucket its own function. constant() and defined() were a chain of string compares over every admitted name - O(n) per call and 66K IR lines; now a static name map and a bucketed integer tree.
…hod calls A dynamic $o->$m() reaches the method through a synthesized trampoline, which pushed the frame with its own synthetic line and whatever file was being lowered when it was made; the site now leaves its line and file in two slots the trampoline's push takes. A method call emitted as other method calls built on the spot (the __call / plain split, dynamic arms) gave those calls line 0; they now take the line of the call they stand for. ux-live-component reads the template line off the trace: symfony-demo /blog/search answered 500.
This was referenced Nov 9, 2026
Closed
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.
Release 0.18.0: faster Laravel hot paths, smaller generated dispatch, symfony-demo serves every page again
Why
After #602 Laravel served without per-request leaks, but profiles showed avoidable work on every request (property visibility checks,
get_object_vars,getcwd), and the largest functions clang had to hold were generated dispatchers carrying every class's body inline. symfony-demo, which compiled and served every page at #599, crashed on its first request onmain.What changes
Runtime hot paths (Laravel)
$o->$namevisibility) answers by binary search over a per-class sorted table instead of a strcmp chain.get_object_vars/(array)of an erased object: one small function per class behind a class-id switch.getcwd()answers from the cwd cachechdir()already maintains (libcgetcwd(3)opens directories on macOS; the HTTP server asked per request).Generated dispatch split into small functions (no generated function grows with the class count any more)
__mc_static_callable: a function per class (was 308K IR lines in Laravel); no$mono$copy of synthesized dispatchers.clone: class-id switch + function per class (178K).new $c(...$args)): one out-of-line argument unpack per callee (2 x 165K).class_uses: data, not code (155K).unserialize/newInstanceWithoutConstructor: one shared allocation by name, static map + integer tree (2 x 128K).print_r/var_export: buckets of at most 64 classes (107K / 76K).constant()/defined(): static name map instead of an O(n) chain of string compares (66K).Correctness fixes found on symfony-demo (all present on
main)...$argsclosure got its first argument as the pack (EventDispatcher listeners, crash on the first request).foreachthat unsets from the array it walks kept its snapshot in an alloca that died at the resume: the loop end released stack garbage (ArrayAdapter::generateItems, first Doctrine metadata lookup). The snapshot / owned iterable now live in the generator frame and are released when a suspended generator is destroyed.$o->$m()) and through method calls rewritten on the spot (__callsplit) had a synthetic or zero line; ux-live-component reads the template line from the trace (/en/blog/searchanswered 500).Version:
COMPILER_VERSION0.18.0 (bootstrap stays 0.17.0 — no new syntax or builtin used insrc/).Measurements (macOS arm64,
-O2, 1 process, wrk c=8)/api/ping/hello/api/notesPeak memory of one clang part while building Laravel / symfony-demo: 3.3–3.7 GB.
symfony-demo:
/en,/en/blog/,/en/blog/page/2,/uk/blog/,/en/blog/search(also?q=and XHR), a post,/en/blog/rss.xml,/en/loginanswer 200,/en/admin/post/302, unknown path 404; 60 sequential requests stable.Tests
Fixes #575 (its repro now passes: promoted to
tests/aot/cases/uncaught_variadic_handler_dynamic_spread.php; SIGSEGV onmain).New:
dyn_prop_access_denied_many_names,getcwd_follows_chdir,variadic_closure_erased_after_prelude_site,uninit_by_name_many_classes,generator_foreach_unset_snapshot,dump_dispatch_many_classes,trace_line_through_magic_and_dynamic_calls— the crash/trace ones are red onmain. Targeted groups (gen, closure, dyn, prop, clone, serial, print_r, var_export, constant, defined, trace, variadic, reflection, spl, iterator, unserialize, enum, object) green.New issues found on the way: #603 (
class_existsfamily case-sensitive for a runtime name), #604 (constant()on an undeclared class: wrong error message).Not in this PR
/en/blog/~420 KB/request) — separate epic.Owed before merge
Full AOT suite, difftest, Linux gate.