History log of /frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
45c97df89d6c9d8b5252ba9fc27c41e75c81254d 02-Feb-2018 Jeff Sharkey <jsharkey@android.com> Move more folks to FileUtils.copy().

Also extend API to accept a "count" argument of exactly how many
bytes to copy, and return the actual number of copied bytes.

Improve docs.

Test: bit FrameworksCoreTests:android.os.FileUtilsTest
Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java
Bug: 71932978
Change-Id: I8d255e4f97462838c02a8ecb6d2d221188c4eff0
/frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java
b18f899241231991e314c40990eb8e9f703732d4 01-Feb-2018 Jeff Sharkey <jsharkey@android.com> Use sendfile() and splice() to speed up copying.

There are several places across the OS where Java code is simply
copying data between two points, which requires bringing that data
out into userspace before going back into the kernel. (That's pretty
lame.) The patches for the recent Meltdown/Spectre security issues
have made this overhead even worse, so it's finally time to move this
copying directly into the kernel.

This change adds a couple new FileUtils.copy() methods which inspect
the given streams/FDs, and attempt to do as much optimization as
possible before falling back to a slower userspace-based copy.

Benchmarks are showing typical improvements of 44% for 32KB files,
50% for 32MB files, and 35% for 32MB pipes.

Plenty of tests are included, and there's a simple kill-switch that
can be used to enable/disable the feature if it starts causing any
trouble. (A future CL will enable the optimizations.)

Test: bit FrameworksCoreTests:android.os.FileUtilsTest
Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java
Bug: 71932978
Change-Id: I52518d529da5d961610998b9f61399064d8025cd
/frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java