• Alberto Donizetti's avatar
    cmd/compile: preallocate in, out arrays in methodfunc · 72f099c3
    Alberto Donizetti authored
    This gives a modest (but measurable) reduction in the number of
    allocations when building the compilebench packages. It's safe and
    exact (there's no heuristic or guessing, the lenghts of in and out are
    known when we enter the function), so it may be worth it.
    
    name       old time/op       new time/op       delta
    Template         236ms ±23%        227ms ± 8%    ~     (p=0.955 n=8+7)
    Unicode          112ms ± 7%        111ms ± 8%    ~     (p=0.798 n=8+8)
    GoTypes          859ms ± 6%        874ms ± 6%    ~     (p=0.442 n=8+8)
    Compiler         3.90s ±12%        3.85s ± 9%    ~     (p=0.878 n=8+8)
    SSA              12.1s ± 7%        11.9s ± 8%    ~     (p=0.798 n=8+8)
    Flate            151ms ±13%        157ms ±14%    ~     (p=0.382 n=8+8)
    GoParser         190ms ±14%        192ms ±10%    ~     (p=0.645 n=8+8)
    Reflect          554ms ± 5%        555ms ± 9%    ~     (p=0.878 n=8+8)
    Tar              220ms ±19%        212ms ± 6%    ~     (p=0.867 n=8+7)
    XML              296ms ±16%        303ms ±13%    ~     (p=0.574 n=8+8)
    
    name       old alloc/op      new alloc/op      delta
    Template        35.4MB ± 0%       35.4MB ± 0%  -0.03%  (p=0.021 n=8+8)
    Unicode         29.2MB ± 0%       29.2MB ± 0%    ~     (p=0.645 n=8+8)
    GoTypes          123MB ± 0%        123MB ± 0%  -0.02%  (p=0.001 n=7+8)
    Compiler         514MB ± 0%        514MB ± 0%    ~     (p=0.336 n=8+7)
    SSA             1.94GB ± 0%       1.94GB ± 0%  -0.00%  (p=0.004 n=8+7)
    Flate           24.5MB ± 0%       24.5MB ± 0%  -0.03%  (p=0.015 n=8+8)
    GoParser        28.7MB ± 0%       28.7MB ± 0%    ~     (p=0.279 n=8+8)
    Reflect         87.4MB ± 0%       87.4MB ± 0%  -0.02%  (p=0.000 n=8+8)
    Tar             35.2MB ± 0%       35.2MB ± 0%  -0.02%  (p=0.007 n=8+8)
    XML             47.4MB ± 0%       47.4MB ± 0%    ~     (p=0.083 n=8+8)
    
    name       old allocs/op     new allocs/op     delta
    Template          348k ± 0%         348k ± 0%  -0.15%  (p=0.000 n=8+8)
    Unicode           339k ± 0%         339k ± 0%    ~     (p=0.195 n=8+8)
    GoTypes          1.28M ± 0%        1.27M ± 0%  -0.20%  (p=0.000 n=8+8)
    Compiler         4.88M ± 0%        4.88M ± 0%  -0.15%  (p=0.000 n=8+8)
    SSA              15.2M ± 0%        15.2M ± 0%  -0.02%  (p=0.000 n=8+7)
    Flate             234k ± 0%         233k ± 0%  -0.34%  (p=0.000 n=8+8)
    GoParser          291k ± 0%         291k ± 0%  -0.13%  (p=0.000 n=8+8)
    Reflect          1.05M ± 0%        1.05M ± 0%  -0.20%  (p=0.000 n=8+8)
    Tar               344k ± 0%         343k ± 0%  -0.22%  (p=0.000 n=8+8)
    XML               430k ± 0%         429k ± 0%  -0.24%  (p=0.000 n=8+8)
    
    Change-Id: I0044b99079ef211003325a7f136e35b55cc5cb74
    Reviewed-on: https://go-review.googlesource.com/c/143638Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    72f099c3
reflect.go 48.6 KB