Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arunpandianp
Copy link
Contributor

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.

@arunpandianp
Copy link
Contributor Author

R: @scwhittle

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

}

private String getStringKey() {
String stringKey = stringKeyRef.get();
Copy link
Contributor

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() {
Copy link
Contributor

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;
Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just inline in stringKey?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants