Repository navigation
A comptime evaluation keeps the type caches: the compiler compiles itself in 96 s where it took 166 (#3351) - #3357
Merged
Merged
Conversation
…pass computed every type's layout again, 4.7 s each over the compiler's types (#3351)
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.
Exact line.
Sema.prepare_comptime_eval_copy(src/Sema.w) replaced the nine type caches (layout size, align and field offsets, copy-ness, needs-drop, unwrapped type, generic-instance identity, generic field types) and the enum-payload cache with empty ones. That was needed when a comptime evaluation worked on a copy beside a live original. Since D120 (#2449) the evaluator takes the Sema whole (comptime_take_semawrites a placeholder back) and its Sema is written back when it finishes, so the caches came back empty. The nexteager_type_caches_passthen computed the layout of every type in the program again.Evidence. Timing
lower_modulestep by step on a 31-line test that importsSema(test/internals_compiler/comptime_value_share_test.w): function bodies 18 ms; the specialization loop 42 s over 64 specializations, nine of which each spent ~4.7 s inpreregister_mir_types, witheager_type_caches_passreportingfresh=22672(every type) each time. Those nine are the specializations whose recheck evaluates something at comptime (print,eprint,List.sort,BTreeSet.drop_entries).Fix. The caches stay: their entries are facts of type ids, which only grow.
Measured.
mir.lowerfor that test: 51 s -> 3.9 s (dev compiler).stage2, built by astage1that has the fix): 95.7 s, against 165.8 s in the builds before it.internals-compiler-tests(two tests that each compile the compiler, one at a time): 71.6 s.Battery: GREEN.
#3351 stays open for the smaller part (codegen and link of functions nothing reaches); its premise is corrected there.