Repository navigation
Conversation
…erpreter configurations
…ile directory) to the `:set` shell command
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2956 +/- ##
========================================
Coverage 45% 46%
- Complexity 6815 6887 +72
========================================
Files 844 851 +7
Lines 68826 69174 +348
Branches 10040 10075 +35
========================================
+ Hits 31434 31992 +558
+ Misses 34995 34753 -242
- Partials 2397 2429 +32 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sungshik
marked this pull request as ready for review
October 29, 2026 11:50
|
This branch has not been deployed
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.



Summary
This PR adds support to the profiler to write profiles in formats that can be visualized as flame charts/graphs by other tools. Two formats are currently supported:
The

cpuprofileformat originates from the Chrome Dev Tools (CDT) protocol. Files written in this format can be opened, for instance, in VS Code using the "Flame Chart Visualizer for JavaScript Profiles" extension, or in Chrome using the built-in developer tools. Example:Note: The video demonstrates the flame chart for a typecheck of
bird-core. I cut a few frames in the middle of the video, though, to skip 45 seconds of typechecking time.The

foldedformat originates from Brendan Gregg's originalflamegraph.plscript. Files written in this format can be post-processed by that script to SVG. Example:Anecdotally, the profiler adds 10% runtime overhead.
Design/implementation notes
Intuitively, each profiling run consists of two phases: (a) while the evaluator is running, the sampler produces a stream of samples, each of which contains the call stack and a timestamp; (b) after the evaluator has run, the formatter consumes the stream of samples and generates the formatted output.
Following these two phases, new package
org.rascalmpl.interpreter.utils.profilerconsists of new interfacesSamplerandFormatter, as well as their implementations. Through these interfaces, sampling and formatting are decoupled as much as possible.To keep memory pressure low, samples are temporarily written to a file in the sampling phase, and lazily read from that file in the formatting phase, so samples don't need to be kept in memory all at the same time.
IO with the temporary file, as well as de/serialization (using base64-encoded
IValues to avoid the need to pretty-print/parseISourceLocations), are done in a separate auxiliary thread to not block the main thread.Following the existing naming conventions, there are two new configuration properties:
rascal.profileFmtcontrols the format of the profile. Possible values:"none","folded", and"cpuprofile"(default).rascal.profileLoccontrols the directory to which formatted profiles can be written. Possible values: any location (default:|cwd:///|).Like other configuration properties, the new ones can be set when the REPL process is started (e.g.,
'-Drascal.profileFmt="folded"'and-Drascal.profileDir=|home:///Desktop|) or when the REPL process is running (e.g.,:set profileFmt "folded"and:set profileDir |home:///Desktop|).To support strings and locations as arguments of
-Drascal.xyz=...and:set, the existing code for configuration properties was adapted a bit (minor changes).TODO