You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/11/28 04:41:47 UTC

[GitHub] [flink] rovboyko opened a new pull request, #21406: [FLINK-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState

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

   …d TtlListState
   
   <!--
   *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
   Avoid unnecessary state updates for TtlMapState and TtlListState in case they are not changed. This affects only HashMapStateBackend, MemoryStateBackend and FsStateBackend.
   
   
   
   ## Brief change log
   
   - add if condition to return original List if no records were expired for TtlListState
   - add if condition to return original Map if no records were expired for TtlMapState
   
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   - add testStateNotChangedWithoutCleanup to TtlStateTestBase
   
   ## 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): yes
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## 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-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState [flink]

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

   I updated the PR and published the benchmark results.
   @azagrebin  , @Myasuka  , @Jiayi-Liao  , could you please help with code review again?


-- 
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-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState [flink]

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

   @Myasuka after implementation of [FLINK-30535](https://issues.apache.org/jira/browse/FLINK-30535) and [FLINK-33881](https://issues.apache.org/jira/browse/FLINK-33881) I changed the current commit to optimize only TtlMapState.
   
   After the optimization benchamrk results seem not so bad (+17% performance):
   
   Benchmark | backendType | expiredOption | stateVisibility | updateType | Non-optimized | Optimized | Units
   -- | -- | -- | -- | -- | -- | -- | --
   TtlMapStateBenchmark.mapAdd | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnCreateAndWrite | 361.671 | 521.839 | ops/ms
   TtlMapStateBenchmark.mapAdd | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnReadAndWrite | 366.513 | 523.892 | ops/ms
   TtlMapStateBenchmark.mapAdd | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 364.311 | 461.037 | ops/ms
   TtlMapStateBenchmark.mapAdd | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 362.902 | 510.513 | ops/ms
   TtlMapStateBenchmark.mapAdd | HEAP | NeverExpired | NeverReturnExpired | OnCreateAndWrite | 361.08 | 520.319 | ops/ms
   TtlMapStateBenchmark.mapAdd | HEAP | NeverExpired | NeverReturnExpired | OnReadAndWrite | 364.026 | 524.573 | ops/ms
   TtlMapStateBenchmark.mapAdd | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 362.199 | 515.707 | ops/ms
   TtlMapStateBenchmark.mapAdd | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 357.642 | 433.35 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnCreateAndWrite | 304.937 | 386.748 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnReadAndWrite | 260.486 | 321.793 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 324.409 | 397.574 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 265.357 | 353.769 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | NeverExpired | NeverReturnExpired | OnCreateAndWrite | 328.767 | 405.722 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | NeverExpired | NeverReturnExpired | OnReadAndWrite | 255.596 | 338.208 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 317.633 | 400.027 | ops/ms
   TtlMapStateBenchmark.mapGet | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 254.176 | 343.937 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnCreateAndWrite | 316.203 | 412.834 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnReadAndWrite | 327.426 | 414.538 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 323.163 | 406.269 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 334.041 | 420.389 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | NeverExpired | NeverReturnExpired | OnCreateAndWrite | 346.116 | 406.019 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | NeverExpired | NeverReturnExpired | OnReadAndWrite | 320.814 | 405.261 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 340.874 | 409.718 | ops/ms
   TtlMapStateBenchmark.mapIsEmpty | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 333.791 | 408.396 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnCreateAndWrite | 2760.188 | 3413.68 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnReadAndWrite | 2322.375 | 2419.871 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 2694.602 | 3372.643 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 2275.37 | 2156.808 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | NeverExpired | NeverReturnExpired | OnCreateAndWrite | 2723.703 | 3369.097 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | NeverExpired | NeverReturnExpired | OnReadAndWrite | 2324.465 | 2453.601 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 2694.324 | 3364.168 | ops/ms
   TtlMapStateBenchmark.mapIterator | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 2339.08 | 2377.672 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnCreateAndWrite | 270.326 | 275.442 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnReadAndWrite | 269.82 | 282.63 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 271.646 | 280.797 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 270.449 | 257.802 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | NeverExpired | NeverReturnExpired | OnCreateAndWrite | 271.497 | 274.694 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | NeverExpired | NeverReturnExpired | OnReadAndWrite | 270.721 | 252.761 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 292.303 | 268.975 | ops/ms
   TtlMapStateBenchmark.mapPutAll | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 271.283 | 277.794 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnCreateAndWrite | 278.52 | 345.521 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | Expire3PercentPerIteration | NeverReturnExpired | OnReadAndWrite | 272.15 | 328.734 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 274.306 | 358.366 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | Expire3PercentPerIteration | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 272.916 | 347.087 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | NeverExpired | NeverReturnExpired | OnCreateAndWrite | 264.072 | 346.595 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | NeverExpired | NeverReturnExpired | OnReadAndWrite | 273.377 | 341.417 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnCreateAndWrite | 275.702 | 352.406 | ops/ms
   TtlMapStateBenchmark.mapUpdate | HEAP | NeverExpired | ReturnExpiredIfNotCleanedUp | OnReadAndWrite | 275.58 | 357.394 | ops/ms
     |   |   |   | total: | 32362.908 | 38118.387 |  
   
   
   </body>
   
   </html>
   


-- 
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


[GitHub] [flink] rovboyko commented on pull request #21406: [FLINK-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState

Posted by GitBox <gi...@apache.org>.
rovboyko commented on PR #21406:
URL: https://github.com/apache/flink/pull/21406#issuecomment-1344101060

   @azagrebin , @Myasuka , @Jiayi-Liao , could you please help with code review?


-- 
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


[GitHub] [flink] Myasuka commented on pull request #21406: [FLINK-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState

Posted by GitBox <gi...@apache.org>.
Myasuka commented on PR #21406:
URL: https://github.com/apache/flink/pull/21406#issuecomment-1365640815

   @rovboyko If so, I think we can add such a TTL state benchmark under https://github.com/apache/flink-benchmarks/tree/master/src/main/java/org/apache/flink/state/benchmark to prove this improvement and also help Flink community to track the TTL state performance changes.


-- 
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


[GitHub] [flink] Myasuka commented on pull request #21406: [FLINK-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState

Posted by GitBox <gi...@apache.org>.
Myasuka commented on PR #21406:
URL: https://github.com/apache/flink/pull/21406#issuecomment-1367780705

   @rovboyko I created ticket FLINK-30535 to focus on the TTL state benchmarks.


-- 
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


[GitHub] [flink] rovboyko commented on pull request #21406: [FLINK-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState

Posted by GitBox <gi...@apache.org>.
rovboyko commented on PR #21406:
URL: https://github.com/apache/flink/pull/21406#issuecomment-1365623119

   Hi @Myasuka !
   Thanks for your reply.
   The main benefit of this change is avoiding of unnecessary stateIterator.update() invocation inside TtlIncrementalCleanup.runCleanup() method.
   As for now it happens even no keys inside ttlState were expired. And after my change the stateIterator.update() invocation would happen only if any key was expired inside ttlState.


-- 
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


[GitHub] [flink] flinkbot commented on pull request #21406: [FLINK-30088][runtime] Fix excessive state updates for TtlMapState and TtlListState

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21406:
URL: https://github.com/apache/flink/pull/21406#issuecomment-1328531809

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "cf8b7c1de5e3dfbe83106a4de89423e17e36e50e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "cf8b7c1de5e3dfbe83106a4de89423e17e36e50e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * cf8b7c1de5e3dfbe83106a4de89423e17e36e50e 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