How thlorenz/deoptigate works
1. What the repository is
- deoptigate is a Node.js CLI plus a browser-based report viewer for V8 performance logs.
- Its core job is to take either an app entrypoint or an existing *-v8.log, parse optimization/deoptimization data, and present it grouped by source file and code location.
2. Primary execution paths
- The CLI can start from source code: deoptigate app.js.
- Or it can start from preexisting logs in the current directory.
- In the “app.js” flow, the tool launches Node with V8 logging enabled, produces a log, then analyzes it.
3. CLI / process boundary
- The bin/ scripts are the user-facing entrypoints:
- deoptigate is the main command.
- deoptigate.create-log.js, deoptigate.find-log.js, and deoptigate.open-log.js support log creation, discovery, and opening.
- This is the boundary where filesystem access and subprocess execution happen; everything after that is log analysis and UI generation.
4. Log ingestion and parsing
- lib/line-reader.js suggests streaming log processing rather than loading the whole file at once.
- lib/log-processing/ contains the typed record parsers and models for the V8 log stream:
- code-entry.js
- deopt-entry.js
- ic-entry.js
- ic-state.js
- optimization-state.js
- These modules turn raw log lines into structured events the rest of the system can aggregate.
5. Analysis and severity classification
- lib/severities.js likely maps parsed events into user-facing importance levels.
- The optimization and IC state modules indicate the tool distinguishes deoptimizations, inline cache transitions, and code/optimization lifecycle events rather than treating the log as a single generic event stream.
6. Source-file and location grouping
- lib/grouping/ is the main analysis layer that turns event streams into reportable units:
- resolve-files.js binds log references back to actual source files.
- location.js represents a file/line/column-style location boundary.
- group-by-file.js and group-by-file-and-location.js aggregate events at different granularities.
- summarize-file.js builds file-level rollups.
- This is the key data-model transformation: raw V8 events → grouped per file/location summaries.
7. Rendering and code annotation
- lib/rendering/ handles how source code is visually marked in the report.
- marker-resolver.js and mark-only.js suggest a separation between deciding what to highlight and actually applying highlight/marker output.
- The output is an annotated code view tied to the grouped analysis results.
8. Browser application
- app/ is the front-end report UI.
- app/components/ contains the main panels:
- files.js for file navigation,
- summary.js for aggregate results,
- file-details.js for per-file inspection,
- code.js for source display,
- toolbar.js for filtering/navigation controls.
- app/lib/ contains browser-specific support such as:
- query-state.js for URL/state synchronization,
- create-page.js for assembling the report page,
- save-parts.js for packaging/splitting report artifacts.
9. Generated frontend artifacts
- app/build/ contains built assets (deoptigate.js, deoptigate.css) that are shipped to render the report.
- This implies the browser UI is compiled separately from the Node analysis pipeline.
10. Overall data flow
- Input is either a Node program or an existing V8 log file.
- The CLI acquires or finds the log, parses it into typed entries, groups and summarizes those entries by file and location, then feeds that data into the browser UI.
- The browser side renders summaries and code annotations, with URL/query state preserving selection and filters.
11. Repo testing and fixtures
- Tests live under test/ and use real log fixtures in test/logs/ such as adders.v8.log and two-modules.v8.log.
- This indicates the analysis pipeline is validated against representative V8 output, not mocked abstractions.
12. Important architectural boundary to draw
- The clearest split is:
- Node/CLI + log processing + grouping on one side,
- browser report rendering on the other.
- The only shared contract between them is the structured analysis result derived from V8 logs and source-file resolution.
Main entry points: create-page.js create page · log-processing log parsing · grouping grouping · deoptigate.log.js log model
Components 28
CLI + analysis
Node entrypoints, log acquisition, parsing, grouping, and report generation.
- deoptigate · Main command for launching analysis from an app or an existing V8 log.
bin/deoptigate - create log · Starts Node with V8 logging enabled to generate a fresh log.
bin/deoptigate.create-log.js - find log · Discovers existing V8 log files in the working directory.
bin/deoptigate.find-log.js - open log · Opens a generated or discovered log for analysis/reporting.
bin/deoptigate.open-log.js - log model · Top-level log analysis and orchestration contract.
deoptigate.log.js - line reader · Streaming reader for V8 log ingestion.
lib/line-reader.js - log parsing · Parses raw V8 log lines into structured optimization, IC, and deopt records.
lib/log-processing - code entry · Represents code-related log records.
lib/log-processing/code-entry.js - deopt entry · Represents deoptimization events.
lib/log-processing/deopt-entry.js - IC entry · Represents inline-cache events.
lib/log-processing/ic-entry.js - grouping · Resolves source files and aggregates events by file and location.
lib/grouping - resolve files · Maps log references back to concrete source files.
lib/grouping/resolve-files.js - file + location · Groups events by file and code location.
lib/grouping/group-by-file-and-location.js - file summary · Builds per-file summaries from grouped events.
lib/grouping/summarize-file.js - rendering · Turns grouped analysis into highlighted source annotations.
lib/rendering - marker resolver · Decides what should be highlighted in source output.
lib/rendering/marker-resolver.js
Browser report
Front-end components and browser-side report assembly.
- app shell · Browser application bootstrap for the report UI.
app/main.js - create page · Assembles the browser report page from analysis results.
app/lib/create-page.js - query state · Synchronizes selection and filters with the URL/state.
app/lib/query-state.js - files · File navigation panel.
app/components/files.js - summary · Aggregate results panel.
app/components/summary.js - details · Per-file inspection view.
app/components/file-details.js - code view · Annotated source display.
app/components/code.js - toolbar · Filtering and navigation controls.
app/components/toolbar.js - built UI · Compiled browser JavaScript and CSS shipped with the report.
app/build/deoptigate.js
Examples + tests
Representative inputs and validation fixtures.
- adders example · Minimal V8 logging example used to exercise the pipeline.
examples/simple/adders.js - two modules · Multi-file example for cross-file grouping behavior.
examples/two-modules/adders.js - log fixtures · Real V8 log fixtures used to validate parsing and grouping.
test/logs/adders.v8.log
Connections 28
- deoptigate → create log: creates log · Starts a logged Node run when given an app entrypoint.
- deoptigate → find log: discovers log · Locates existing V8 log files in the current directory.
- deoptigate → open log: opens log · Hands a chosen log off for analysis and viewing.
- create log → log model: produces input · Emits the log artifact consumed by analysis.
- find log → log model: selects input · Provides an existing log to the analysis pipeline.
- open log → log model: loads analysis · Connects the chosen log to the shared analysis flow.
- log model → line reader: streams · Reads log contents incrementally.
- line reader → log parsing: feeds lines · Supplies raw log lines to typed parsers.
- log parsing → code entry: parses · Creates code-related records.
- log parsing → deopt entry: parses · Creates deoptimization records.
- log parsing → IC entry: parses · Creates inline-cache records.
- log parsing → grouping: aggregates into · Hands structured records to the grouping layer.
- grouping → resolve files: resolves · Maps log references to real source files.
- grouping → file + location: groups by · Aggregates events by file and location.
- file + location → file summary: rolls up · Produces file-level summaries.
- grouping → rendering: supplies markers · Passes grouped analysis to annotation generation.
- rendering → marker resolver: decides highlights · Determines source markers and emphasis.
- app shell → create page: assembles · Builds the report page from analysis output.
- create page → query state: syncs state · Keeps view selection and filters in the URL.
- create page → files: renders · Displays file navigation.
- create page → summary: renders · Displays the summary panel.
- create page → details: renders · Displays per-file details.
- create page → code view: renders · Displays annotated code.
- create page → toolbar: renders · Displays filtering controls.
- app shell → built UI: uses build · Loads compiled browser assets for the report UI.
- log fixtures → log parsing: validates · Fixture logs exercise the parser and grouping pipeline.
- adders example → create log: exercises · Simple app used to generate and analyze a log.
- two modules → grouping: exercises · Multi-module sample validates grouping across files.