Implementation of IO with Panama

Radosław Smogura mail at smogura.eu
Thu Apr 15 23:37:33 UTC 2021


Hi all,

I hope you have a good day.

I started implementing I/O for JDK using Panama (I could not find such project). I think this is natural consequence of Panama project.

Right now, it's done as separate Maven project, which can be found here https://github.com/rsmogura/panama-io

Generally, I'm happy it went so smooth.

Well done!

I created CachedAllocator (first version) which will keep memory segments cached to avoid calling alloc / free (I did not make performance tests between both versions).

I created as well simple benchmarks
Benchmark                          Mode  Cnt        Score        Error  Units
SocketReadJdk.teatRead4k          thrpt   15  1202109.549 ± 127132.855  ops/s
SocketReadJdk.testRead16b         thrpt   15  2818334.225 ±  82209.971  ops/s
SocketReadJdk.testRead8bOffset    thrpt   15  2851310.595 ±  20675.631  ops/s
SocketReadPosix.teatRead4k        thrpt   15  1187974.868 ± 101285.497  ops/s
SocketReadPosix.testRead16b       thrpt   15  2963827.190 ±  62004.165  ops/s
SocketReadPosix.testRead8bOffset  thrpt   15  2999631.814 ±  23925.859  ops/s

>From minor things and ideas:

  *   I could not capture errno using jextract, my script uses --include-var errno, but I had ask for this symbol manually
  *   Privately I wonder about safety of errno, as between call to Posix function and reading value we have JVM, which can meantime invoke Posix methods too and make errno dirty (low probability I think)
  *   I wonder if we could add class LocalSegmentAllocator which will allocate memory segment on stack (I know there are some risks)

If you have any questions, or ideas I'm happy to answer.

and I think with moving forward I can provide quite interesting feedback.

The goal is to make complete rewrite, together with mmap, and async I/O.

Best regards,
Rado


More information about the panama-dev mailing list