Improve the efficiency of dex2oat log redirection.

Before this change, it takes ~90s for dex2oat to complete on `pm compile
-v: compiler` on Pixel 8 when it outputs ~100MB logs. This is because
dex2oat writes a lot of small pieces of logs, waking up the reader
thread (e.g., adbd) frequently.

This change buffers the output in a pipe and reads from it occasionally,
for more efficient, less frequent reads.

After this change, it takes ~12s for dex2oat to complete the same task,
7.5x faster than before.

Bug: 441818922
Test: adb shell pm compile -f -m speed-profile -v:compiler com.google.android.apps.photos 2>$HOME/tmp/compile.log
Flag: com.android.art.rw.flags.pm_compile_verbose_logging
Change-Id: Ife140a1e1aba229309fb29bb19fd9bb15658bd95
3 files changed