• Kirill Smelkov's avatar
    X zodb/cache: Allocate OCE from freelist · fbca5755
    Kirill Smelkov authored
    This avoid 2 allocations (for oidCacheEntry and for its .revv) for NoHit
    cache in steady state, speeding things up a bit via lowering pressure on
    go gc.
    
    Startup time increase could be either ignored (because it is only when
    N(access) < N(cache-size)) or handled later via explicitly preallocating
    OCE pool on cache creation.
    
    ---- 8< ----
    
    name                        old time/op    new time/op    delta
    NoopStorage                   56.6ns ± 1%    57.0ns ± 0%   +0.77%  (p=0.100 n=3+3)
    NoopStorage-4                 56.4ns ± 0%    57.1ns ± 0%   +1.24%  (p=0.100 n=3+3)
    CacheStartup                  1.95µs ± 2%    1.91µs ±10%     ~     (p=0.700 n=3+3)
    CacheStartup-4                1.31µs ± 5%    1.47µs ± 2%  +11.48%  (p=0.100 n=3+3)
    CacheNoHit/size=0              590ns ± 1%     502ns ± 1%  -14.81%  (p=0.100 n=3+3)
    CacheNoHit/size=0-4            591ns ± 1%     502ns ± 0%  -15.06%  (p=0.100 n=3+3)
    CacheNoHit/size=16             707ns ± 0%     622ns ± 1%  -11.98%  (p=0.100 n=3+3)
    CacheNoHit/size=16-4           711ns ± 1%     623ns ± 1%  -12.34%  (p=0.100 n=3+3)
    CacheNoHit/size=128            717ns ± 0%     624ns ± 0%  -12.88%  (p=0.100 n=3+3)
    CacheNoHit/size=128-4          716ns ± 0%     630ns ± 1%  -12.10%  (p=0.100 n=3+3)
    CacheNoHit/size=512            737ns ± 0%     645ns ± 0%  -12.40%  (p=0.100 n=3+3)
    CacheNoHit/size=512-4          721ns ± 0%     636ns ± 1%  -11.84%  (p=0.100 n=3+3)
    CacheNoHit/size=4096           946ns ± 1%     782ns ± 0%  -17.30%  (p=0.100 n=3+3)
    CacheNoHit/size=4096-4         780ns ± 1%     680ns ± 0%  -12.86%  (p=0.100 n=3+3)
    CacheHit/size=0                589ns ± 1%     507ns ± 0%  -13.98%  (p=0.100 n=3+3)
    CacheHit/size=0-4              588ns ± 0%     503ns ± 1%  -14.50%  (p=0.100 n=3+3)
    CacheHit/size=16               122ns ± 1%     121ns ± 1%     ~     (p=0.500 n=3+3)
    CacheHit/size=16-4             123ns ± 1%     124ns ± 2%     ~     (p=1.000 n=3+3)
    CacheHit/size=128              127ns ± 2%     124ns ± 1%     ~     (p=0.200 n=3+3)
    CacheHit/size=128-4            126ns ± 1%     126ns ± 1%     ~     (p=0.600 n=3+3)
    CacheHit/size=512              128ns ± 2%     127ns ± 1%     ~     (p=0.300 n=3+3)
    CacheHit/size=512-4            127ns ± 1%     126ns ± 0%   -1.05%  (p=0.100 n=3+3)
    CacheHit/size=4096             130ns ± 0%     130ns ± 3%     ~     (p=0.700 n=3+3)
    CacheHit/size=4096-4           130ns ± 1%     129ns ± 1%     ~     (p=0.300 n=3+3)
    NoopStoragePar                59.7ns ± 3%    57.0ns ± 0%   -4.47%  (p=0.100 n=3+3)
    NoopStoragePar-4              31.3ns ± 8%    30.7ns ± 5%     ~     (p=1.000 n=3+3)
    CacheStartupPar               1.97µs ±13%    2.19µs ±10%     ~     (p=0.400 n=3+3)
    CacheStartupPar-4             1.49µs ± 4%    1.71µs ± 4%  +14.44%  (p=0.100 n=3+3)
    CacheNoHitPar/size=0           591ns ± 0%     510ns ± 0%  -13.65%  (p=0.100 n=3+3)
    CacheNoHitPar/size=0-4         811ns ± 0%     726ns ± 0%  -10.40%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16          713ns ± 0%     621ns ± 0%  -12.95%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16-4        924ns ± 0%     826ns ± 0%  -10.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128         717ns ± 0%     629ns ± 0%  -12.23%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128-4       953ns ± 0%     848ns ± 0%  -11.02%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512         733ns ± 0%     645ns ± 0%  -12.00%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512-4       972ns ± 0%     881ns ± 0%   -9.36%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096        941ns ± 0%     788ns ± 0%  -16.29%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096-4     1.07µs ± 0%    0.96µs ± 0%  -10.30%  (p=0.100 n=3+3)
    CacheHitPar/size=0             587ns ± 0%     509ns ± 0%  -13.23%  (p=0.100 n=3+3)
    CacheHitPar/size=0-4           805ns ± 0%     722ns ± 0%  -10.31%  (p=0.100 n=3+3)
    CacheHitPar/size=16            122ns ± 1%     123ns ± 2%     ~     (p=1.000 n=3+3)
    CacheHitPar/size=16-4          236ns ± 1%     216ns ± 0%   -8.74%  (p=0.100 n=3+3)
    CacheHitPar/size=128           125ns ± 1%     125ns ± 1%     ~     (p=1.000 n=3+3)
    CacheHitPar/size=128-4         220ns ± 0%     207ns ± 0%   -6.06%  (p=0.100 n=3+3)
    CacheHitPar/size=512           127ns ± 2%     127ns ± 1%     ~     (p=0.600 n=3+3)
    CacheHitPar/size=512-4         219ns ± 0%     228ns ± 5%     ~     (p=0.600 n=3+3)
    CacheHitPar/size=4096          129ns ± 1%     129ns ± 0%     ~     (p=1.000 n=3+3)
    CacheHitPar/size=4096-4        223ns ± 5%     223ns ± 4%     ~     (p=1.000 n=3+3)
    NoopStorageProc               54.7ns ± 0%    55.1ns ± 0%   +0.67%  (p=0.100 n=3+3)
    NoopStorageProc-4             31.8ns ± 4%    29.5ns ± 1%   -7.14%  (p=0.100 n=3+3)
    CacheStartupProc              1.88µs ±11%    2.15µs ±11%     ~     (p=0.400 n=3+3)
    CacheStartupProc-4            1.13µs ± 3%    1.23µs ± 4%   +9.04%  (p=0.100 n=3+3)
    CacheNoHitProc/size=0          598ns ± 0%     500ns ± 0%  -16.33%  (p=0.100 n=3+3)
    CacheNoHitProc/size=0-4        309ns ± 0%     297ns ± 1%   -3.89%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16         711ns ± 0%     615ns ± 0%  -13.55%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16-4       356ns ± 0%     314ns ± 0%  -11.88%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128        722ns ± 1%     622ns ± 0%  -13.90%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128-4      363ns ± 0%     311ns ± 0%  -14.25%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512        741ns ± 1%     640ns ± 0%  -13.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512-4      394ns ± 0%     331ns ± 0%  -16.06%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096       943ns ± 0%     782ns ± 1%  -17.04%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096-4     565ns ± 0%     462ns ± 0%  -18.28%  (p=0.100 n=3+3)
    CacheHitProc/size=0            598ns ± 0%     498ns ± 0%  -16.67%  (p=0.100 n=3+3)
    CacheHitProc/size=0-4          310ns ± 0%     291ns ± 0%   -5.92%  (p=0.100 n=3+3)
    CacheHitProc/size=16           120ns ± 1%     120ns ± 1%     ~     (p=0.600 n=3+3)
    CacheHitProc/size=16-4        57.5ns ± 2%    57.2ns ± 1%     ~     (p=1.000 n=3+3)
    CacheHitProc/size=128          123ns ± 1%     123ns ± 1%     ~     (p=1.000 n=3+3)
    CacheHitProc/size=128-4       58.1ns ± 0%    57.9ns ± 0%     ~     (p=0.200 n=3+3)
    CacheHitProc/size=512          126ns ± 2%     126ns ± 1%     ~     (p=1.000 n=3+3)
    CacheHitProc/size=512-4       58.6ns ± 0%    58.6ns ± 0%     ~     (p=1.000 n=3+3)
    CacheHitProc/size=4096         128ns ± 1%     127ns ± 1%     ~     (p=1.000 n=3+3)
    CacheHitProc/size=4096-4      69.8ns ± 0%    70.6ns ± 1%   +1.15%  (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               152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheNoHit/size=0-4             152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheNoHit/size=16              153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHit/size=16-4            153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHit/size=128             153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHit/size=128-4           153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHit/size=512             153B ± 0%       97B ± 0%  -36.46%  (p=0.100 n=3+3)
    CacheNoHit/size=512-4           153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHit/size=4096            153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHit/size=4096-4          153B ± 0%       97B ± 0%  -36.46%  (p=0.100 n=3+3)
    CacheHit/size=0                 152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheHit/size=0-4               152B ± 0%       96B ± 0%  -36.84%  (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 ± 0%      282B ± 1%     ~     (p=1.000 n=3+3)
    CacheNoHitPar/size=0            152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheNoHitPar/size=0-4          152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16           153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16-4         154B ± 0%       98B ± 0%  -36.36%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128          153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128-4        153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512          153B ± 0%       97B ± 1%  -36.82%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512-4        153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096         153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096-4       153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheHitPar/size=0              152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheHitPar/size=0-4            152B ± 0%       96B ± 0%  -36.84%  (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           152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheNoHitProc/size=0-4         152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16          153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16-4        153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128         153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128-4       153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512         153B ± 0%       96B ± 1%  -37.04%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512-4       153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096        153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096-4      153B ± 0%       97B ± 0%  -36.60%  (p=0.100 n=3+3)
    CacheHitProc/size=0             152B ± 0%       96B ± 0%  -36.84%  (p=0.100 n=3+3)
    CacheHitProc/size=0-4           152B ± 0%       96B ± 0%  -36.84%  (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%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=0-4             3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=16              3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=16-4            3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=128             3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=128-4           3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=512             3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=512-4           3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=4096            3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHit/size=4096-4          3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheHit/size=0                 3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheHit/size=0-4               3.00 ± 0%      1.00 ± 0%  -66.67%  (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.00 ± 0%      4.33 ±15%     ~     (p=1.000 n=3+3)
    CacheNoHitPar/size=0            3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=0-4          3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16           3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=16-4         3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128          3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=128-4        3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512          3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=512-4        3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096         3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitPar/size=4096-4       3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheHitPar/size=0              3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheHitPar/size=0-4            3.00 ± 0%      1.00 ± 0%  -66.67%  (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%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=0-4         3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16          3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=16-4        3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128         3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=128-4       3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512         3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=512-4       3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096        3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheNoHitProc/size=4096-4      3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheHitProc/size=0             3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.100 n=3+3)
    CacheHitProc/size=0-4           3.00 ± 0%      1.00 ± 0%  -66.67%  (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)
    fbca5755
cache.go 17.8 KB