Skip to content

Commit

Permalink
mention that Hash and Eq are O(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
drash-course authored Jul 5, 2024
1 parent 434b2a5 commit 9b65ad5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ This crate exposes `IString`, an

It's built for high performance and with multithreading in mind.

Reading an `IString`'s contents is very fast, lock free and wait free (thanks to `left_right`).
The `IString` can be shared and read from any number of threads.
It scales linearly with the number of reading threads.

The tradeoff is that creating a new `IString` is slower.
A radix tree (compact trie) needs to be traversed to deduplicate the new string,
a lock needs to be acquired, and the tree needs to be updated if the string wasn't interned yet.
While the tree walk can be done in parallel from multiple threads, the lock prevents linear
scaling for writes.

It provides O(1) `Hash` and `Eq` operations, perfect for your `HashMap<IString, _>`.

## Getting Started

Expand Down Expand Up @@ -65,6 +56,18 @@ fn main() {

```

## Performance Characteristics

Reading an `IString`'s contents is very fast, lock free and wait free (thanks to `left_right`).
The `IString` can be shared and read from any number of threads.
It scales linearly with the number of reading threads.

The tradeoff is that creating a new `IString` is slower.
A radix tree (compact trie) needs to be traversed to deduplicate the new string,
a lock needs to be acquired, and the tree needs to be updated if the string wasn't interned yet.
While the tree walk can be done in parallel from multiple threads, the lock prevents linear
scaling for writes.

## Planned Improvements

- Make `IString::from` (in the already interned case), `IString::clone`, and `IString::drop`
Expand Down

0 comments on commit 9b65ad5

Please sign in to comment.