Repository navigation
Compile time: MLIR generation remembers each module's last global (8,000 classes: 7.2 s -> 2.4 s) - #864
Merged
Conversation
Every global goes after the module's last one, which createGlobalVariable found by scanning the module backwards over every function generated so far. It now remembers the global it created last, for each module it creates globals in (the module being generated, the temp module, a discovery module). The entry is dropped wherever the answer can change behind its back: a global erased (a const lambda's, a dummy run's), a temp or discovery module erased, and around MLIRRTTIHelperVC, which makes an exception's type records itself. A module with no entry is scanned as before, so the globals are placed where they were. MLIR generation of 8,000 small classes takes 2.4 s instead of 7.2 s, and now doubles when the source doubles. TSLANG_VERIFY_LLVM_GLOBALS_INDEX=<file> checks the remembered global against the scan too: the suite run that way leaves no file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Follow-up to #862 and #863: the last stage of the compiler that grew faster than the source.
What
Every global goes after the module's last one, and
createGlobalVariablefound that one by scanning the module backwards over every function generated so far. MLIR generation now remembers the global it created last, for each module it creates globals in (the module being generated, the temp module, a discovery module), inMLIRGenImpl::lastGlobalOfModule.Stage times for an object file, no optimisation,
--no-default-lib, from--mlir-timing(Windows x64, Release compiler; a class is two fields, a constructor and one method):With this every stage roughly doubles when the source doubles.
Keeping the remembered global true
The entry of a module is dropped wherever the answer can change without
createGlobalVariableknowing; a module with no entry is scanned as before, so globals are placed where they were.MLIRGenVariables.cpp), and a dummy run's globals, which are erased when the run is cleaned up (those are never remembered).MLIRRTTIHelperVC(RttiGlobalsScope, at its four uses): it makes an exception's type records itself and places them by its own scan.The last case was found by the check below: my first version did not have it, the check logged 765 differences across the suite, and the LLVM IR of several tests changed.
Checking mode
TSLANG_VERIFY_LLVM_GLOBALS_INDEX=<file>, added in #862 for the LLVM globals index, now also compares the remembered global with the scan it replaces, appends any difference to the file and uses the scan's answer.Testing
test-borrow-facts-*. As before they fail on my machine only (the build cache'sCMAKE_ARnames an MSVC toolset that is no longer installed) and pass when rerun with the installedlib.exe.--opt_level=3and-mm=rc: 450 of 453 identical. The other three are00param_assigned_owned.ts, whose output already differs from run to run.docs/performance.md: the "Compile time" paragraph has the new figures.Not covered
🤖 Generated with Claude Code