This branch:
https://github.com/openjdk/panama-foreign/compare/foreign-jextract...mcimadamore:small_copy_benchmark?expand=1
Contains a new benchmark "TestSmallCopy". No matter how the copy is done (slicing, or static method), the performance of the segment version is worse than when using unsafe directly.
This could be a result of the added safety check which are added by the segment version, but I believe we should investigate this deeper, as something related seems to be causing issues with Lucene.