Skip to content

Add lock profiler mode (--lock) - #586

Merged
lucko merged 1 commit into
lucko:masterfrom
Beaness:feature/lock-profiler
Oct 4, 2026
Merged

lucko merged 1 commit into
lucko:masterfrom
Beaness:feature/lock-profiler

Conversation

@Beaness

@Beaness Beaness commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Adds a lock contention profiling mode using async-profiler's lock event.
It measures time spent waiting on synchronized monitors and
java.util.concurrent locks.

Usage: /spark profiler start --lock. In this mode --interval is the
contention threshold in milliseconds (default 10us).

Requires async-profiler, and --ignore-sleeping is disabled in this mode.

Viewer support: lucko/spark-viewer#94

Adds a new sampler mode backed by async-profiler's "lock" event, which
measures the time threads spend waiting on contended monitors
(synchronized) and parked on java.util.concurrent locks.

- new SamplerMode.LOCK / proto SamplerMode.LOCK = 2
- SampleCollector.Lock reads jdk.JavaMonitorEnter + jdk.ThreadPark events
  and converts their duration from ticks to nanoseconds
- `/spark profiler start --lock`, with --interval used as the contention
  threshold in milliseconds (default 10us, same as async-profiler)
- --ignore-sleeping is disabled in lock mode, as parked threads are
  exactly what is being measured
@lucko
lucko merged commit 03210f7 into lucko:master Oct 4, 2026
@lucko

lucko commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants