Skip to content

Perf/io - #210

Merged
cmhulbert merged 5 commits into
developmentfrom
perf/io
Apr 3, 2026
Merged

Perf/io#210
cmhulbert merged 5 commits into
developmentfrom
perf/io

Conversation

@cmhulbert

@cmhulbert cmhulbert commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

a few performance optimizations, mostly related to file IO. The largest performance gains were:

  1. don't truncate separately over the file channel when writing, just specify the TRUNCATE_EXISTING OpenOption. It is much faster
  2. for Unsafe, don't use Files.copy for Unsafe. It's much slower than writing via FileChannel.
    • And in any case, it didn't properly handle creating the parent directories
  3. only try to create directory if parent is not already a directory
    • In general, when writing many blocks, this mkdir call is only necessary once per directory. It's cheaper on average to check before calling, instead of calling every time

…g via FileChannel.

fix: ensure parent directories exist before writing file for Unsafe
Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
…ust specify the TRUNCATE_EXISTING OpenOption. It is much faster

Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
…ry (isFile -> throws, null -> creates)

Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
…writes that also fail on closing the file. It's a bit more involved, since we need to flush the write operation, but the logic is the same as for read

Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
@cmhulbert
cmhulbert merged commit d175b54 into development Apr 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants