diff options
author | Nathan Harmata <nharmata@google.com> | 2015-10-12 22:23:57 +0000 |
---|---|---|
committer | John Field <jfield@google.com> | 2015-10-13 01:04:04 +0000 |
commit | ce3f8ed44b9983711ddcf30c4fecb53799e3f8b4 (patch) | |
tree | 4d9f1cd7b341617ce8553bfbf68b16119ef980a4 /src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java | |
parent | 808217c1d4674a0678182dfefe0325dab781fc82 (diff) |
Enable Blaze profiling for the VFS_READ on InputStream#read(), since some helper classes do call that method to see if the stream has more data.
This is part of a series of changes with the net result being that we open, read, and parse each BUILD file exactly once.
--
MOS_MIGRATED_REVID=105253425
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java index 2a99d7c8ad..de67af85cf 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java @@ -64,6 +64,17 @@ abstract class AbstractFileSystem extends FileSystem { try { // Replace default FileInputStream instance with the custom one that does profiling. return new FileInputStream(name) { + @Override public int read() throws IOException { + long startTime = Profiler.nanoTimeMaybe(); + try { + // Note that FileInputStream#read() does *not* call any of our overriden methods, + // so there's no concern with double counting here. + return super.read(); + } finally { + profiler.logSimpleTask(startTime, ProfilerTask.VFS_READ, name); + } + } + @Override public int read(byte b[]) throws IOException { return read(b, 0, b.length); } |