-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BEAM-4374] Shortids for the Go SDK #11231
Conversation
Run Go Postcommit |
R: @lukecwik |
This code drifts slightly from #11184, which removes the OneOf in favour of always using the payload format. This version still uses the oneof, but only populates payload. |
// sync.Map might have lower contention for this read heavy load. | ||
var ( | ||
shortMu sync.Mutex | ||
labels2ShortIds map[metrics.Labels]string |
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.
This won't be enough as the key. There are things that have the same labels but different URNs, e.g start/process/finish msecs
I would suggest using the MonitoringInfo with the payload field "blanked" as the key of the map.
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.
Ah good to know. Thanks!
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.
Ah good point.
Can't use protos as Go Map keys, because of all the magic fields they have, but I can use other things.
I've put in aligned constants, types, and string arrays for the proto specified strings, so these lookups don't end up hashing the strings every time (and instead use a uint32, which is very fast for go maps to deal with.) There's still the hashing of the fields in metrics.Labels, but we can do the same hashing in the metrics code at a later time, to allow for faster lookups for those instead.
A rather large refactoring occurred. For one, I wasn't initializing the maps properly which correctly caused postcommit failures. Now I've moved that verification to tests, and made the cache easier to test. |
Run Go Postcommit |
Just as a note, I'll wait until #11184 is in, and resolve the merge conflicts on my end before we merge this one. |
|
||
// TODO: Pull these from the protos. | ||
var sUrns = []string{ | ||
"beam:metric:user:v1", |
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.
heads up that this has now been exploded so that each MonitoringInfoSpec has a unique urn meaning that you'll see:
beam:metric:user:sum_int64:v1, beam:metric:user:sum_double:v1, ...
"TestingSentinelType", // Must remain last. | ||
} | ||
|
||
const ( |
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.
Since the urns uniquely identify the type now, you don't need this anymore and a monitoring info is uniquely described by urn + labels.
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.
Ack. I've kept the extra marker type around for the moment, but I might collapse things into the function to simplify some thing.
}{ | ||
{ | ||
id: "1", | ||
urn: urnUser, |
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.
Can you add the case where the same urn but unique labels are used gets a different short id?
Run Go Postcommit |
Run Go Postcommit |
A quick unblocker for current proto changes. Adds Short ID handling for the Go SDK.
There are likely some performance improvements that can go in around the single lock, either moving them to a RW lock or a sync.Map, but this should be fine for Batch cases at present, until we measure differently.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
Post-Commit Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.