-
Notifications
You must be signed in to change notification settings - Fork 322
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
chore(warehouse): use fastUUID with google UUID generation #2598
Conversation
Codecov ReportBase: 45.44% // Head: 45.47% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2598 +/- ##
==========================================
+ Coverage 45.44% 45.47% +0.02%
==========================================
Files 289 289
Lines 47997 47999 +2
==========================================
+ Hits 21814 21826 +12
+ Misses 24796 24788 -8
+ Partials 1387 1385 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Thanks for addressing my comments
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.
Overall the changes looks good. 👍🏼 LGTM
I have just one comment on the motivation behind creation of RandomHex() function.
prefix := StagingTablePrefix(provider) | ||
stagingTableName := fmt.Sprintf(`%s%s_%s`, prefix, tableName, randomNess) | ||
return misc.TruncateStr(stagingTableName, tableNameLimit) | ||
} | ||
|
||
// RandHex returns a random hex string of length 32 | ||
func RandHex() 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.
Is there any improvement in this function in terms of speed or uniqueness over the other function ? Just curious to understand the motivation behind it.
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.
Yes. Actually, UUID.string() is processing for 36 bytes. We are ignoring the -
present by replacing it using strings.ReplaceAll(uuid.Must(uuid.NewV4()).String(), "-", "")
. We can just probably call hex.Encode
which can just populate the 32 bytes.
const Size = 16
type UUID [Size]byte
func (u UUID) String() string {
buf := make([]byte, 36)
hex.Encode(buf[0:8], u[0:4])
buf[8] = '-'
hex.Encode(buf[9:13], u[4:6])
buf[13] = '-'
hex.Encode(buf[14:18], u[6:8])
buf[18] = '-'
hex.Encode(buf[19:23], u[8:10])
buf[23] = '-'
hex.Encode(buf[24:], u[10:])
return string(buf)
}
Description
Use google's uuid, as gofrs can cause performance issues
Also, we have introduced one more utility called RandHex which generated a random string of 32 characters from UUID.
(The benefit here is that at some places where after getting the UUID string of 36 characters we used to replace
-
. Since we are doing extra computation of preparing the UUID string and replacing the-
. The same functionality is being provided by RandHex.)Notion Ticket
https://www.notion.so/rudderstacks/Fasf-UUID-4683365544654681aa04f69f790e05ce
Security