beacon-biosignals / StableHashTraits.jl

Compute hashes over any Julia object simply and reproducibly
MIT License
7 stars 1 forks source link

fix Base.Fix1/2 error #34

Closed haberdashPI closed 11 months ago

haberdashPI commented 11 months ago

Description

HashVersion{V} for V > 1 used to crash for types of Base.Fix1 and Base.Fix2. This adds hash_method methods to address that.

This involved generating a new reference tests for HashVersion{1} with reference files for before implementing my fix, to ensure that the new changes don't alter the hash value for that context.

This change did not noticeably affect the benchmarks.

Before

12×5 DataFrame
 Row │ benchmark   hash       base        trait       ratio     
     │ SubStrin…   SubStrin…  String      String      Float64   
─────┼──────────────────────────────────────────────────────────
   1 │ structs     crc        71.542 μs   1.116 ms    15.6027
   2 │ tuples      crc        71.459 μs   918.917 μs  12.8594
   3 │ dataframes  crc        71.458 μs   257.166 μs   3.59884
   4 │ numbers     crc        35.916 μs   126.666 μs   3.52673
   5 │ symbols     crc        635.875 μs  629.000 μs   0.989188
   6 │ strings     crc        655.500 μs  561.292 μs   0.856281
   7 │ structs     sha256     543.166 μs  3.045 ms     5.60525
   8 │ tuples      sha256     543.125 μs  2.594 ms     4.77668
   9 │ symbols     sha256     1.494 ms    2.264 ms     1.51544
  10 │ strings     sha256     1.484 ms    2.196 ms     1.47992
  11 │ dataframes  sha256     543.125 μs  749.125 μs   1.37929
  12 │ numbers     sha256     270.958 μs  371.833 μs   1.37229

After

 Row │ benchmark   hash       base        trait       ratio     
     │ SubStrin…   SubStrin…  String      String      Float64   
─────┼──────────────────────────────────────────────────────────
   1 │ structs     crc        75.458 μs   1.265 ms    16.7665
   2 │ tuples      crc        75.458 μs   1.019 ms    13.4998
   3 │ dataframes  crc        75.542 μs   276.458 μs   3.65966
   4 │ numbers     crc        38.125 μs   136.667 μs   3.58471
   5 │ symbols     crc        725.500 μs  703.167 μs   0.969217
   6 │ strings     crc        743.833 μs  635.875 μs   0.854863
   7 │ structs     sha256     571.041 μs  3.209 ms     5.61985
   8 │ tuples      sha256     570.708 μs  2.742 ms     4.80412
   9 │ symbols     sha256     1.615 ms    2.403 ms     1.48763
  10 │ strings     sha256     1.609 ms    2.337 ms     1.45261
  11 │ dataframes  sha256     571.375 μs  794.458 μs   1.39043
  12 │ numbers     sha256     285.084 μs  394.958 μs   1.38541
codecov[bot] commented 11 months ago

Codecov Report

Merging #34 (18fe90e) into main (16b2af8) will increase coverage by 0.09%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
+ Coverage   95.86%   95.95%   +0.09%     
==========================================
  Files           1        1              
  Lines         266      272       +6     
==========================================
+ Hits          255      261       +6     
  Misses         11       11              
Files Coverage Δ
src/StableHashTraits.jl 95.95% <100.00%> (+0.09%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more