Unleash / unleash-client-rust

Unleash client SDK for Rust language projects
Apache License 2.0
23 stars 17 forks source link

Remove inner Arc on memoised strategies #3

Closed rbtcollins closed 4 years ago

rbtcollins commented 4 years ago

This was an attempt to fix the poor scaling of same-feature lookups but has not worked. It is however a useful improvement to have.

single_call/single_call time:   [265.38 ns 266.55 ns 267.73 ns]
                        thrpt:  [3.7350 Melem/s 3.7516 Melem/s 3.7682 Melem/s]
50000 elements per thread below:
batch/single thread     time:   [13.502 ms 13.542 ms 13.583 ms]
                        thrpt:  [3.6812 Melem/s 3.6921 Melem/s 3.7030 Melem/s]
32 threads below:
batch/parallel same-feature
                        time:   [105.75 ms 107.96 ms 109.94 ms]
                        thrpt:  [14.554 Melem/s 14.821 Melem/s 15.129 Melem/s]
batch/parallel distinct-features
                        time:   [35.620 ms 36.025 ms 36.418 ms]
                        thrpt:  [43.934 Melem/s 44.414 Melem/s 44.919 Melem/s]
batch/parallel unknown-features
                        time:   [11.877 ms 12.104 ms 12.261 ms]
                        thrpt:  [130.50 Melem/s 132.19 Melem/s 134.71 Melem/s]

I may need to crack out CPU profiling tools next to determine what is up. It isn't exactly slow : 500k lookups per thread per second still allows lots of headroom for developers to use toggles with confidence, but it would be nice to figure out the issue and fix it.

Close #2

rbtcollins commented 4 years ago

Thanks @amorken yeah, I do wonder if a larger rearrangement would be beneficial; I avoided having an explicit trait until now to make writing strategies ultra low overhead - and it is kindof magical that the simple closures still works :). Until I see a strategy that actually needs a larger footprint I'm satisfied with this though.