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

derive: replace ahash with rustc-hash #137

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

Kijewski
Copy link
Collaborator

ahash shines when you hash very long inputs, in excess of 1000 bytes. We only hash file names, variable names, block names … which should for all reasonable applications less than 100 bytes in length.

rustc-hash does not claim to be DoS-resistent like ahash is, but we only operate on trusted data, so this feature is not needed.

See also: https://blog.goose.love/posts/rosetta-hashing/.

The performance is mostly unchanged or slightly improved:

hello_world             time:   [61.157 µs 61.336 µs 61.503 µs]
                        change: [-3.5829% -2.8333% -2.0098%] (p = 0.00 < 0.05)
                        Performance has improved.

item_info.html          time:   [69.987 µs 70.137 µs 70.277 µs]
                        change: [-2.5459% -2.1263% -1.7360%] (p = 0.00 < 0.05)
                        Performance has improved.

item_union.html         time:   [185.41 µs 185.80 µs 186.18 µs]
                        change: [-2.9272% -2.4197% -1.9278%] (p = 0.00 < 0.05)
                        Performance has improved.

page.html               time:   [747.83 µs 748.66 µs 749.58 µs]
                        change: [-0.3883% -0.1132% +0.1551%] (p = 0.43 > 0.05)
                        No change in performance detected.

print_item.html         time:   [158.28 µs 158.72 µs 159.28 µs]
                        change: [-1.9084% -1.4402% -0.9742%] (p = 0.00 < 0.05)
                        Change within noise threshold.

short_item_info.html    time:   [133.45 µs 133.66 µs 133.89 µs]
                        change: [-4.0600% -3.7956% -3.5459%] (p = 0.00 < 0.05)
                        Performance has improved.

sidebar.html            time:   [207.27 µs 207.74 µs 208.28 µs]
                        change: [-3.7883% -3.2903% -2.8108%] (p = 0.00 < 0.05)
                        Performance has improved.

source.html             time:   [122.85 µs 123.15 µs 123.53 µs]
                        change: [-1.0462% -0.5575% -0.0943%] (p = 0.03 < 0.05)
                        Change within noise threshold.

type_layout.html        time:   [158.98 µs 159.46 µs 160.00 µs]
                        change: [+0.5711% +0.9257% +1.2877%] (p = 0.00 < 0.05)
                        Change within noise threshold.

type_layout_size.html   time:   [75.699 µs 75.978 µs 76.250 µs]
                        change: [-2.6748% -1.9573% -1.0695%] (p = 0.00 < 0.05)
                        Performance has improved.

`ahash` shines when you hash very long inputs, in excess of 1000 bytes.
We only hash file names, variable names, block names … which should for
all reasonable applications less than 100 bytes in length.

`rustc-hash` does not claim to be DoS-resistent like `ahash` is, but we
only operate on trusted data, so this feature is not needed.

See also: <https://blog.goose.love/posts/rosetta-hashing/>.

The performance is mostly unchanged or slightly improved:

```text
hello_world             time:   [61.157 µs 61.336 µs 61.503 µs]
                        change: [-3.5829% -2.8333% -2.0098%] (p = 0.00 < 0.05)
                        Performance has improved.

item_info.html          time:   [69.987 µs 70.137 µs 70.277 µs]
                        change: [-2.5459% -2.1263% -1.7360%] (p = 0.00 < 0.05)
                        Performance has improved.

item_union.html         time:   [185.41 µs 185.80 µs 186.18 µs]
                        change: [-2.9272% -2.4197% -1.9278%] (p = 0.00 < 0.05)
                        Performance has improved.

page.html               time:   [747.83 µs 748.66 µs 749.58 µs]
                        change: [-0.3883% -0.1132% +0.1551%] (p = 0.43 > 0.05)
                        No change in performance detected.

print_item.html         time:   [158.28 µs 158.72 µs 159.28 µs]
                        change: [-1.9084% -1.4402% -0.9742%] (p = 0.00 < 0.05)
                        Change within noise threshold.

short_item_info.html    time:   [133.45 µs 133.66 µs 133.89 µs]
                        change: [-4.0600% -3.7956% -3.5459%] (p = 0.00 < 0.05)
                        Performance has improved.

sidebar.html            time:   [207.27 µs 207.74 µs 208.28 µs]
                        change: [-3.7883% -3.2903% -2.8108%] (p = 0.00 < 0.05)
                        Performance has improved.

source.html             time:   [122.85 µs 123.15 µs 123.53 µs]
                        change: [-1.0462% -0.5575% -0.0943%] (p = 0.03 < 0.05)
                        Change within noise threshold.

type_layout.html        time:   [158.98 µs 159.46 µs 160.00 µs]
                        change: [+0.5711% +0.9257% +1.2877%] (p = 0.00 < 0.05)
                        Change within noise threshold.

type_layout_size.html   time:   [75.699 µs 75.978 µs 76.250 µs]
                        change: [-2.6748% -1.9573% -1.0695%] (p = 0.00 < 0.05)
                        Performance has improved.
```
@GuillaumeGomez
Copy link
Contributor

In our case, it should be more than enough. Thanks!

@GuillaumeGomez GuillaumeGomez merged commit f1806f7 into rinja-rs:master Aug 16, 2024
21 checks passed
@Kijewski Kijewski deleted the pr-hash branch August 16, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants