Blackhole for preventing dead code elimination (DCE) in benchmarks.
Two modes are supported:
Compiler Blackhole (JVM 17+) Uses -XX:CompileCommand=blackhole,criterium.blackhole.Blackhole::consume to mark consume methods as compiler blackholes. Zero overhead.
Runtime Blackhole (JVM < 17 or flag not present) Uses volatile fields and XOR-based impossible conditions. ~3ns overhead.
Mode is detected at namespace load time. Use mode to check which is active.
Blackhole for preventing dead code elimination (DCE) in benchmarks. Two modes are supported: Compiler Blackhole (JVM 17+) Uses -XX:CompileCommand=blackhole,criterium.blackhole.Blackhole::consume to mark consume methods as compiler blackholes. Zero overhead. Runtime Blackhole (JVM < 17 or flag not present) Uses volatile fields and XOR-based impossible conditions. ~3ns overhead. Mode is detected at namespace load time. Use `mode` to check which is active.
(compiler-blackhole-available?)True if the JVM supports compiler blackholes (version >= 17).
True if the JVM supports compiler blackholes (version >= 17).
(compiler-blackhole-enabled?)True if compiler blackhole mode is active.
True if compiler blackhole mode is active.
(consume x)Consume a value to prevent dead code elimination.
In compiler mode (JVM 17+ with flag), expands to static method call with zero overhead. In runtime mode, expands to instance method call with ~3ns overhead.
The value is evaluated exactly once.
Consume a value to prevent dead code elimination. In compiler mode (JVM 17+ with flag), expands to static method call with zero overhead. In runtime mode, expands to instance method call with ~3ns overhead. The value is evaluated exactly once.
(evaporate)Clear any retained object references from the runtime blackhole. Call after measurement to prevent object retention. No-op in compiler mode.
Clear any retained object references from the runtime blackhole. Call after measurement to prevent object retention. No-op in compiler mode.
(mode)Return the active blackhole mode: :compiler or :runtime.
Return the active blackhole mode: :compiler or :runtime.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |