• Kirill Smelkov's avatar
    X zodb/cache: Performing GC in separate goroutine was actually a bad idea · 0e2be3b3
    Kirill Smelkov authored
    Probably channel signalling + goroutine scheduling overhead was taking
    too much - see appendix for timings.
    
    Once again - as in 521d3ae5 (X zodb/cache: Also free OCE entries on GC)
    we can ignore *Hit/size=0 increase as /size=0 won't happen in practice
    and we mostly care about NoHit overhead for which /size=0 also improves.
    The HitProc/* increase, as in 521d3ae5, is also withing noise.
    
    ---- 8< ----
    
    name                        old time/op    new time/op    delta
    NoopStorage                   56.6ns ± 0%    57.9ns ± 1%     +2.36%  (p=0.100 n=3+3)
    NoopStorage-4                 56.9ns ± 1%    57.4ns ± 1%       ~     (p=0.200 n=3+3)
    CacheStartup                  1.97µs ± 3%    2.13µs ±16%       ~     (p=0.600 n=3+3)
    CacheStartup-4                1.29µs ± 4%    1.29µs ± 4%       ~     (p=1.000 n=3+3)
    CacheNoHit/size=0             1.34µs ± 1%    0.68µs ± 1%    -49.43%  (p=0.100 n=3+3)
    CacheNoHit/size=0-4            941ns ± 1%     664ns ± 1%    -29.38%  (p=0.100 n=3+3)
    CacheNoHit/size=16            1.38µs ± 3%    0.79µs ± 0%    -42.49%  (p=0.100 n=3+3)
    CacheNoHit/size=16-4           939ns ± 2%     788ns ± 0%    -16.02%  (p=0.100 n=3+3)
    CacheNoHit/size=128           1.32µs ± 2%    0.80µs ± 0%    -39.55%  (p=0.100 n=3+3)
    CacheNoHit/size=128-4          946ns ± 1%     795ns ± 1%    -16.03%  (p=0.100 n=3+3)
    CacheNoHit/size=512           1.37µs ± 3%    0.82µs ± 0%    -40.33%  (p=0.100 n=3+3)
    CacheNoHit/size=512-4          977ns ± 2%     803ns ± 0%    -17.75%  (p=0.100 n=3+3)
    CacheNoHit/size=4096          1.37µs ± 4%    1.05µs ± 1%    -23.03%  (p=0.100 n=3+3)
    CacheNoHit/size=4096-4        1.07µs ± 0%    0.86µs ± 0%    -19.94%  (p=0.100 n=3+3)
    CacheHit/size=0                164ns ±29%     664ns ± 0%   +305.08%  (p=0.100 n=3+3)
    CacheHit/size=0-4              251ns ± 6%     660ns ± 0%   +162.95%  (p=0.100 n=3+3)
    CacheHit/size=16               120ns ± 1%     123ns ± 4%       ~     (p=0.700 n=3+3)
    CacheHit/size=16-4             121ns ± 2%     121ns ± 1%       ~     (p=1.000 n=3+3)
    CacheHit/size=128              123ns ± 1%     124ns ± 1%       ~     (p=1.000 n=3+3)
    CacheHit/size=128-4            124ns ± 0%     124ns ± 1%       ~     (p=1.000 n=3+3)
    CacheHit/size=512              125ns ± 0%     126ns ± 1%       ~     (p=0.400 n=3+3)
    CacheHit/size=512-4            126ns ± 1%     125ns ± 1%       ~     (p=0.400 n=3+3)
    CacheHit/size=4096             128ns ± 1%     127ns ± 1%       ~     (p=1.000 n=3+3)
    CacheHit/size=4096-4           128ns ± 1%     128ns ± 1%       ~     (p=1.000 n=3+3)
    NoopStoragePar                56.5ns ± 0%    59.2ns ± 1%     +4.84%  (p=0.100 n=3+3)
    NoopStoragePar-4              33.1ns ± 3%    31.2ns ± 8%       ~     (p=0.400 n=3+3)
    CacheStartupPar               2.01µs ±14%    2.04µs ± 6%       ~     (p=0.800 n=3+3)
    CacheStartupPar-4             1.47µs ± 4%    1.48µs ± 3%       ~     (p=1.000 n=3+3)
    CacheNoHitPar/size=0          1.35µs ± 3%    0.67µs ± 0%    -50.25%  (p=0.100 n=3+3)
    CacheNoHitPar/size=0-4        1.04µs ± 0%    0.90µs ± 0%    -12.83%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16         1.32µs ± 2%    0.79µs ± 0%    -40.36%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16-4       1.04µs ± 0%    1.03µs ± 0%     -1.28%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128        1.33µs ± 1%    0.80µs ± 0%    -40.02%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128-4      1.03µs ± 1%    1.04µs ± 0%       ~     (p=0.400 n=3+3)
    CacheNoHitPar/size=512        1.34µs ± 2%    0.82µs ± 0%    -38.79%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512-4      1.07µs ± 2%    1.07µs ± 0%       ~     (p=0.600 n=3+3)
    CacheNoHitPar/size=4096       1.36µs ± 4%    1.06µs ± 1%    -21.87%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096-4     1.16µs ± 2%    1.17µs ± 1%       ~     (p=0.700 n=3+3)
    CacheHitPar/size=0             163ns ± 3%     665ns ± 0%   +306.94%  (p=0.100 n=3+3)
    CacheHitPar/size=0-4           394ns ± 3%     903ns ± 1%   +129.08%  (p=0.100 n=3+3)
    CacheHitPar/size=16            121ns ± 0%     124ns ± 1%     +2.20%  (p=0.100 n=3+3)
    CacheHitPar/size=16-4          213ns ± 0%     217ns ± 1%     +2.03%  (p=0.100 n=3+3)
    CacheHitPar/size=128           124ns ± 1%     125ns ± 0%       ~     (p=0.400 n=3+3)
    CacheHitPar/size=128-4         208ns ± 0%     215ns ± 1%     +3.21%  (p=0.100 n=3+3)
    CacheHitPar/size=512           126ns ± 1%     127ns ± 1%       ~     (p=0.300 n=3+3)
    CacheHitPar/size=512-4         205ns ± 0%     241ns ± 0%    +17.40%  (p=0.100 n=3+3)
    CacheHitPar/size=4096          127ns ± 0%     129ns ± 0%     +1.57%  (p=0.100 n=3+3)
    CacheHitPar/size=4096-4        201ns ± 0%     236ns ± 4%    +17.58%  (p=0.100 n=3+3)
    NoopStorageProc               54.8ns ± 0%    56.1ns ± 0%     +2.43%  (p=0.100 n=3+3)
    NoopStorageProc-4             32.6ns ± 4%    37.1ns ±10%    +14.02%  (p=0.100 n=3+3)
    CacheStartupProc              1.91µs ± 7%    1.79µs ± 3%       ~     (p=0.400 n=3+3)
    CacheStartupProc-4            1.13µs ± 1%    1.08µs ± 7%       ~     (p=0.400 n=3+3)
    CacheNoHitProc/size=0         1.32µs ± 1%    0.67µs ± 0%    -49.38%  (p=0.100 n=3+3)
    CacheNoHitProc/size=0-4        649ns ± 1%     414ns ±15%    -36.23%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16        1.33µs ± 3%    0.79µs ± 0%    -40.23%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16-4       650ns ± 2%     440ns ± 7%    -32.34%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128       1.31µs ± 5%    0.81µs ± 0%    -38.41%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128-4      663ns ± 1%     467ns ± 8%    -29.58%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512       1.30µs ± 2%    0.83µs ± 1%    -35.72%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512-4      685ns ± 1%     499ns ± 9%    -27.12%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096      1.35µs ± 3%    1.07µs ± 0%    -20.87%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096-4     684ns ± 2%     629ns ± 3%     -8.04%  (p=0.100 n=3+3)
    CacheHitProc/size=0            159ns ± 3%     669ns ± 0%   +320.75%  (p=0.100 n=3+3)
    CacheHitProc/size=0-4         75.1ns ±10%   381.0ns ± 2%   +407.10%  (p=0.100 n=3+3)
    CacheHitProc/size=16           120ns ± 1%     121ns ± 1%       ~     (p=0.300 n=3+3)
    CacheHitProc/size=16-4        58.1ns ± 2%    65.0ns ± 3%    +11.94%  (p=0.100 n=3+3)
    CacheHitProc/size=128          123ns ± 0%     124ns ± 0%     +0.81%  (p=0.100 n=3+3)
    CacheHitProc/size=128-4       57.6ns ± 0%    74.9ns ± 3%    +30.05%  (p=0.100 n=3+3)
    CacheHitProc/size=512          124ns ± 1%     125ns ± 1%       ~     (p=0.300 n=3+3)
    CacheHitProc/size=512-4       59.4ns ± 1%    71.5ns ± 2%    +20.38%  (p=0.100 n=3+3)
    CacheHitProc/size=4096         127ns ± 0%     132ns ± 6%     +3.94%  (p=0.100 n=3+3)
    CacheHitProc/size=4096-4      64.2ns ± 1%    80.5ns ± 7%    +25.34%  (p=0.100 n=3+3)
    
    name                        old alloc/op   new alloc/op   delta
    NoopStorage                    0.00B          0.00B            ~     (all equal)
    NoopStorage-4                  0.00B          0.00B            ~     (all equal)
    CacheStartup                    285B ± 0%      285B ± 0%       ~     (all equal)
    CacheStartup-4                  285B ± 0%      285B ± 0%       ~     (all equal)
    CacheNoHit/size=0               247B ± 2%      152B ± 0%    -38.38%  (p=0.100 n=3+3)
    CacheNoHit/size=0-4             153B ± 0%      152B ± 0%     -0.65%  (p=0.100 n=3+3)
    CacheNoHit/size=16              247B ± 2%      153B ± 0%    -37.97%  (p=0.100 n=3+3)
    CacheNoHit/size=16-4            153B ± 0%      153B ± 0%       ~     (p=1.000 n=3+3)
    CacheNoHit/size=128             241B ± 1%      153B ± 0%    -36.60%  (p=0.100 n=3+3)
    CacheNoHit/size=128-4           153B ± 0%      153B ± 0%       ~     (p=1.000 n=3+3)
    CacheNoHit/size=512             245B ± 1%      153B ± 0%    -37.64%  (p=0.100 n=3+3)
    CacheNoHit/size=512-4           154B ± 0%      153B ± 0%     -0.65%  (p=0.100 n=3+3)
    CacheNoHit/size=4096            244B ± 1%      153B ± 0%    -37.21%  (p=0.100 n=3+3)
    CacheNoHit/size=4096-4          155B ± 0%      152B ± 0%     -1.72%  (p=0.100 n=3+3)
    CacheHit/size=0               5.00B ±100%   152.00B ± 0%  +2940.00%  (p=0.100 n=3+3)
    CacheHit/size=0-4              11.0B ± 9%    152.0B ± 0%  +1281.82%  (p=0.100 n=3+3)
    CacheHit/size=16               0.00B          0.00B            ~     (all equal)
    CacheHit/size=16-4             0.00B          0.00B            ~     (all equal)
    CacheHit/size=128              0.00B          0.00B            ~     (all equal)
    CacheHit/size=128-4            0.00B          0.00B            ~     (all equal)
    CacheHit/size=512              0.00B          0.00B            ~     (all equal)
    CacheHit/size=512-4            0.00B          0.00B            ~     (all equal)
    CacheHit/size=4096             0.00B          0.00B            ~     (all equal)
    CacheHit/size=4096-4           0.00B          0.00B            ~     (all equal)
    NoopStoragePar                 0.00B          0.00B            ~     (all equal)
    NoopStoragePar-4               0.00B          0.00B            ~     (all equal)
    CacheStartupPar                 285B ± 0%      285B ± 0%       ~     (all equal)
    CacheStartupPar-4               282B ± 1%      281B ± 0%       ~     (p=0.600 n=3+3)
    CacheNoHitPar/size=0            247B ± 2%      152B ± 0%    -38.38%  (p=0.100 n=3+3)
    CacheNoHitPar/size=0-4          161B ± 0%      152B ± 0%     -5.59%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16           245B ± 1%      153B ± 0%    -37.55%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16-4         161B ± 0%      155B ± 0%     -3.93%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128          245B ± 2%      153B ± 0%    -37.55%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128-4        162B ± 0%      153B ± 0%     -5.36%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512          246B ± 3%      153B ± 0%    -37.89%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512-4        161B ± 0%      153B ± 0%     -4.97%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096         244B ± 3%      153B ± 0%    -37.38%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096-4       164B ± 0%      153B ± 0%     -6.71%  (p=0.100 n=3+3)
    CacheHitPar/size=0             5.00B ±20%   152.00B ± 0%  +2940.00%  (p=0.100 n=3+3)
    CacheHitPar/size=0-4           14.0B ± 7%    152.0B ± 0%   +985.71%  (p=0.100 n=3+3)
    CacheHitPar/size=16            0.00B          0.00B            ~     (all equal)
    CacheHitPar/size=16-4          0.00B          0.00B            ~     (all equal)
    CacheHitPar/size=128           0.00B          0.00B            ~     (all equal)
    CacheHitPar/size=128-4         0.00B          0.00B            ~     (all equal)
    CacheHitPar/size=512           0.00B          0.00B            ~     (all equal)
    CacheHitPar/size=512-4         0.00B          0.00B            ~     (all equal)
    CacheHitPar/size=4096          0.00B          0.00B            ~     (all equal)
    CacheHitPar/size=4096-4        0.00B          0.00B            ~     (all equal)
    NoopStorageProc                0.00B          0.00B            ~     (all equal)
    NoopStorageProc-4              0.00B          0.00B            ~     (all equal)
    CacheStartupProc                285B ± 0%      285B ± 0%       ~     (all equal)
    CacheStartupProc-4              285B ± 0%      285B ± 0%       ~     (all equal)
    CacheNoHitProc/size=0           243B ± 1%      152B ± 0%    -37.53%  (p=0.100 n=3+3)
    CacheNoHitProc/size=0-4         195B ± 1%      152B ± 0%    -22.05%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16          247B ± 2%      153B ± 0%    -37.97%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16-4        194B ± 0%      153B ± 0%    -21.27%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128         242B ± 4%      153B ± 0%    -36.78%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128-4       193B ± 0%      153B ± 0%    -20.86%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512         240B ± 2%      153B ± 0%    -36.48%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512-4       190B ± 1%      153B ± 0%    -19.33%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096        245B ± 2%      153B ± 0%    -37.55%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096-4      181B ± 2%      153B ± 0%    -15.47%  (p=0.100 n=3+3)
    CacheHitProc/size=0            4.33B ±15%   152.00B ± 0%  +3407.69%  (p=0.100 n=3+3)
    CacheHitProc/size=0-4          3.33B ±50%   152.00B ± 0%  +4460.00%  (p=0.100 n=3+3)
    CacheHitProc/size=16           0.00B          0.00B            ~     (all equal)
    CacheHitProc/size=16-4         0.00B          0.00B            ~     (all equal)
    CacheHitProc/size=128          0.00B          0.00B            ~     (all equal)
    CacheHitProc/size=128-4        0.00B          0.00B            ~     (all equal)
    CacheHitProc/size=512          0.00B          0.00B            ~     (all equal)
    CacheHitProc/size=512-4        0.00B          0.00B            ~     (all equal)
    CacheHitProc/size=4096         0.00B          0.00B            ~     (all equal)
    CacheHitProc/size=4096-4       0.00B          0.00B            ~     (all equal)
    
    name                        old allocs/op  new allocs/op  delta
    NoopStorage                     0.00           0.00            ~     (all equal)
    NoopStorage-4                   0.00           0.00            ~     (all equal)
    CacheStartup                    5.00 ± 0%      5.00 ± 0%       ~     (all equal)
    CacheStartup-4                  5.00 ± 0%      5.00 ± 0%       ~     (all equal)
    CacheNoHit/size=0               3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=0-4             3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=16              3.33 ±20%      3.00 ± 0%       ~     (p=1.000 n=3+3)
    CacheNoHit/size=16-4            3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=128             3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=128-4           3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=512             3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=512-4           3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=4096            3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHit/size=4096-4          3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheHit/size=0                 0.00           3.00 ± 0%      +Inf%  (p=0.100 n=3+3)
    CacheHit/size=0-4               0.00           3.00 ± 0%      +Inf%  (p=0.100 n=3+3)
    CacheHit/size=16                0.00           0.00            ~     (all equal)
    CacheHit/size=16-4              0.00           0.00            ~     (all equal)
    CacheHit/size=128               0.00           0.00            ~     (all equal)
    CacheHit/size=128-4             0.00           0.00            ~     (all equal)
    CacheHit/size=512               0.00           0.00            ~     (all equal)
    CacheHit/size=512-4             0.00           0.00            ~     (all equal)
    CacheHit/size=4096              0.00           0.00            ~     (all equal)
    CacheHit/size=4096-4            0.00           0.00            ~     (all equal)
    NoopStoragePar                  0.00           0.00            ~     (all equal)
    NoopStoragePar-4                0.00           0.00            ~     (all equal)
    CacheStartupPar                 5.00 ± 0%      5.00 ± 0%       ~     (all equal)
    CacheStartupPar-4               4.33 ±15%      4.00 ± 0%       ~     (p=1.000 n=3+3)
    CacheNoHitPar/size=0            3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=0-4          3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=16           3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=16-4         3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=128          3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=128-4        3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=512          3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=512-4        3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=4096         3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitPar/size=4096-4       3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheHitPar/size=0              0.00           3.00 ± 0%      +Inf%  (p=0.100 n=3+3)
    CacheHitPar/size=0-4            0.00           3.00 ± 0%      +Inf%  (p=0.100 n=3+3)
    CacheHitPar/size=16             0.00           0.00            ~     (all equal)
    CacheHitPar/size=16-4           0.00           0.00            ~     (all equal)
    CacheHitPar/size=128            0.00           0.00            ~     (all equal)
    CacheHitPar/size=128-4          0.00           0.00            ~     (all equal)
    CacheHitPar/size=512            0.00           0.00            ~     (all equal)
    CacheHitPar/size=512-4          0.00           0.00            ~     (all equal)
    CacheHitPar/size=4096           0.00           0.00            ~     (all equal)
    CacheHitPar/size=4096-4         0.00           0.00            ~     (all equal)
    NoopStorageProc                 0.00           0.00            ~     (all equal)
    NoopStorageProc-4               0.00           0.00            ~     (all equal)
    CacheStartupProc                5.00 ± 0%      5.00 ± 0%       ~     (all equal)
    CacheStartupProc-4              5.00 ± 0%      5.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=0           3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=0-4         3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=16          3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=16-4        3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=128         3.33 ±20%      3.00 ± 0%       ~     (p=1.000 n=3+3)
    CacheNoHitProc/size=128-4       3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=512         3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=512-4       3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheNoHitProc/size=4096        3.33 ±20%      3.00 ± 0%       ~     (p=1.000 n=3+3)
    CacheNoHitProc/size=4096-4      3.00 ± 0%      3.00 ± 0%       ~     (all equal)
    CacheHitProc/size=0             0.00           3.00 ± 0%      +Inf%  (p=0.100 n=3+3)
    CacheHitProc/size=0-4           0.00           3.00 ± 0%      +Inf%  (p=0.100 n=3+3)
    CacheHitProc/size=16            0.00           0.00            ~     (all equal)
    CacheHitProc/size=16-4          0.00           0.00            ~     (all equal)
    CacheHitProc/size=128           0.00           0.00            ~     (all equal)
    CacheHitProc/size=128-4         0.00           0.00            ~     (all equal)
    CacheHitProc/size=512           0.00           0.00            ~     (all equal)
    CacheHitProc/size=512-4         0.00           0.00            ~     (all equal)
    CacheHitProc/size=4096          0.00           0.00            ~     (all equal)
    CacheHitProc/size=4096-4        0.00           0.00            ~     (all equal)
    0e2be3b3
cache_test.go 23.7 KB