-
Notifications
You must be signed in to change notification settings - Fork 5
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
Several code/performance improvements #225
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cthulhu-rider
requested review from
roman-khimov,
smallhive and
tatiana-nspcc
as code owners
June 25, 2024 12:52
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #225 +/- ##
==========================================
+ Coverage 22.11% 22.21% +0.09%
==========================================
Files 17 17
Lines 3305 3300 -5
==========================================
+ Hits 731 733 +2
+ Misses 2439 2431 -8
- Partials 135 136 +1 ☔ View full report in Codecov by Sentry. |
roman-khimov
previously approved these changes
Jun 25, 2024
cthulhu-rider
force-pushed
the
fast-improvements
branch
from
June 25, 2024 13:26
e6826ee
to
917a404
Compare
Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
cthulhu-rider
force-pushed
the
fast-improvements
branch
from
June 25, 2024 15:34
917a404
to
3c06296
Compare
tatiana-nspcc
approved these changes
Jun 25, 2024
smallhive
reviewed
Jun 26, 2024
smallhive
reviewed
Jun 26, 2024
cthulhu-rider
force-pushed
the
fast-improvements
branch
from
June 26, 2024 07:26
3c06296
to
209157f
Compare
Several API handlers call `io.CopyBuffer` passing buffer of static parameter size. Previously, this parameter was of int64 type and converted from uint64 `MaxObjectSize` (M) NeoFS network setting. In practice, such a numerical cast was quite safe: M is normally positive and not bigger than int64. However, since this parameter is used to allocated buffers passed to `io.CopyBuffer`, there were rooms for panic: - zero value could cause specific `io.CopyBuffer` panic - int64 overflow could cause `make` panic on negative len input From now parameter type is uint64, so negative case is prevented. Zero case is still possible at the type level, so it is replaced by default at 4MB at the app layer. Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Previously, `NewUploadContainerObject` handler always allocated buffer of max object size (NeoFS setting) to copy request body. In practice, this value is pretty big to be buffer size (e.g. it is 64M usually now). Moreover, for requests with a smaller body, part of the buffer remained simply redundant. From now buffer size is determined according to `Content-Length` header. This will significantly reduce the memory consumption of small queries. However, the header will cover only part of the cases: the previous behavior is left in case of its absence or MaxObjectSize overflow. Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Continues f1f7ab4 for `UploadContainerObject`. Size of the file from the multipart form is at hand, so using it to allocate a buffer will improve performance on small volumes. Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
According to the code, operand cannot be nil. Otherwise, the unconditional `io.CopyBuffer` call within the same method would be unsafe and removed if-condition only raised suspicions of potential panic. Deferred action is also moved "closer" to the file init. Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
`NewUploadContainerObject`, `UploadContainerObject` and `PutObject` put objects to the NeoFS in a very similar way. Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
cthulhu-rider
force-pushed
the
fast-improvements
branch
from
June 26, 2024 07:29
209157f
to
1370519
Compare
smallhive
approved these changes
Jun 26, 2024
roman-khimov
approved these changes
Jun 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.