bench: add internal benchmark for `secp256k1_fe_normalize_var` #1855

pull theStack wants to merge 1 commits into bitcoin-core:master from theStack:add-field_normalize_var-bench changing 1 files +12 −0
  1. theStack commented at 10:49 PM on May 14, 2026: contributor

    While addressing the review suggestion #1765 (review) (b10c mirror link), I noticed that we don't have an internal benchmark for the variable-time variant of _fe_normalize yet, so this PR adds one. IIUC it's fine to repeatedly apply the operation on the same (already normalized at latest after the first loop iteration) field element for benchmarking purposes and don't put in an effort to reach the final reduction code path, considering how extremely unlikely it is to reach it in practice.

    Results on my machine:

    $ ./build/bin/bench_internal normalize
    Benchmark                     ,    Min(us)    ,    Avg(us)    ,    Max(us)    
    
    field_normalize               ,     0.0103    ,     0.0106    ,     0.0128 
    field_normalize_var           ,     0.00545   ,     0.00546   ,     0.00547
    field_normalize_weak          ,     0.00352   ,     0.00354   ,     0.00363
    
  2. furszy commented at 4:49 PM on May 30, 2026: member

    ACK 8b066a4dd772e6a4d3d3cc1a48b0683214654c23

  3. sipa commented at 1:47 PM on June 2, 2026: contributor

    ACK 8b066a4dd772e6a4d3d3cc1a48b0683214654c23

    Worth noting that this benchmarks the optimistic path? It makes sense to do so, because the worst-case path is very unlikely to be needed.

  4. bench: add internal benchmark for `secp256k1_fe_normalize_var` 240578eef5
  5. theStack force-pushed on Jun 4, 2026
  6. theStack commented at 5:19 PM on June 4, 2026: contributor

    Worth noting that this benchmarks the optimistic path? It makes sense to do so, because the worst-case path is very unlikely to be needed.

    Makes sense, thanks. Added a corresponding comment.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-06-06 14:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me