-
Notifications
You must be signed in to change notification settings - Fork 873
use max size semaphore #4220
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
use max size semaphore #4220
Conversation
aeec2e8 to
ef08cbf
Compare
0b21da5 to
9062721
Compare
stack-info: PR: #4220, branch: GarrettBeatty/gcbeatty/taskoptimization/3
9062721 to
a0cbc80
Compare
| Assert.AreEqual(3, bufferedPartNumbers[0], "Part 3 should be buffered"); | ||
|
|
||
| // Verify ReleaseBufferSpace was called for streaming path (immediate capacity release) | ||
| mockBufferManager.Verify(m => m.ReleaseBufferSpace(), Times.Once, |
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.
this isnt true anymore since we hold it until the reader consumes it which is why i removed it
| streamingDataSource = null; | ||
|
|
||
| // Release capacity immediately since we're not holding anything in memory | ||
| _partBufferManager.ReleaseBufferSpace(); |
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.
this was being released here and then also when the reader read the part later on. so we remove this to fix the double release.
Side note:
The original reason i had this hear was because my intent was not count streaming to the user as "holding the part in memory". But for simplicitys sake and this bug fix, we now consider a part that gets directly streamed to the user as "taking up memory". in the future we could probably optimize/change this if we want.
| _partBufferManager.ReleaseBufferSpace(); | ||
|
|
||
| _logger.DebugFormat("BufferedPartDataHandler: [Part {0}] StreamingDataSource added and capacity released", | ||
| partNumber); |
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.
this was being released here and then also when the reader read the part later on. so we remove this to fix the double release.
Side note:
The original reason i had this hear was because my intent was not count streaming to the user as "holding the part in memory". But for simplicity's takes and this bug fix we now consider a part that gets directly streamed to the user as "taking up memory". in the future we could probably optimize/change this if we want.
| { | ||
| // Arrange | ||
| var mockClient = MultipartDownloadTestHelpers.CreateMockS3Client(); | ||
| var mockResponse = MultipartDownloadTestHelpers.CreateSinglePartResponse(1024); |
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.
had to update all of these tests to call DiscoverDownloadStrategyAsync/reservere buffer space before doing any action that would release buffer space. otherwise it was getting exceeded semaphore maximum error (which is expected now)
a0cbc80 to
8b5d911
Compare
8b5d911 to
0942990
Compare
stack-info: PR: #4220, branch: GarrettBeatty/gcbeatty/taskoptimization/3
0942990 to
58d4444
Compare
Stacked PRs:
Description
I noticed during testing using AI that it said the maxinmemoryparts being used from the logs was 1026 even though i had configured it to 1024. this means i was:
This change updates the code to fix the double release and also ensure the semaphores enforce a maximum.
Motivation and Context
#3806
Testing
Types of changes
Checklist
License