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

Support specializing get_hash without nightly #242

Open
wants to merge 4 commits into
base: 0.9-prerelease
Choose a base branch
from

Conversation

dtolnay
Copy link

@dtolnay dtolnay commented Aug 17, 2024

Submitting as an alternative to #239. Benchmarks:

Before:

RUSTFLAGS='-Ctarget-cpu=native' cargo bench --bench ahash
    aeshash/u8              time:   [994.20 ps 995.35 ps 996.54 ps]                        
    aeshash/u16             time:   [994.81 ps 995.50 ps 996.21 ps]                         
    aeshash/u32             time:   [1.0140 ns 1.0169 ns 1.0204 ns]                         
    aeshash/u64             time:   [988.77 ps 989.85 ps 991.07 ps]                         
    aeshash/u128            time:   [501.29 ps 502.12 ps 503.08 ps]                          
    aeshash/strings         time:   [57.541 ns 57.576 ns 57.615 ns]                            

cargo bench --bench ahash
    fallbackhash/u8         time:   [976.34 ps 977.16 ps 978.05 ps]                             
    fallbackhash/u16        time:   [982.23 ps 983.48 ps 984.79 ps]                              
    fallbackhash/u32        time:   [983.96 ps 986.30 ps 989.23 ps]                              
    fallbackhash/u64        time:   [976.09 ps 980.99 ps 987.61 ps]                              
    fallbackhash/u128       time:   [1.2632 ns 1.2644 ns 1.2657 ns]                               
    fallbackhash/strings    time:   [129.09 ns 129.21 ns 129.33 ns]                                 

RUSTFLAGS='-Zallow-features= -Ctarget-cpu=native' cargo bench --bench ahash
    aeshash/u8              time:   [551.31 ps 551.92 ps 552.62 ps]                        
    aeshash/u16             time:   [587.73 ps 588.50 ps 589.33 ps]                         
    aeshash/u32             time:   [548.83 ps 550.01 ps 551.29 ps]                         
    aeshash/u64             time:   [549.42 ps 550.84 ps 552.65 ps]                         
    aeshash/u128            time:   [557.69 ps 558.17 ps 558.70 ps]                          
    aeshash/strings         time:   [57.197 ns 57.271 ns 57.355 ns]                            

RUSTFLAGS='-Zallow-features=' cargo bench --bench ahash
    fallbackhash/u8         time:   [1.1932 ns 1.1941 ns 1.1951 ns]                             
    fallbackhash/u16        time:   [1.2140 ns 1.2161 ns 1.2190 ns]                              
    fallbackhash/u32        time:   [1.2145 ns 1.2160 ns 1.2176 ns]                              
    fallbackhash/u64        time:   [1.2148 ns 1.2194 ns 1.2247 ns]                              
    fallbackhash/u128       time:   [1.4800 ns 1.4820 ns 1.4842 ns]                               
    fallbackhash/strings    time:   [129.03 ns 129.26 ns 129.55 ns]                                 

After:

RUSTFLAGS='-Zallow-features= -Ctarget-cpu=native' cargo bench --bench ahash
    aeshash/u8              time:   [990.82 ps 991.44 ps 992.03 ps]                        
    aeshash/u16             time:   [986.98 ps 988.56 ps 990.37 ps]                         
    aeshash/u32             time:   [995.33 ps 996.65 ps 998.35 ps]                         
    aeshash/u64             time:   [987.58 ps 988.99 ps 990.64 ps]                         
    aeshash/u128            time:   [506.18 ps 507.51 ps 509.45 ps]                          
    aeshash/strings         time:   [57.803 ns 57.859 ns 57.923 ns]                            

RUSTFLAGS='-Zallow-features=' cargo bench --bench ahash
    fallbackhash/u8         time:   [973.12 ps 973.98 ps 974.93 ps]                             
    fallbackhash/u16        time:   [976.37 ps 977.22 ps 978.17 ps]                              
    fallbackhash/u32        time:   [984.10 ps 984.82 ps 985.56 ps]                              
    fallbackhash/u64        time:   [977.77 ps 978.66 ps 979.64 ps]                              
    fallbackhash/u128       time:   [1.2595 ns 1.2606 ns 1.2618 ns]                               
    fallbackhash/strings    time:   [129.86 ns 130.00 ns 130.18 ns]                                 

It's clear that we are now getting exactly the specialized behavior of both aeshash and fallbackhash, even without the use of unstable min_specialization.

@tkaitchuck tkaitchuck changed the base branch from master to 0.9-prerelease August 22, 2024 19:32
@tkaitchuck
Copy link
Owner

Retargeting this to the 0.9 pre-release branch.

@kornelski
Copy link

@tkaitchuck If only 0.9 is fixed, then the abandoned unfixed 0.8 version will cause the same kind of pain that the abandoned unfixed 0.7 version has caused when only 0.8 had a fix.

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.

4 participants