eclipse-platform / eclipse.platform

https://eclipse.dev/eclipse/
Eclipse Public License 2.0
84 stars 113 forks source link

[FS] Copy small files using InputStream.transferTo() #1502

Closed HannesWell closed 3 months ago

HannesWell commented 3 months ago

Follow-up on https://github.com/eclipse-platform/eclipse.platform/pull/1471 to not use java.nio.file.Files.copy() for small files because it's slower in that case.

With https://github.com/eclipse-platform/eclipse.platform/pull/1475 InputStream.transferTo() is used, which is optimized from Java-17 to 21 in case a FileInputStream is transferred to a FileOutputStream to perform the copy using FileChannels. In my experiments the latter method and Files.copy() had approximately similar performance in the area of 1MiB large files, while Files.copy() became faster with further growing file-size and was significantly faster for 1GiB files. Since Eclipse-Platform probably requires Java-21 soonish, using 1MiB as threshold seemed to be a good compromise for me.

github-actions[bot] commented 3 months ago

Test Results

 1 734 files  ±0   1 734 suites  ±0   1h 25m 22s :stopwatch: + 1m 26s  3 973 tests ±0   3 951 :white_check_mark: ±0   22 :zzz: ±0  0 :x: ±0  12 516 runs  ±0  12 355 :white_check_mark: ±0  161 :zzz: ±0  0 :x: ±0 

Results for commit 31976544. ± Comparison against base commit 27ff234e.