You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We did CPU profiling by integrating GB java client SDK into our backend service and are making 100 calls to GB.evalFeature() per request (assuming in prod we'll run 100 experiments in parallel per request), we observed GB taking too much CPU, we narrowed it down to MathUtils.fnv1a_32 where it's spending 75% of overall CPU inside GB. As you can see in the attached screenshot, most of the time is being spent inside the hash function.
Our overall application CPU increased drastically because of this
Is there any faster hashing strategy that we can use here?
I suspect usage of BigInteger in fnv1a_32 is too expensive. Will moving to integer (instead of BigInteger) solve for this issue?
privatestaticfinalintFNV_32_PRIME = 0x01000193;
privatestaticfinalintFNV_32_INIT = 0x811c9dc5;
publicstaticintfnv1a_32_int(byte[] data) {
inthash = FNV_32_PRIME;
for (byteb : data) {
// XOR the bottom with the current octet.hash ^= (b & 0xff);
// Multiply by the 32 bit FNV magic prime mod 2^32hash *= FNV_32_INIT;
}
returnhash;
}
The text was updated successfully, but these errors were encountered:
We did the profiling again by removing the dependency on BigInteger and use integer instead (PR: https://github.com/growthbook/growthbook-sdk-java/pull/45/files)
We observed that the performance issue is fixed, the CPU usage in our environment for GrowthBookUtils.hashV2() dropped from 11.25% to 0.13%
but the test cases start to fail (because a specific set of hashing outcomes are defined in the test case)
We did CPU profiling by integrating GB java client SDK into our backend service and are making 100 calls to
![Screenshot 2024-03-26 at 5 13 22 PM](https://private-user-images.githubusercontent.com/11795117/317093711-2246bc8f-37ec-4293-acda-85e8e48a95c0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwNDUwMzQsIm5iZiI6MTcyMDA0NDczNCwicGF0aCI6Ii8xMTc5NTExNy8zMTcwOTM3MTEtMjI0NmJjOGYtMzdlYy00MjkzLWFjZGEtODVlOGU0OGE5NWMwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzAzVDIyMTIxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM3Y2FlY2ZlMDExZDBjZDBiMDZjOTAwZjFhNTJmMDFhNDdlMDdmMjdlNjUyNjg1M2I3NTcyZGQyYjBlODY4OTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.H7LGK7IDu-4sd86JX1c85eetvAEdEdCmZTeln0Do2fA)
GB.evalFeature()
per request (assuming in prod we'll run 100 experiments in parallel per request), we observed GB taking too much CPU, we narrowed it down toMathUtils.fnv1a_32
where it's spending 75% of overall CPU inside GB. As you can see in the attached screenshot, most of the time is being spent inside the hash function.Our overall application CPU increased drastically because of this
Is there any faster hashing strategy that we can use here?
I suspect usage of BigInteger in fnv1a_32 is too expensive. Will moving to integer (instead of BigInteger) solve for this issue?
The text was updated successfully, but these errors were encountered: