• erifan01's avatar
    internal/bytealg: optimize IndexString on arm64 · d4e936cf
    erifan01 authored
    This CL adjusts the order of the branch instructions of the
    code to make it easier for the LIKELY branch to happen.
    
    Benchmarks:
    name                            old time/op    new time/op    delta
    pkg:strings goos:linux goarch:arm64
    IndexHard2-8                      2.17ms ± 1%    1.23ms ± 0%  -43.34%  (p=0.008 n=5+5)
    CountHard2-8                      2.13ms ± 1%    1.21ms ± 2%  -43.31%  (p=0.008 n=5+5)
    
    pkg:bytes goos:linux goarch:arm64
    IndexRune/4M-8                     661µs ±22%     513µs ± 0%  -22.32%  (p=0.008 n=5+5)
    IndexEasy/4M-8                     672µs ±23%     513µs ± 0%  -23.71%  (p=0.016 n=5+4)
    
    Change-Id: Ib96f095edf77747edc8a971e79f5c1428e5808ce
    Reviewed-on: https://go-review.googlesource.com/109015Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
    Run-TryBot: Cherry Zhang <cherryyz@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    d4e936cf
Name
Last commit
Last update
..
bytealg Loading commit data...
cpu Loading commit data...
nettrace Loading commit data...
poll Loading commit data...
race Loading commit data...
singleflight Loading commit data...
syscall Loading commit data...
testenv Loading commit data...
testlog Loading commit data...
trace Loading commit data...