[foreign-memaccess+abi] RFR: 8268266: Investigate way to lazily customize upcall lambda forms

Jorn Vernee jvernee at openjdk.java.net
Thu Jun 10 18:55:37 UTC 2021


Hi,

This patch makes upcall method handle customization lazy, which helps a lot in reducing the number of lambda form classes generated during for intstance the TestUpcall test, making it complete a lot faster.

This adds a very slight overhead per call, since there's another indirection, but I think the tradeoff is acceptable.

Since the patch was otherwise really small, this also adds a qsort benchmark that is also used the measure the cost of the extra indirection. Results are as follows:


QSort without lazy customization:

Benchmark                         Mode  Cnt      Score     Error  Units
QSort.jni_upcall_qsort_naive      avgt   30  21096.871 � 299.669  ns/op
QSort.jni_upcall_qsort_optimized  avgt   30   3603.495 �  16.464  ns/op
QSort.native_qsort                avgt   30     96.236 �   0.713  ns/op
QSort.panama_upcall_qsort         avgt   30    937.675 �  26.160  ns/op

QSort with lazy customization:

Benchmark                         Mode  Cnt      Score     Error  Units
QSort.jni_upcall_qsort_naive      avgt   30  21454.476 � 306.135  ns/op
QSort.jni_upcall_qsort_optimized  avgt   30   3691.395 �  35.671  ns/op
QSort.native_qsort                avgt   30     97.440 �   0.894  ns/op
QSort.panama_upcall_qsort         avgt   30   1072.929 �  14.948  ns/op


So, while there is some regression from this change, it's not super bad (not integer factor), and I think the tradeoff is worth it to generate fewer lambda form classes, which of course has it's own overhead not visible in this benchmark.

Thanks,
Jorn

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

Commit messages:
 - Add QSort benchmark
 - Lazily customize upcall method handles

Changes: https://git.openjdk.java.net/panama-foreign/pull/553/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=553&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8268266
  Stats: 446 lines in 11 files changed: 387 ins; 52 del; 7 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/553.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/553/head:pull/553

PR: https://git.openjdk.java.net/panama-foreign/pull/553


More information about the panama-dev mailing list