You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/06/05 16:32:23 UTC

[GitHub] [kafka] dongjinleekr opened a new pull request #10826: KAFKA-7632: Support Compression Level

dongjinleekr opened a new pull request #10826:
URL: https://github.com/apache/kafka/pull/10826


   Since I reworked [KIP-390](https://cwiki.apache.org/confluence/display/KAFKA/KIP-390%3A+Support+Compression+Level) from scratch, here I open a new PR.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dongjinleekr commented on pull request #10826: KAFKA-7632: Support Compression Level

Posted by GitBox <gi...@apache.org>.
dongjinleekr commented on pull request #10826:
URL: https://github.com/apache/kafka/pull/10826#issuecomment-855263796


   @ijuma @guozhangwang Could you have a look when you are free? I refined the original work with a benchmark with a real-world dataset. As you can see in the updated KIP, this option can improve the producer's performance significantly. :pray:


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] kkonstantine commented on pull request #10826: KAFKA-7632: Support Compression Level

Posted by GitBox <gi...@apache.org>.
kkonstantine commented on pull request #10826:
URL: https://github.com/apache/kafka/pull/10826#issuecomment-876779515


   @tombentley do you think you'll be able to finish the review soon? If we had an approval I'd be willing to make an exception and consider this feature for inclusion to AK 3.0. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] tombentley commented on a change in pull request #10826: KAFKA-7632: Support Compression Level

Posted by GitBox <gi...@apache.org>.
tombentley commented on a change in pull request #10826:
URL: https://github.com/apache/kafka/pull/10826#discussion_r648485713



##########
File path: clients/src/main/java/org/apache/kafka/common/record/MemoryRecordsBuilder.java
##########
@@ -183,8 +183,8 @@ public double compressionRatio() {
         return actualCompressionRatio;
     }
 
-    public CompressionType compressionType() {
-        return compressionType;
+    public CompressionConfig compressionConfing() {

Review comment:
       typo, it should be `compressionConfig()`

##########
File path: clients/src/main/java/org/apache/kafka/common/record/CompressionConfig.java
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.common.record;
+
+import org.apache.kafka.common.utils.BufferSupplier;
+import org.apache.kafka.common.utils.ByteBufferOutputStream;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+public class CompressionConfig {
+    private final CompressionType type;
+    private final Integer level;
+
+    public static CompressionConfig none() {
+        return of(CompressionType.NONE);
+    }
+
+    public static CompressionConfig of(final CompressionType type) {
+        return of(Objects.requireNonNull(type), null);
+    }
+
+    public static CompressionConfig of(final CompressionType type, final Integer level) {
+        return new CompressionConfig(Objects.requireNonNull(type), level);
+    }
+
+    private CompressionConfig(final CompressionType type, final Integer level) {
+        this.type = type;
+
+        if (level != null && !type.isValidLevel(level.intValue())) {
+            throw new IllegalArgumentException("Illegal level " + level + " for compression codec " + type.name);

Review comment:
       Should the message include the valid levels?

##########
File path: core/src/main/scala/kafka/server/KafkaConfig.scala
##########
@@ -933,6 +934,9 @@ object KafkaConfig {
   val CompressionTypeDoc = "Specify the final compression type for a given topic. This configuration accepts the standard compression codecs " +
   "('gzip', 'snappy', 'lz4', 'zstd'). It additionally accepts 'uncompressed' which is equivalent to no compression; and " +
   "'producer' which means retain the original compression codec set by the producer."
+  val CompressionLevelDoc = "The compression level for all data generated by the producer. The default level and valid value is up to " +
+    "compression.type. (<code>none</code>, <code>snappy</code>: not available. <code>gzip</code>: 1~9. <code>lz4</code>: 1~17. " +
+    "<code>zstd</code>: -131072~22."

Review comment:
       Since the docs use `[min,...,max]` syntax for things validated by `ConfigDef.Range` I think we should use a similar syntax here for consistency (even though it's not validated by `Range`).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dongjinleekr commented on a change in pull request #10826: KAFKA-7632: Support Compression Level

Posted by GitBox <gi...@apache.org>.
dongjinleekr commented on a change in pull request #10826:
URL: https://github.com/apache/kafka/pull/10826#discussion_r652405099



##########
File path: clients/src/main/java/org/apache/kafka/common/record/CompressionConfig.java
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.common.record;
+
+import org.apache.kafka.common.utils.BufferSupplier;
+import org.apache.kafka.common.utils.ByteBufferOutputStream;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+public class CompressionConfig {
+    private final CompressionType type;
+    private final Integer level;
+
+    public static CompressionConfig none() {
+        return of(CompressionType.NONE);
+    }
+
+    public static CompressionConfig of(final CompressionType type) {
+        return of(Objects.requireNonNull(type), null);
+    }
+
+    public static CompressionConfig of(final CompressionType type, final Integer level) {
+        return new CompressionConfig(Objects.requireNonNull(type), level);
+    }
+
+    private CompressionConfig(final CompressionType type, final Integer level) {
+        this.type = type;
+
+        if (level != null && !type.isValidLevel(level.intValue())) {
+            throw new IllegalArgumentException("Illegal level " + level + " for compression codec " + type.name);

Review comment:
       Let me have a look.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dongjinleekr commented on pull request #10826: KAFKA-7632: Support Compression Level

Posted by GitBox <gi...@apache.org>.
dongjinleekr commented on pull request #10826:
URL: https://github.com/apache/kafka/pull/10826#issuecomment-876259060


   @kkonstantine Here it is - I rebased it onto the latest trunk. Could anyone review this PR? :pray:


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] kkonstantine commented on pull request #10826: KAFKA-7632: Support Compression Level

Posted by GitBox <gi...@apache.org>.
kkonstantine commented on pull request #10826:
URL: https://github.com/apache/kafka/pull/10826#issuecomment-876146029


   This PR implements [KIP-390](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=97550583) but is still open and has several conflicts. Unless I hear from you by EOD Thursday, July 8 (pacific time), I'll remove it from the KIP list for 3.0


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org