[foreign-memaccess+abi] RFR: 8313238: Improve the performance of strlen for null-terminated strings
Per Minborg
pminborg at openjdk.org
Thu Aug 3 16:25:56 UTC 2023
On Thu, 3 Aug 2023 13:52:27 GMT, Per Minborg <pminborg at openjdk.org> wrote:
> This PR proposes to use native calls for determining the string length for C-type strings.
>
> Smaller segments (<1024 bytes) is using a trivial call whereas all other segments are using a normal call. We might consider always using regular calls if we think most segments are unbound anyhow.
>
> The PR also contains a number of new tests, one of which requires a large heap size to run. It is likely that this latter test will not run in most test environments. In such cases, it is silently ignored.
Here are some more variants of sizes:
Before:
Benchmark (size) Mode Cnt Score Error Units
InternalStrLen.currentSingleByte 1 avgt 30 1.599 ? 0.031 ns/op
InternalStrLen.currentSingleByte 4 avgt 30 2.969 ? 0.009 ns/op
InternalStrLen.currentSingleByte 16 avgt 30 8.586 ? 0.013 ns/op
InternalStrLen.currentSingleByte 251 avgt 30 124.995 ? 0.832 ns/op
InternalStrLen.currentSingleByte 1024 avgt 30 489.230 ? 2.585 ns/op
After:
Benchmark (size) Mode Cnt Score Error Units
InternalStrLen.nativeSingleByte 1 avgt 30 3.313 ? 0.008 ns/op
InternalStrLen.nativeSingleByte 4 avgt 30 3.310 ? 0.006 ns/op
InternalStrLen.nativeSingleByte 16 avgt 30 3.479 ? 0.017 ns/op
InternalStrLen.nativeSingleByte 251 avgt 30 8.817 ? 0.102 ns/op
InternalStrLen.nativeSingleByte 1024 avgt 30 24.257 ? 0.031 ns/op
<img width="764" alt="image" src="https://github.com/openjdk/panama-foreign/assets/7457876/4c5a2c4b-58d6-443c-a7e1-d22ad8242084">
-------------
PR Comment: https://git.openjdk.org/panama-foreign/pull/857#issuecomment-1664277478
More information about the panama-dev
mailing list