RFR: 8352536: Add overloads to parse and build class files from/to MemorySegment [v5]

Adam Sotona asotona at openjdk.org
Thu Mar 27 22:24:15 UTC 2025


On Thu, 27 Mar 2025 17:38:49 GMT, David M. Lloyd <duke at openjdk.org> wrote:

>> Provide method overloads to the ClassFile interface of the java.lang.classfile API which allow parsing of classes found in memory segments, as well as allowing built class files to be output to them.
>
> David M. Lloyd has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add a benchmark for class file emission

I have two problems with the numbers you measured:
1. The benchmarked transformation runs on pre-parsed class and does nothing, so technically it measures mainly the memory copy process.
2.  In the discussions there were mentioned memory mapped files as a use case for the off-heap targeting of the classes.

When I modify `ClassfileBenchmark` to replicate your scenario I get these numbers:

Benchmark                                             Mode  Cnt       Score     Error  Units
ClassfileBenchmark.transformWithAddedNOP             thrpt    5   31542.151 ?  63.838  ops/s
ClassfileBenchmark.transformWithAddedNOPWithoutCopy  thrpt    5   31738.045 ? 105.725  ops/s
ClassfileBenchmark.transformWithNewCP                thrpt    5   23514.061 ?  91.453  ops/s
ClassfileBenchmark.transformWithNewCPWithoutCopy     thrpt    5   23824.561 ? 532.565  ops/s
ClassfileBenchmark.transformWithSharedCP             thrpt    5   66083.564 ? 231.388  ops/s
ClassfileBenchmark.transformWithSharedCPWithoutCopy  thrpt    5   66780.329 ? 298.292  ops/s


So my measured performance benefit is around 1% and even that will vaporize when writing to physical files as inteded.


Unfortunately I could not recommend this PR.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/24139#issuecomment-2759659040


More information about the core-libs-dev mailing list