-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
patch a perf bottleneck #79
Conversation
@@ -52,7 +53,7 @@ object Hash { | |||
def apply(as: Array[Byte]): Array[Byte] = apply(new ByteArrayInputStream(as)) | |||
|
|||
/** Calculates the SHA-1 hash of the given file.*/ | |||
def apply(file: File): Array[Byte] = Using.fileInputStream(file)(apply) | |||
def apply(file: File): Array[Byte] = Files.readAllBytes(file.toPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wat. This reads all the bytes in the file. It doesn't calculate the SHA-1 hash for it..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well then apply the hash to it afterwards... the slow bit is the FileFilterStream
like I said, I have absolutely no way of validating anything about this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def apply(file: File): Array[Byte] = apply(Files.readAllBytes(file.toPath))
using sbt/launcher#43 (and including the
and get a CPU profile in yourkit. Unfortunately, it looks like the bottleneck is still there in So the actual bottleneck is the digest calculation. I don't understand why we calculate this again for every file, even if the size and timestamp has not changed. |
I did some analysis that looked the same as sbt/zinc#371 then I came up with this patch.
I've spent the last few hours trying to apply this as a monkey patch, but I can't get it to work, so I have absolutely no idea if it improves anything or not.
UPDATE this needs to actually calculate the hash. My point is that using NIO should be a lot faster than
FileFilterStream
, which is using 99% of my CPU in the profile (not the calculation of the hash).