Reserve padding bytes in the metadata - #83
Conversation
…ly re-saving the trace set
…ing metadata padding
| // which is not been finalized in Java 21. | ||
| System.gc(); | ||
| try { | ||
| Thread.sleep(100); |
There was a problem hiding this comment.
Have you considered reading the comments, the commit log, or the method name? The name of the method is 'awaitFileUnmapping'. System.gc() returns immediately, which will lead to the file handle being kept open until the GC is complete.
There was a problem hiding this comment.
The comment above System.gc(); mentions "requires a garbage collect to have been performed". But it does not mention why the sleep(100) is necessary. I guess because System.gc() is asynchronous, which I didn't know.
The docs about System.gc mention:
When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.
This seems to suggest it is not asynchronous?
I suppose it's a request to do GC, but modern GCs are running in background threads.
There was a problem hiding this comment.
The comment mentions:
Other fixes required either a Java 8 Cleaner.clean() call not accessible from Java 21
Can this not work for java 9-21 ?
sun.misc.Unsafe.invokeCleaner(ByteBuffer)There was a problem hiding this comment.
and then from java 24+ using arenas...?
try (Arena arena = Arena.ofConfined()) {
MemorySegment segment = MemorySegment.mapFile(..., arena);
}This will have less impact on very small trace sets, while still being plenty
143e368 to
39edc87
Compare
This change allows pre-allocating a header of fixed size, which allows a user to make modifications and additions to the global parameters without needing to completely rewrite the file (up to the preset limit). The initial reserved size was 1MB, but it was reduced to 256kB after some user feedback.
close #77