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
Increase Buffer / Use SequentialScan For Get-FileHash #20881
base: master
Are you sure you want to change the base?
Conversation
- Increased file stream buffer to 64 KiB. - Changed reads to use SequentialScan to support scenarios that optimize based on this.
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
1 similar comment
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |


PR Summary
This change uses an alternate constructor in
Get-FileHashto increase the buffer size to 64 KiB and specifies the SequentialScan option to support scenarios where the kernel / drivers may benefit from knowing the intended read strategy.PR Context
The current Get-FileHash -Path and Get-FileHash -LiteralPath functions currently use System.IO.File.OpenRead() establish a file stream before computing the hash. This function, in turn, calls the FileStream constructor using a default buffer size of 4KiB. While this buffer size is probably a good general purpose value for opening files not knowing how they are going to be used, it does not incorporate the contextual knowledge we have that we are going to read the entirety of the file into memory and we are going to do so sequentially. In testing, this change has notable benefits as file sizes increased.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).