-
Notifications
You must be signed in to change notification settings - Fork 71
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
Performance of useFlags hook severely degraded by Proxy implementation #177
Comments
Thanks for reporting this. Are you able to share the number of flags involved when you start noticing the performance degradation please? If possible also please provide some metrics of the performance degradation in terms of rendering time for example comparing the performance before and after this issue. |
@yusinto We had about 520+ flags at time of the issue. |
Hey @coreylight, I think that this implementation would improve performance and ensure that flag events work as expected: const useMyFlag = (name, fallback) => {
const ldClient = useLDClient();
if (overrides.hasOwnProperty(name)) {
return overrides[name]
}
return ldClient.variation(name, fallback)
} This will avoid any deoptimization caused by the use of Although I highly recommend using const useMyFlag = (name) => {
const ldClient = useLDClient();
// directly access the flag set without the proxy
const allFlags = ldClient.allFlags()
//..... etc
} |
@tarqd Thanks for the suggestions. However, you're asking me to change my access patterns, which I've already done since we've experienced the pain of this change. |
We just got bit by this problem as well, gaining back 4 seconds of initial load time by using |
ok so I get that from multiple long pending critical issues like this, this library is not something to be used ? |
With the introduction of this change in 2.27.0
Our application was unknowingly heavily impacted at runtime.
We have hundreds of flags and have expected a "plain object" implementation found in previous versions that caused no issues.
Example code that was ok before:
While this code may not apply to everyone, it's very simple JS code that no developer would expect to cause performance implications.
By introducing a Proxy that does work based on key access, performance plummeted for us.
I'm raising an issue mostly to warn other developers to make certain they know of this change. To that effect, a major version bump should (and still can) be considered to this library.
OR the flag evaluation proxy should be opt-in.
The text was updated successfully, but these errors were encountered: