github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/bloom/block_amd64.go (about)

     1  //go:build !purego
     2  
     3  package bloom
     4  
     5  import "golang.org/x/sys/cpu"
     6  
     7  // The functions in this file are SIMD-optimized versions of the functions
     8  // declared in block_optimized.go for x86 targets.
     9  //
    10  // The optimization yields measurable improvements over the pure Go versions:
    11  //
    12  // goos: darwin
    13  // goarch: amd64
    14  // pkg: github.com/vc42/parquet-go/bloom
    15  // cpu: Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    16  //
    17  // name         old time/op    new time/op     delta
    18  // BlockInsert    11.6ns ± 4%      2.0ns ± 3%   -82.37%  (p=0.000 n=8+8)
    19  // BlockCheck     12.6ns ±28%      2.1ns ± 4%   -83.12%  (p=0.000 n=10+8)
    20  //
    21  // name         old speed      new speed       delta
    22  // BlockInsert  2.73GB/s ±13%  15.70GB/s ± 3%  +475.96%  (p=0.000 n=9+8)
    23  // BlockCheck   2.59GB/s ±23%  15.06GB/s ± 4%  +482.25%  (p=0.000 n=10+8)
    24  //
    25  // Note that the numbers above are a comparison to the routines implemented in
    26  // block_optimized.go; the delta comparing to functions in block_default.go is
    27  // significantly larger but not very interesting since those functions have no
    28  // practical use cases.
    29  var hasAVX2 = cpu.X86.HasAVX2
    30  
    31  //go:noescape
    32  func blockInsert(b *Block, x uint32)
    33  
    34  //go:noescape
    35  func blockCheck(b *Block, x uint32) bool
    36  
    37  func (b *Block) Insert(x uint32) { blockInsert(b, x) }
    38  
    39  func (b *Block) Check(x uint32) bool { return blockCheck(b, x) }