Skip to content

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

@Byron

Description

@Byron

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions