You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "mayuehappy (via GitHub)" <gi...@apache.org> on 2024/01/11 13:27:20 UTC

[PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

mayuehappy opened a new pull request, #24072:
URL: https://github.com/apache/flink/pull/24072

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   support set CompressionType for RocksDBStateBackend
   
   ## Brief change log
   
   add CompressionType option in RocksDBConfiguredOptions
   
   ## Verifying this change
   
   RocksDBStateBackendConfigTest help to verify the legality.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: ( no)
     - The serializers: ( no )
     - The runtime per-record code paths (performance sensitive): (no )
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no )
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
   


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1458185586


##########
docs/layouts/shortcodes/generated/rocksdb_configurable_configuration.html:
##########
@@ -62,6 +62,12 @@
             <td><p>Enum</p></td>
             <td>The specified compaction style for DB. Candidate compaction style is LEVEL, FIFO, UNIVERSAL or NONE, and Flink chooses 'LEVEL' as default style.<br /><br />Possible values:<ul><li>"LEVEL"</li><li>"UNIVERSAL"</li><li>"FIFO"</li><li>"NONE"</li></ul></td>
         </tr>
+        <tr>

Review Comment:
   The CI failed seems because the doc is not consistent with [RocksDBConfigurableOptions.java](https://github.com/apache/flink/pull/24072/files#diff-162968bbd8c0d2dbfd91b191a97fa012ab1b3c27a329a2581746a66ad8ac76a3), Could you check it ?



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1458185586


##########
docs/layouts/shortcodes/generated/rocksdb_configurable_configuration.html:
##########
@@ -62,6 +62,12 @@
             <td><p>Enum</p></td>
             <td>The specified compaction style for DB. Candidate compaction style is LEVEL, FIFO, UNIVERSAL or NONE, and Flink chooses 'LEVEL' as default style.<br /><br />Possible values:<ul><li>"LEVEL"</li><li>"UNIVERSAL"</li><li>"FIFO"</li><li>"NONE"</li></ul></td>
         </tr>
+        <tr>

Review Comment:
   The CI failed seems because the doc is not consistent with [RocksDBConfigurableOptions.java](https://github.com/apache/flink/pull/24072/files#diff-162968bbd8c0d2dbfd91b191a97fa012ab1b3c27a329a2581746a66ad8ac76a3), Could you check it ?
   You could regenerate the doc follwing the method in README of flink-docs.



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1450005923


##########
flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/RocksDBStateBackendConfigTest.java:
##########
@@ -557,6 +559,9 @@ public void testConfigurableOptionsFromConfig() throws Exception {
             configuration.setString(RocksDBConfigurableOptions.LOG_FILE_NUM.key(), "10");
             configuration.setString(RocksDBConfigurableOptions.LOG_MAX_FILE_SIZE.key(), "2MB");
             configuration.setString(RocksDBConfigurableOptions.COMPACTION_STYLE.key(), "level");
+            configuration.setString(

Review Comment:
   Let's also test other compression type to guarantee these could work.



##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =

Review Comment:
   Could we also introduce CompressionPerLevel ?
   From my experience, the space amplification may affect the performace more obviously when state size is larger than L2 or higher level.
   So maybe we have to configure different compression for different levels.



##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =
+            key("state.backend.rocksdb.compression.type")
+                    .enumType(CompressionType.class)
+                    .defaultValue(SNAPPY_COMPRESSION)
+                    .withDescription(
+                            String.format(
+                                    "The specified compression type for DB. Candidate compression type is %s, %s, %s, %s, %s, "
+                                            + "%s, %s, %s or %s, and RocksDB choose '%s' as default style.",
+                                    NO_COMPRESSION.name(),
+                                    SNAPPY_COMPRESSION.name(),
+                                    ZLIB_COMPRESSION.name(),

Review Comment:
   I'd suggest to:
   1. just remain most common-used and lightweight algorithm e.g. NO/SNAPPY/LZ4 to reduce user choice.
   2. add some description about how to choose among them.
   WDYT ?



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1455150026


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -149,24 +144,42 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
-    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =
-            key("state.backend.rocksdb.compression.type")
+    public static final ConfigOption<List<CompressionType>> COMPRESSION_PER_LEVEL =
+            key("state.backend.rocksdb.compression.per.level")
                     .enumType(CompressionType.class)
-                    .defaultValue(SNAPPY_COMPRESSION)
+                    .asList()
+                    .defaultValues(SNAPPY_COMPRESSION)
                     .withDescription(
-                            String.format(
-                                    "The specified compression type for DB. Candidate compression type is %s, %s, %s, %s, %s, "
-                                            + "%s, %s, %s or %s, and RocksDB choose '%s' as default style.",
-                                    NO_COMPRESSION.name(),
-                                    SNAPPY_COMPRESSION.name(),
-                                    ZLIB_COMPRESSION.name(),
-                                    BZLIB2_COMPRESSION.name(),
-                                    LZ4_COMPRESSION.name(),
-                                    LZ4HC_COMPRESSION.name(),
-                                    XPRESS_COMPRESSION.name(),
-                                    ZSTD_COMPRESSION.name(),
-                                    DISABLE_COMPRESSION_OPTION.name(),
-                                    SNAPPY_COMPRESSION.name()));
+                            Description.builder()
+                                    .text(
+                                            "A semicolon-separated list of Compression Type. Different levels can have different "
+                                                    + "compression policies. In many cases, lower levels use fast compression algorithms,"
+                                                    + " while higher levels with more data use slower but more effective compression algorithms. "
+                                                    + "If the COMPRESSION_PER_LEVEL list is not empty, it should have an entry for each level of the database, "
+                                                    + "When level_compaction_dynamic_level_bytes=true, compression_per_level[0] still determines L0, but other "

Review Comment:
   What is `level_compaction_dynamic_level_bytes`?



##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -149,24 +144,42 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
-    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =
-            key("state.backend.rocksdb.compression.type")
+    public static final ConfigOption<List<CompressionType>> COMPRESSION_PER_LEVEL =
+            key("state.backend.rocksdb.compression.per.level")
                     .enumType(CompressionType.class)
-                    .defaultValue(SNAPPY_COMPRESSION)
+                    .asList()
+                    .defaultValues(SNAPPY_COMPRESSION)
                     .withDescription(
-                            String.format(
-                                    "The specified compression type for DB. Candidate compression type is %s, %s, %s, %s, %s, "
-                                            + "%s, %s, %s or %s, and RocksDB choose '%s' as default style.",
-                                    NO_COMPRESSION.name(),
-                                    SNAPPY_COMPRESSION.name(),
-                                    ZLIB_COMPRESSION.name(),
-                                    BZLIB2_COMPRESSION.name(),
-                                    LZ4_COMPRESSION.name(),
-                                    LZ4HC_COMPRESSION.name(),
-                                    XPRESS_COMPRESSION.name(),
-                                    ZSTD_COMPRESSION.name(),
-                                    DISABLE_COMPRESSION_OPTION.name(),
-                                    SNAPPY_COMPRESSION.name()));
+                            Description.builder()
+                                    .text(
+                                            "A semicolon-separated list of Compression Type. Different levels can have different "
+                                                    + "compression policies. In many cases, lower levels use fast compression algorithms,"
+                                                    + " while higher levels with more data use slower but more effective compression algorithms. "
+                                                    + "If the COMPRESSION_PER_LEVEL list is not empty, it should have an entry for each level of the database, "

Review Comment:
   > it should have an entry for each level of the database
   
   That's not true, isn't it?



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on PR #24072:
URL: https://github.com/apache/flink/pull/24072#issuecomment-1898103526

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1457153572


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -149,24 +144,42 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
-    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =
-            key("state.backend.rocksdb.compression.type")
+    public static final ConfigOption<List<CompressionType>> COMPRESSION_PER_LEVEL =
+            key("state.backend.rocksdb.compression.per.level")
                     .enumType(CompressionType.class)
-                    .defaultValue(SNAPPY_COMPRESSION)
+                    .asList()
+                    .defaultValues(SNAPPY_COMPRESSION)
                     .withDescription(
-                            String.format(
-                                    "The specified compression type for DB. Candidate compression type is %s, %s, %s, %s, %s, "
-                                            + "%s, %s, %s or %s, and RocksDB choose '%s' as default style.",
-                                    NO_COMPRESSION.name(),
-                                    SNAPPY_COMPRESSION.name(),
-                                    ZLIB_COMPRESSION.name(),
-                                    BZLIB2_COMPRESSION.name(),
-                                    LZ4_COMPRESSION.name(),
-                                    LZ4HC_COMPRESSION.name(),
-                                    XPRESS_COMPRESSION.name(),
-                                    ZSTD_COMPRESSION.name(),
-                                    DISABLE_COMPRESSION_OPTION.name(),
-                                    SNAPPY_COMPRESSION.name()));
+                            Description.builder()
+                                    .text(
+                                            "A semicolon-separated list of Compression Type. Different levels can have different "
+                                                    + "compression policies. In many cases, lower levels use fast compression algorithms,"
+                                                    + " while higher levels with more data use slower but more effective compression algorithms. "
+                                                    + "If the COMPRESSION_PER_LEVEL list is not empty, it should have an entry for each level of the database, "
+                                                    + "When level_compaction_dynamic_level_bytes=true, compression_per_level[0] still determines L0, but other "

Review Comment:
   A minor suggestion: replace level_compaction_dynamic_level_bytes with USE_DYNAMIC_LEVEL_SIZE.key() which could help developers to find the description conviently



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1452854496


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =

Review Comment:
   +1 to the idea of @pnowojski 



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "mayuehappy (via GitHub)" <gi...@apache.org>.
mayuehappy commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1455847890


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -149,24 +144,42 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
-    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =
-            key("state.backend.rocksdb.compression.type")
+    public static final ConfigOption<List<CompressionType>> COMPRESSION_PER_LEVEL =
+            key("state.backend.rocksdb.compression.per.level")
                     .enumType(CompressionType.class)
-                    .defaultValue(SNAPPY_COMPRESSION)
+                    .asList()
+                    .defaultValues(SNAPPY_COMPRESSION)
                     .withDescription(
-                            String.format(
-                                    "The specified compression type for DB. Candidate compression type is %s, %s, %s, %s, %s, "
-                                            + "%s, %s, %s or %s, and RocksDB choose '%s' as default style.",
-                                    NO_COMPRESSION.name(),
-                                    SNAPPY_COMPRESSION.name(),
-                                    ZLIB_COMPRESSION.name(),
-                                    BZLIB2_COMPRESSION.name(),
-                                    LZ4_COMPRESSION.name(),
-                                    LZ4HC_COMPRESSION.name(),
-                                    XPRESS_COMPRESSION.name(),
-                                    ZSTD_COMPRESSION.name(),
-                                    DISABLE_COMPRESSION_OPTION.name(),
-                                    SNAPPY_COMPRESSION.name()));
+                            Description.builder()
+                                    .text(
+                                            "A semicolon-separated list of Compression Type. Different levels can have different "
+                                                    + "compression policies. In many cases, lower levels use fast compression algorithms,"
+                                                    + " while higher levels with more data use slower but more effective compression algorithms. "
+                                                    + "If the COMPRESSION_PER_LEVEL list is not empty, it should have an entry for each level of the database, "

Review Comment:
   Emm, I directly copied the comment for this parameter in the RocksDB code, and I think this description is inaccurate and I have updated it



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "mayuehappy (via GitHub)" <gi...@apache.org>.
mayuehappy commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1450153620


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =

Review Comment:
   Introduce CompressionPerLevel  requires passing in a CompressType List for each level.
   I idea is to introduce a config like 
   `ConfigOption<List<CompressType>> CompressionPerLevel `
   But I'm worried about whether the cost to users is too high. After all, many flink users may not understand rocksdb or even lsm.
   Do you have any suggestions ? 



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #24072:
URL: https://github.com/apache/flink/pull/24072#issuecomment-1887177365

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7c3926354e1a872d465b2830ce80dc5d8ef65a26",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7c3926354e1a872d465b2830ce80dc5d8ef65a26",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7c3926354e1a872d465b2830ce80dc5d8ef65a26 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1455138026


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =

Review Comment:
   ๐Ÿ‘ Keeping it consistent with the rocksdb naming makes sense. Good that someone from RocksDB had the same idea as me how to configure it ๐Ÿ˜† 



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "mayuehappy (via GitHub)" <gi...@apache.org>.
mayuehappy commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1455112632


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =

Review Comment:
   @pnowojski @masteryhx thanks for suggestion . After I read the related documentation and code. I think maybe we can just use the API `public ColumnFamilyOptions setCompressionPerLevel(
         final List<CompressionType> compressionLevels)`  directly. We can pass in a List of CompressionType to represent different levels of Compression Style.
   
   
   https://github.com/facebook/rocksdb/blob/65e162bf09e6d81d5de533539753d80c008717fd/include/rocksdb/advanced_options.h#L399C1-L426C5
   >   // NOTE: if the vector size is smaller than the level number, the undefined
   >   // lower level uses the last option in the vector, for example, for 3 level
   >   // LSM tree the following settings are the same:
   >   // {kNoCompression, kSnappyCompression}
   >   // {kNoCompression, kSnappyCompression, kSnappyCompression}
   
   It can be seen that the effect of using this parameter directly is actually the same as @pnowojski 's idea. So it seems that we do not need to rename parameter name to `rocksdb.compression.types` but directly use the following parameters `state.backend.rocksdb.compression.per.level`.
   I have updated the pr. Please comment if you have any other suggestions.
   



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "mayuehappy (via GitHub)" <gi...@apache.org>.
mayuehappy commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1450153620


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =

Review Comment:
   @masteryhx Introduce CompressionPerLevel  requires passing in a CompressType List for each level.
   My idea is to introduce a config like 
   `ConfigOption<List<CompressType>> CompressionPerLevel `
   But I'm worried about whether the cost to users is too high. After all, many flink users may not understand rocksdb or even lsm.
   Do you have any suggestions ? 



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "mayuehappy (via GitHub)" <gi...@apache.org>.
mayuehappy commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1455817124


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -149,24 +144,42 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
-    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =
-            key("state.backend.rocksdb.compression.type")
+    public static final ConfigOption<List<CompressionType>> COMPRESSION_PER_LEVEL =
+            key("state.backend.rocksdb.compression.per.level")
                     .enumType(CompressionType.class)
-                    .defaultValue(SNAPPY_COMPRESSION)
+                    .asList()
+                    .defaultValues(SNAPPY_COMPRESSION)
                     .withDescription(
-                            String.format(
-                                    "The specified compression type for DB. Candidate compression type is %s, %s, %s, %s, %s, "
-                                            + "%s, %s, %s or %s, and RocksDB choose '%s' as default style.",
-                                    NO_COMPRESSION.name(),
-                                    SNAPPY_COMPRESSION.name(),
-                                    ZLIB_COMPRESSION.name(),
-                                    BZLIB2_COMPRESSION.name(),
-                                    LZ4_COMPRESSION.name(),
-                                    LZ4HC_COMPRESSION.name(),
-                                    XPRESS_COMPRESSION.name(),
-                                    ZSTD_COMPRESSION.name(),
-                                    DISABLE_COMPRESSION_OPTION.name(),
-                                    SNAPPY_COMPRESSION.name()));
+                            Description.builder()
+                                    .text(
+                                            "A semicolon-separated list of Compression Type. Different levels can have different "
+                                                    + "compression policies. In many cases, lower levels use fast compression algorithms,"
+                                                    + " while higher levels with more data use slower but more effective compression algorithms. "
+                                                    + "If the COMPRESSION_PER_LEVEL list is not empty, it should have an entry for each level of the database, "
+                                                    + "When level_compaction_dynamic_level_bytes=true, compression_per_level[0] still determines L0, but other "

Review Comment:
   It's another RocksDB DBOption ๏ผŒflink user can also config it though the ConfigOption
   ```
   public static final ConfigOption<Boolean> USE_DYNAMIC_LEVEL_SIZE =
               key("state.backend.rocksdb.compaction.level.use-dynamic-size")
                       .booleanType()
                       .defaultValue(false)
   ```



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx closed pull request #24072: [FLINK-33819] support set CompressionType for RocksDBStateBackend
URL: https://github.com/apache/flink/pull/24072


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on PR #24072:
URL: https://github.com/apache/flink/pull/24072#issuecomment-1909398142

   merged 4f7725aa into master


-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1452350812


##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =
+            key("state.backend.rocksdb.compression.type")
+                    .enumType(CompressionType.class)
+                    .defaultValue(SNAPPY_COMPRESSION)
+                    .withDescription(
+                            String.format(
+                                    "The specified compression type for DB. Candidate compression type is %s, %s, %s, %s, %s, "
+                                            + "%s, %s, %s or %s, and RocksDB choose '%s' as default style.",
+                                    NO_COMPRESSION.name(),
+                                    SNAPPY_COMPRESSION.name(),
+                                    ZLIB_COMPRESSION.name(),

Review Comment:
   +1 to that suggestion



##########
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBConfigurableOptions.java:
##########
@@ -139,6 +149,25 @@ public class RocksDBConfigurableOptions implements Serializable {
                                     NONE.name(),
                                     LEVEL.name()));
 
+    public static final ConfigOption<CompressionType> COMPRESSION_TYPE =

Review Comment:
   ๐Ÿค” Maybe rename the parameter name to `rocksdb.compression.types` and then implement it a as a comma separated list. Where item N on the list corresponds to sst level N-1. Last item on the list maps to "all levels below". And then keep `SNAPPY_COMPRESSION` as the default.
   
   This way, user could configure simply:
   
   -  `lz4` - everything will be lz4
   - `NO_COMPRESSION.name()` - there will be no compression at all
   - `NO_COMPRESSION.name(), NO_COMPRESSION.name(), lz4` - L0, L1 using no compression. Everything below `lz4`. 
   
   Also I wouldn't worry about this being too complicated for users. No sane Flink user will ever look into this, only the power nerds who shouldn't be scared the complexity here :)



-- 
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: issues-unsubscribe@flink.apache.org

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


Re: [PR] [FLINK-33819] support set CompressionType for RocksDBStateBackend [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #24072:
URL: https://github.com/apache/flink/pull/24072#discussion_r1458185586


##########
docs/layouts/shortcodes/generated/rocksdb_configurable_configuration.html:
##########
@@ -62,6 +62,12 @@
             <td><p>Enum</p></td>
             <td>The specified compaction style for DB. Candidate compaction style is LEVEL, FIFO, UNIVERSAL or NONE, and Flink chooses 'LEVEL' as default style.<br /><br />Possible values:<ul><li>"LEVEL"</li><li>"UNIVERSAL"</li><li>"FIFO"</li><li>"NONE"</li></ul></td>
         </tr>
+        <tr>

Review Comment:
   The CI failed seems because the doc is not consistent with [RocksDBConfigurableOptions.java](https://github.com/apache/flink/pull/24072/files#diff-162968bbd8c0d2dbfd91b191a97fa012ab1b3c27a329a2581746a66ad8ac76a3), Could you check it ?
   You could regenerate the doc follwing the method in README in flink-docs.



-- 
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: issues-unsubscribe@flink.apache.org

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