-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Dataflow Streaming] Cache StateNamespace encoded keys using SoftReference #33689
base: master
Are you sure you want to change the base?
Conversation
R: @scwhittle |
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
} | ||
|
||
private String getStringKey() { | ||
String stringKey = stringKeyRef.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need some annotations to make this not show up as racy? we could have multiple threads calling this at the same time.
@@ -219,6 +238,27 @@ public boolean equals(@Nullable Object obj) { | |||
&& Objects.equals(this.windowStructuralValue(), that.windowStructuralValue()); | |||
} | |||
|
|||
private String getStringKey() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just move this impl into stringKey()?
private final Coder<W> windowCoder; | ||
private final W window; | ||
private final int triggerIndex; | ||
private SoftReference<String> stringKeyRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed, maybe we shouldn't use softrefs without some more investigation.
sb.append(getStringKey()); | ||
} | ||
|
||
private String getStringKey() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just inline in stringKey?
UserWorker receives encodedKeys from backend, decodes it for processing and encodes it again for committing. This change caches the encoded keys using java SoftReferences and avoids encoding the keys again.