-
Notifications
You must be signed in to change notification settings - Fork 596
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
Use lazy encoding in utf-8 encoded string comparison #6706
base: main
Are you sure you want to change the base?
Conversation
Release note changesThe following release notes were modified. Please ensure they look correct. Release Notesfirebase-firestore### {{firestore}} version 25.1.3 {: #firestore_v25-1-3}
* {{fixed}} Use lazy encoding in UTF-8 encoded byte comparison for strings to solve performance issues. GitHub [#6706](//github.com/firebase/firebase-android-sdk/issues/6706){: .external}
#### {{firestore}} Kotlin extensions version 25.1.3 {: #firestore-ktx_v25-1-3}
The Kotlin extensions library transitively includes the updated
`firebase-firestore` library. The Kotlin extensions library has no additional
updates.
|
Coverage Report 1Affected Products
Test Logs |
Test Results 186 files + 166 186 suites +166 4m 44s ⏱️ + 4m 32s Results for commit 8159f25. ± Comparison against base commit 95bbf92. This pull request removes 116 and adds 1235 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
Size Report 1Affected Products
Test Logs |
return Integer.compare(leftCodePoint, rightCodePoint); | ||
} else { | ||
// substring and do UTF-8 encoded byte comparison | ||
byte[] leftBytes = getUtf8SafeBytes(left, i); |
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.
would it be wrong to always take (index, index+2)
, and compare those?
meaning, getting rid of getUtf8SafeBytes()
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.
Based on the unit test results, yes, somehow it is problematic for java, while js managed to handle it nicely. But, increasing i one by one + getUtf8SafeBytes()
solved the problem.
The previous fix created a performance issue due to expensive UTF-8 encoding. Update
compareUtf8Strings
to use lazy encoding instead.