You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lhotari (via GitHub)" <gi...@apache.org> on 2026/10/19 11:03:22 UTC
[PR] [improve][test] Add a script that builds and installs hsdis for perfasm [pulsar]
lhotari opened a new pull request, #26995:
URL: https://github.com/apache/pulsar/pull/26995
### Motivation
JMH's `-prof perfasm` profiler and `-XX:+PrintAssembly` show the machine code that the JIT generated, annotated with the Java source and with where the CPU spent its cycles. That is often what explains a microbenchmark's result: whether a loop was unrolled, whether a bounds check or a safepoint poll stayed in it, or whether the code's layout makes the CPU decode it slowly. Both need hsdis, a disassembler plugin that JDKs don't ship, since it links GPL-licensed binutils, and perfasm also needs Linux `perf`. Building hsdis takes the JDK's sources at the JVM's exact version, a binutils release and a few workarounds, which the performance testing environment doesn't describe.
### Modifications
- **`tests/performance/environment/scripts/compile-and-install-hsdis.sh`** builds hsdis for the Amazon Corretto JDK that `java` runs and installs it into that JDK:
- It checks that `java` is Corretto 19 or later, whose build has the `build-hsdis` target, and reads its version from `java -version`, such as `25.0.4.8.1`.
- It shallow-clones that tag of `https://github.com/corretto/corretto-<major>`, so that hsdis matches the JVM, downloads binutils (`BINUTILS_VERSION`, 2.43 by default), configures the JDK build with the JDK itself as the boot JDK and runs `make build-hsdis`.
- It installs `hsdis-<arch>.so` into the JDK's `lib/server` directory (`HSDIS_INSTALL_DIR`) and checks that the JVM loads it.
- It assumes a Corretto JDK installed with SDKMAN!, such as with `sdk i java 25.0.4-amzn`, which is in the user's home directory, so that the script installs hsdis without root.
- The build runs in a new directory under `$TMPDIR` or `/tmp`, removed after a successful build and kept after a failed one for its logs; `HSDIS_BUILD_DIR` sets a directory to keep.
- The JDK's `configure` requires the CUPS, fontconfig and ALSA headers even for a headless build, and binutils builds its documentation with `makeinfo`. Neither is part of hsdis, so the script satisfies those checks with stubs and uses the bundled FreeType and zlib: it needs only the build tools and the zlib headers, and it checks for them before building.
- **`tests/performance/environment/README.md`**: a section on disassembling the JIT's code, with the script, how to pick a Corretto JDK with `sdk l java`, how to install `perf` on Ubuntu and on Pop!_OS, whose kernel tools packages have no `perf` binary, the `kernel.perf_event_paranoid` setting that sampling without root needs, and running a microbenchmark with `-prof perfasm`.
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
This change is a developer tool without test coverage. It was verified as follows:
- The script built and installed hsdis for Corretto 25.0.4.8.1 (SDKMAN!'s `25.0.4-amzn`) on Pop!_OS 24.04 in about 2 minutes, from a new temporary directory that it removed afterwards, and the JVM loaded it.
- With it and `perf` 7.2.6, JMH's `-prof perfasm` disassembled a microbenchmark's hot loop, and `-prof perfnorm` with the CPU's front-end events explained a difference of 19.3 ns against 15.2 ns between two code alignments of the same machine code: at one alignment, three quarters of the loop's micro-ops came from the legacy decoder instead of the decoded instruction cache.
- `./gradlew quickCheck` passes.
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*If the box was checked, please highlight the changes*
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [improve][test] Add a script that builds and installs hsdis for perfasm [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari merged PR #26995:
URL: https://github.com/apache/pulsar/pull/26995
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org