Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ codecov = "llvm-cov --workspace --ignore-filename-regex tasks"
coverage = "run -p oxc_coverage --profile coverage --"
benchmark = "bench -p oxc_benchmark"
minsize = "run -p oxc_minsize --profile coverage --"
allocs = "run -p oxc_track_memory_allocations --profile coverage --"
allocs = "run -p oxc_track_memory_allocations --profile coverage-with-debug --"
rule = "run -p rulegen"

# Build oxlint in release mode
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ lto = "thin" # Faster compile time with thin LTO
debug-assertions = true # Make sure `debug_assert!`s pass
overflow-checks = true # Catch arithmetic overflow errors

# Same as `coverage`, but with debug symbols included for backtraces.
[profile.coverage-with-debug]
inherits = "coverage"
strip = false # Keep debug information in binary
debug = true # Include maximum amount of debug information

# Profile for linting with release mode-like settings.
# Catches lint errors which only appear in release mode.
# `cargo lint --profile dev-no-debug-assertions` is about 35% faster than `cargo lint --release`.
Expand Down
1 change: 1 addition & 0 deletions tasks/track_memory_allocations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ oxc_parser = { workspace = true }
oxc_semantic = { workspace = true }
oxc_tasks_common = { workspace = true }

backtrace = "0.3"
humansize = { workspace = true }
mimalloc-safe = { workspace = true }

Expand Down
24 changes: 24 additions & 0 deletions tasks/track_memory_allocations/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Oxc allocations stats

This task keeps track of the number of system allocations as well as arena allocations and the total number of bytes allocated. This is used for monitoring possible regressions in allocations and improvements in memory usage.

## Callsite aggregation (optional)

You can also aggregate where allocations occur by source location, similar in spirit to dhat-rs. This is disabled by default because collecting backtraces for every allocation is expensive.

- Enable tracking: set `OXC_ALLOC_SITES=1`
- Optional sampling to reduce overhead: set `OXC_ALLOC_SAMPLE=N` to record 1 in `N` allocations (default `1000`).

Example:

```
OXC_ALLOC_SITES=1 OXC_ALLOC_SAMPLE=100 cargo run -p oxc_track_memory_allocations
```

At the end of the run, you'll see a "Top allocation sites" section like:

```
Top allocation sites (sampled 1 in 100)
Location | Allocations
----------------------------------------------------
crates/oxc_parser/src/lexer.rs:123 | 152
crates/oxc_semantic/src/builder.rs:45 | 101
...
```
Loading
Loading