[FLINK-39026][runtime] Remove misleading TODO about getPartitionedState overhead#27517
Open
nateab wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-39026][runtime] Remove misleading TODO about getPartitionedState overhead#27517nateab wants to merge 1 commit intoapache:masterfrom
nateab wants to merge 1 commit intoapache:masterfrom
Conversation
8ddb873 to
e9f1e09
Compare
Collaborator
e9f1e09 to
0a2e053
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…te overhead
What is the purpose of the change
Remove TODO comments in
AbstractKeyedStateBackendandStreamOperatorStateHandlerthat incorrectly suggestedgetPartitionedState()has significant overhead when updating namespaces.The TODO (added in 2020) claimed:
Benchmarking revealed this is incorrect. The current implementation already has an efficient fast-path cache, and calling
setCurrentNamespace()directly is actually no faster (and sometimes slower) thanthe current approach, most likely due to just test noise.
Benchmark Results
Heap Backend (5 trials × 2M iterations each)
getPartitionedState: min=130.4 ns, median=135.1 ns
setCurrentNamespace: min=134.0 ns, median=142.5 ns
"Optimized" direct approach is 5% SLOWER
RocksDB Backend (5 trials × 2M iterations each)
getPartitionedState: min=9006.0 ns, median=9861.0 ns
setCurrentNamespace: min=9414.2 ns, median=10101.1 ns
"Optimized" direct approach is 2.4% SLOWER
Why the Current Code is Already Optimal
The fast-path in
getPartitionedState()(lines 434-437) already does minimal work:When hitting the cache (common case), it just does String.equals() + setCurrentNamespace() - which is essentially the same as the "optimized" direct approach.
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
Documentation