Skip to content
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

Avoid Dashmap in favor of a shared threadsafe tree implementation #11

Closed
Byron opened this issue Dec 6, 2021 · 1 comment
Closed

Avoid Dashmap in favor of a shared threadsafe tree implementation #11

Byron opened this issue Dec 6, 2021 · 1 comment

Comments

@Byron
Copy link
Owner

Byron commented Dec 6, 2021

Most operations we do are actually incrementing counters. This should be as fast as possible, which is Arc<AtomicUsize>.

Other operations can be slower as they happen much more rarely.

In order to achieve this, DashMap should be replaced with a shared mutable tree implementation for prodash::tree, which is Send + Clone (but doesn't have to be sync). If the new implementation happens to be sync, which it could be, we can consider making this a property of prodash, which previously was a bit inconvenient as it forced users sometimes to wrap tree items into a mutex themselves.

Doing this naturally affects a lot of code especially in the renderers and it would be wise to figure out which steps to take to make this more gradual.

Benchmark Results

When using an Arc<AtomicUsize> compared to the current dashmap based implementation.

                        time:   [34.193 ns 34.199 ns 34.206 ns]
                        thrpt:  [146.17 Melem/s 146.20 Melem/s 146.23 Melem/s]
                 change:
                        time:   [-90.711% -90.674% -90.626%] (p = 0.00 < 0.05)
                        thrpt:  [+966.81% +972.27% +976.50%]
                        Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
  2 (2.00%) low severe
  3 (3.00%) high mild
  8 (8.00%) high severe
@Byron
Copy link
Owner Author

Byron commented Dec 27, 2021

Released in v16.1

@Byron Byron closed this as completed Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

1 participant