-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[release/6.0-rc2] File preallocationSize: align Windows and Unix behavior. #59532
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsBackport of #59338 to release/6.0 Customer Impact
|
not ready yet, but marking so tactics aware. last day is essentially tomorrow. |
Will send a commit to fix the browser error, strange that we didn't got it in the PR for main.
|
@danmoseley it should be ready now. |
For RC2, right? Is the intent/expectation to backport this PR into |
Ah yes I didn't realize this wasn't targeted at RC2 |
Rebased, hopefully it works. Still need a review |
eng/Versions.props
Outdated
<PreReleaseVersionLabel>rc</PreReleaseVersionLabel> | ||
<PreReleaseVersionIteration>2</PreReleaseVersionIteration> | ||
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel> | ||
<PreReleaseVersionIteration></PreReleaseVersionIteration> |
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.
@danmoseley, these rebases aren't doing the right things...
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.
I suspect it would be easier/cleaner to back out (with a force push) the rebase commit, and change this back to target release/6.0
, merge this as it was into that branch, and then use the backport bot to port from release/6.0
to release/6.0-rc2
.
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.
I think we could cherry-pick Adam and Tom's commits to release/6.0-rc2 then force-push that to this branch; then the bot that syncs rc2 with release/6.0 will port automatically.
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.
Oh wow. I should have noticed what this did. I wonder how many others...
Yes into 6.0 first is fine it just needs to be in RC2 tomorrow. I'm hesitant to attempt to fix anything again..
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.
To be clear, I rebased to include only the relevant commits and is already targeting RC2. No need to manually port to 6.0 as that is made automatically AFAIK.
Co-authored-by: Stephen Toub <[email protected]>
* File preallocationSize: align Windows and Unix behavior. This aligns Windows and Unix behavior of preallocationSize for the intended use-case of specifing the size of a file that will be written. For this use-case, the expected FileAccess is Write, and the file should be a new one (FileMode.Create*) or a truncated file (FileMode.Truncate). Specifing a preallocationSize for other modes, or non-writable files throws ArgumentException. The opened file will have a length of zero, and is ready to be written to by the user. If the requested size cannot be allocated, an IOException is thrown. When the OS/filesystem does not support pre-allocating, preallocationSize is ignored. * fix pal_io preprocessor checks * pal_io more fixes * ctor_options_as.Windows.cs: fix compilation * Update tests * tests: use preallocationSize from all public APIs * pal_io: add back FreeBSD, fix OSX * tests: check allocated is zero when preallocation is not supported. * Only throw for not enough space errors * Fix compilation * Add some more tests * Fix ExtendedPathsAreSupported test * Apply suggestions from code review Co-authored-by: David Cantú <[email protected]> * Update System.Private.CoreLib Strings.resx * PR feedback * Remove GetPathToNonExistingFile * Fix compilation * Skip checking allocated size on mobile platforms. Co-authored-by: David Cantú <[email protected]>
83aa152
to
f85919f
Compare
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.
Looks like a good retargeting to me; thanks, @jozkee. Either @tmds or @stephentoub should take another look through the changes to verify too.
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.
lgtm
Want me to merge now @jozkee ? |
src/libraries/System.IO.FileSystem/tests/FileStream/ctor_options.cs
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
[OuterLoop("Might allocate 1 TB file if there is enough space on the disk")] |
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.
Remind me never to run this suite on outerloop ;-)
src/libraries/System.IO.FileSystem/tests/FileStream/ctor_options.cs
Outdated
Show resolved
Hide resolved
I will be unavailable this afternoon (recruiting) so please rely on someone else to merge when ready. |
Backport of #59338 to release/6.0
Customer Impact
As per @stephentoub in #59338 (comment):
in .NET 6. If you end up writing fewer bytes than you preallocated, in release/6.0 Windows will truncate the file to the number of bytes actually written whereas Linux will end up with a file padded with zeros at the end to meet the preallocationSize. In main (before this change was merged in main), both Windows and Linux will end up with said zeros at the end. This PR tries to bring it to a state where preallocationSize is just a (non-observable) hint purely for performance, such that the resulting file size isn't dependent on the preallocationSize, and the latter is just there to help the system optimize.
The downside is that some OSes/platforms (e.g: browser) don't have the hint behavior and therefore will ignore
preallocationSize
.Testing
Tests are being updated accordingly.
Risk
Low
Note