-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Give users the ability to disable gzip content encoding to increase throughput #3822
Comments
I see that Storage.Objects.Insert extends StorageRequest which extends AbstractGoogleJsonClientRequest which in turn extends AbstractGoogleClientRequest. setDisableGZipContent is public setter exists on AbstractGoogleClientRequest, so you should be able to call insertRequest.setDisableGZipContent(true); directly |
Thanks, perhaps there is some miscommunication, i'm complaining about the lack of this feature in this project, google-cloud-java/google-cloud-storage not the library it's wrapping google-api-java-client-services. |
@bmenasha Thanks for clarification. Using BlobWriteChannel will allow you to send data without compressing. String bucketName = "my_unique_bucket";
String blobName = "my_blob_name";
BlobId blobId = BlobId.of(bucketName, blobName);
byte[] content = "Hello, World!".getBytes(UTF_8);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
try (WriteChannel writer = storage.writer(blobInfo)) {
try {
writer.write(ByteBuffer.wrap(content, 0, content.length));
} catch (Exception ex) {
// handle exception
}
} |
Hi, We need this feature as well.
|
Hi @ajaaym Following your recommendation, I replaced the use of storage.create: With using a writer channel: Performance became much worst with the new code. Is this the expected behaviour? |
This is a serious problem with the new storage client. The internal method in HttpStorageRpc does not attempt any configuration on the mediaHttpUploader. This can severely impair performance for files which are not suitable for gzip compression. For instance, the following test ran with a 1GB binary file produces very different results due to high CPU overhead without significant size reduction:
Without gzip: ~35MB/s I'd think that this deserves a higher priority. We cannot upgrade to the new client library until this is fixed. |
I think the write channel performance is similar to issue #3929. The write operation to the API is tied to the chunk size: Unless you want to use large buffers, the performance will likely be slower. Edit: never mind... I see that you're adjusting the chunk size to the size of the data. I missed that. |
Attaching a test case which demonstrates multiple upload mechanisms:
See StoragePerformanceUploadTest in storage-performance-new.zip Edit: test file available here |
Steps to reproduce
On GCE I'm able to achieve 70 MiB/s if I disable gzip encoding when uploading to GCS. With gzip encoding it's much worse at 20 MiB/s. However disabling gzip encoding isn't an option exposed in the interface. This makes google-cloud-java poor in comparison to the REST api it's wrapping.
This is a request to expose the gzip encoding of the stream as a storage option. See code in com.google.cloud.storage.spi.v1.HttpStorageRpc.create there is no code to call StorageRequest.setDisableGZipContent (which defaults to false) on the underling com.google.api.services.storage.StorageRequest:
Can we please provide this feature to maintain comparable performance with the com.google.api.services.storage.* client?
thanks
Code snippet
Uploading an object to GCS and observe performance, then do so with gzip disabled:
Any additional information below
Also, perhaps document somewhere that in order to get any reasonable performance on Java8 it's necessary to disable Galios/Counter mode in java.security: https://stackoverflow.com/questions/25992131/slow-aes-gcm-encryption-and-decryption-with-java-8u20
The text was updated successfully, but these errors were encountered: