launchdarkly / rust-server-sdk

LaunchDarkly Server-Side SDK for Rust
https://docs.launchdarkly.com/sdk/server-side/rust
Other
18 stars 13 forks source link

Adopt lockless design #2

Closed mraerino closed 2 years ago

mraerino commented 3 years ago

Is your feature request related to a problem? Please describe.

The codebase is using a lot of locking right now. This can have unexpected consequences for people using the library.

Describe the solution you'd like

Adopt lockless programming using Arc and different kinds of channels instead.

There are several synchronization cases here:

Describe alternatives you've considered

We could consider having different Store implementation based on whether users rather want to use locks or atomic swaps.

Additional context

I implemented a lock-free store in my alternative SDK here: https://github.com/mraerino/launchdarkly-rust-sdk-experimental/blob/main/src/store.rs On a large number of flags it will make a large number of allocations, since it deep-clones the map of flags on every update - that's a tradeoff of the lockless approach. I think using an RwLock around the map would be totally fine too though.

keelerm84 commented 2 years ago

Thank for you for these suggestions and ideas, as well as linking to your own SDK implementation. We have reduced the amount of locking required in our most recent beta release.