Skip to content

Commit

Permalink
perf($OSS): reduce data chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Aug 13, 2021
1 parent 10c65f5 commit 5498716
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@Validated
public interface ReadResourceService {
String BUCKET_OBJECT_NAME_REGEX = "^.+/.+$";
DataSize TINY_CHUNK_SIZE = DataSize.ofBytes(512);
DataSize SMALL_CHUNK_SIZE = DataSize.ofMegabytes(1);
DataSize MEDIUM_CHUNK_SIZE = DataSize.ofMegabytes(4);
DataSize LARGE_CHUNK_SIZE = DataSize.ofMegabytes(8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ResponseEntity<StreamingResponseBody> asyncStreamSingleResource(@NotBlank
}
val httpRanges = HttpRange.parseRanges(range);
if (CollUtil.isEmpty(httpRanges)) {
val getObjectResponse = this.minioHelper.getObject(bucket, object, 0, MEDIUM_CHUNK_SIZE.toBytes());
val getObjectResponse = this.minioHelper.getObject(bucket, object, 0, TINY_CHUNK_SIZE.toBytes());
return ResponseEntity.ok()
.header(HttpHeaders.ACCEPT_RANGES, "bytes")
.contentLength(statObjectResponse.size())
Expand Down Expand Up @@ -90,9 +90,9 @@ private ResponseEntity<StreamingResponseBody> asyncGetResourceRegion(String buck
StatObjectResponse statObjectResponse,
List<HttpRange> httpRanges) {
val getObjectResponse = this.minioHelper.getObject(bucket, object, httpRanges.get(0).getRangeStart(0),
MEDIUM_CHUNK_SIZE.toBytes());
LARGE_CHUNK_SIZE.toBytes());
val start = httpRanges.get(0).getRangeStart(0);
var end = start + MEDIUM_CHUNK_SIZE.toBytes() - 1;
var end = start + LARGE_CHUNK_SIZE.toBytes() - 1;
val resourceLength = statObjectResponse.size();
end = Math.min(end, resourceLength - 1);
val rangeLength = end - start + 1;
Expand Down

0 comments on commit 5498716

Please sign in to comment.