Commit 13f149f0 authored by Kirill Smelkov's avatar Kirill Smelkov

X zodb/cache: Kill cache-gc tracepoint

On NoHit workloads gc is invoked for every load and since cache's goal
is to provide minimum slowdown the tracepoint overhead becomes visible.

Cache gc tracepoints were initially added for testing - to be able to
wait for gc to start/finish - when gc was running in its own goroutine,
but now, after 0e2be3b3 (X zodb/cache: Performing GC in separate
goroutine was actually a bad idea), when gc is running synchronously
there is need for this tracing events even from testing point of view.

So remove them.

---- 8< ----

name                        old time/op    new time/op    delta
NoopStorage                   57.9ns ± 1%    56.6ns ± 1%   -2.30%  (p=0.100 n=3+3)
NoopStorage-4                 57.4ns ± 1%    56.4ns ± 0%   -1.68%  (p=0.100 n=3+3)
CacheStartup                  2.13µs ±16%    1.95µs ± 2%     ~     (p=0.700 n=3+3)
CacheStartup-4                1.29µs ± 4%    1.31µs ± 5%     ~     (p=0.700 n=3+3)
CacheNoHit/size=0              677ns ± 1%     590ns ± 1%  -12.86%  (p=0.100 n=3+3)
CacheNoHit/size=0-4            664ns ± 1%     591ns ± 1%  -11.04%  (p=0.100 n=3+3)
CacheNoHit/size=16             792ns ± 0%     707ns ± 0%  -10.81%  (p=0.100 n=3+3)
CacheNoHit/size=16-4           788ns ± 0%     711ns ± 1%   -9.85%  (p=0.100 n=3+3)
CacheNoHit/size=128            796ns ± 0%     717ns ± 0%   -9.93%  (p=0.100 n=3+3)
CacheNoHit/size=128-4          795ns ± 1%     716ns ± 0%   -9.86%  (p=0.100 n=3+3)
CacheNoHit/size=512            816ns ± 0%     737ns ± 0%   -9.69%  (p=0.100 n=3+3)
CacheNoHit/size=512-4          803ns ± 0%     721ns ± 0%  -10.25%  (p=0.100 n=3+3)
CacheNoHit/size=4096          1.05µs ± 1%    0.95µs ± 1%  -10.13%  (p=0.100 n=3+3)
CacheNoHit/size=4096-4         856ns ± 0%     780ns ± 1%   -8.91%  (p=0.100 n=3+3)
CacheHit/size=0                664ns ± 0%     589ns ± 1%  -11.34%  (p=0.100 n=3+3)
CacheHit/size=0-4              660ns ± 0%     588ns ± 0%  -10.86%  (p=0.100 n=3+3)
CacheHit/size=16               123ns ± 4%     122ns ± 1%     ~     (p=0.800 n=3+3)
CacheHit/size=16-4             121ns ± 1%     123ns ± 1%     ~     (p=0.300 n=3+3)
CacheHit/size=128              124ns ± 1%     127ns ± 2%   +2.70%  (p=0.100 n=3+3)
CacheHit/size=128-4            124ns ± 1%     126ns ± 1%   +2.16%  (p=0.100 n=3+3)
CacheHit/size=512              126ns ± 1%     128ns ± 2%     ~     (p=0.400 n=3+3)
CacheHit/size=512-4            125ns ± 1%     127ns ± 1%   +1.60%  (p=0.100 n=3+3)
CacheHit/size=4096             127ns ± 1%     130ns ± 0%   +2.09%  (p=0.100 n=3+3)
CacheHit/size=4096-4           128ns ± 1%     130ns ± 1%   +1.56%  (p=0.100 n=3+3)
NoopStoragePar                59.2ns ± 1%    59.7ns ± 3%     ~     (p=1.000 n=3+3)
NoopStoragePar-4              31.2ns ± 8%    31.3ns ± 8%     ~     (p=1.000 n=3+3)
CacheStartupPar               2.04µs ± 6%    1.97µs ±13%     ~     (p=1.000 n=3+3)
CacheStartupPar-4             1.48µs ± 3%    1.49µs ± 4%     ~     (p=0.700 n=3+3)
CacheNoHitPar/size=0           670ns ± 0%     591ns ± 0%  -11.75%  (p=0.100 n=3+3)
CacheNoHitPar/size=0-4         904ns ± 0%     811ns ± 0%  -10.32%  (p=0.100 n=3+3)
CacheNoHitPar/size=16          789ns ± 0%     713ns ± 0%   -9.63%  (p=0.100 n=3+3)
CacheNoHitPar/size=16-4       1.03µs ± 0%    0.92µs ± 0%  -10.06%  (p=0.100 n=3+3)
CacheNoHitPar/size=128         800ns ± 0%     717ns ± 0%  -10.45%  (p=0.100 n=3+3)
CacheNoHitPar/size=128-4      1.04µs ± 0%    0.95µs ± 0%   -8.63%  (p=0.100 n=3+3)
CacheNoHitPar/size=512         818ns ± 0%     733ns ± 0%  -10.35%  (p=0.100 n=3+3)
CacheNoHitPar/size=512-4      1.07µs ± 0%    0.97µs ± 0%   -9.04%  (p=0.100 n=3+3)
CacheNoHitPar/size=4096       1.06µs ± 1%    0.94µs ± 0%  -11.50%  (p=0.100 n=3+3)
CacheNoHitPar/size=4096-4     1.17µs ± 1%    1.07µs ± 0%   -7.89%  (p=0.100 n=3+3)
CacheHitPar/size=0             665ns ± 0%     587ns ± 0%  -11.69%  (p=0.100 n=3+3)
CacheHitPar/size=0-4           903ns ± 1%     805ns ± 0%  -10.85%  (p=0.100 n=3+3)
CacheHitPar/size=16            124ns ± 1%     122ns ± 1%     ~     (p=0.200 n=3+3)
CacheHitPar/size=16-4          217ns ± 1%     236ns ± 1%   +8.74%  (p=0.100 n=3+3)
CacheHitPar/size=128           125ns ± 0%     125ns ± 1%     ~     (p=1.000 n=3+3)
CacheHitPar/size=128-4         215ns ± 1%     220ns ± 0%   +2.48%  (p=0.100 n=3+3)
CacheHitPar/size=512           127ns ± 1%     127ns ± 2%     ~     (p=0.600 n=3+3)
CacheHitPar/size=512-4         241ns ± 0%     219ns ± 0%   -9.14%  (p=0.100 n=3+3)
CacheHitPar/size=4096          129ns ± 0%     129ns ± 1%     ~     (p=1.000 n=3+3)
CacheHitPar/size=4096-4        236ns ± 4%     223ns ± 5%     ~     (p=0.200 n=3+3)
NoopStorageProc               56.1ns ± 0%    54.7ns ± 0%   -2.44%  (p=0.100 n=3+3)
NoopStorageProc-4             37.1ns ±10%    31.8ns ± 4%  -14.45%  (p=0.100 n=3+3)
CacheStartupProc              1.79µs ± 3%    1.88µs ±11%     ~     (p=0.700 n=3+3)
CacheStartupProc-4            1.08µs ± 7%    1.13µs ± 3%     ~     (p=0.400 n=3+3)
CacheNoHitProc/size=0          669ns ± 0%     598ns ± 0%  -10.66%  (p=0.100 n=3+3)
CacheNoHitProc/size=0-4        414ns ±15%     309ns ± 0%  -25.38%  (p=0.100 n=3+3)
CacheNoHitProc/size=16         792ns ± 0%     711ns ± 0%  -10.27%  (p=0.100 n=3+3)
CacheNoHitProc/size=16-4       440ns ± 7%     356ns ± 0%  -19.02%  (p=0.100 n=3+3)
CacheNoHitProc/size=128        808ns ± 0%     722ns ± 1%  -10.61%  (p=0.100 n=3+3)
CacheNoHitProc/size=128-4      467ns ± 8%     363ns ± 0%  -22.29%  (p=0.100 n=3+3)
CacheNoHitProc/size=512        834ns ± 1%     741ns ± 1%  -11.08%  (p=0.100 n=3+3)
CacheNoHitProc/size=512-4      499ns ± 9%     394ns ± 0%  -20.98%  (p=0.100 n=3+3)
CacheNoHitProc/size=4096      1.07µs ± 0%    0.94µs ± 0%  -11.71%  (p=0.100 n=3+3)
CacheNoHitProc/size=4096-4     629ns ± 3%     565ns ± 0%  -10.12%  (p=0.100 n=3+3)
CacheHitProc/size=0            669ns ± 0%     598ns ± 0%  -10.61%  (p=0.100 n=3+3)
CacheHitProc/size=0-4          381ns ± 2%     310ns ± 0%  -18.72%  (p=0.100 n=3+3)
CacheHitProc/size=16           121ns ± 1%     120ns ± 1%     ~     (p=0.400 n=3+3)
CacheHitProc/size=16-4        65.0ns ± 3%    57.5ns ± 2%  -11.59%  (p=0.100 n=3+3)
CacheHitProc/size=128          124ns ± 0%     123ns ± 1%     ~     (p=0.700 n=3+3)
CacheHitProc/size=128-4       74.9ns ± 3%    58.1ns ± 0%  -22.44%  (p=0.100 n=3+3)
CacheHitProc/size=512          125ns ± 1%     126ns ± 2%     ~     (p=0.600 n=3+3)
CacheHitProc/size=512-4       71.5ns ± 2%    58.6ns ± 0%  -17.96%  (p=0.100 n=3+3)
CacheHitProc/size=4096         132ns ± 6%     128ns ± 1%     ~     (p=0.600 n=3+3)
CacheHitProc/size=4096-4      80.5ns ± 7%    69.8ns ± 0%  -13.30%  (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%      152B ± 0%     ~     (all equal)
CacheNoHit/size=0-4             152B ± 0%      152B ± 0%     ~     (all equal)
CacheNoHit/size=16              153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHit/size=16-4            153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHit/size=128             153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHit/size=128-4           153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHit/size=512             153B ± 0%      153B ± 0%     ~     (p=1.000 n=3+3)
CacheNoHit/size=512-4           153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHit/size=4096            153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHit/size=4096-4          152B ± 0%      153B ± 0%     ~     (p=1.000 n=3+3)
CacheHit/size=0                 152B ± 0%      152B ± 0%     ~     (all equal)
CacheHit/size=0-4               152B ± 0%      152B ± 0%     ~     (all equal)
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               281B ± 0%      282B ± 0%     ~     (p=0.300 n=3+3)
CacheNoHitPar/size=0            152B ± 0%      152B ± 0%     ~     (all equal)
CacheNoHitPar/size=0-4          152B ± 0%      152B ± 0%     ~     (all equal)
CacheNoHitPar/size=16           153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitPar/size=16-4         155B ± 0%      154B ± 0%     ~     (p=0.400 n=3+3)
CacheNoHitPar/size=128          153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitPar/size=128-4        153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitPar/size=512          153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitPar/size=512-4        153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitPar/size=4096         153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitPar/size=4096-4       153B ± 0%      153B ± 0%     ~     (all equal)
CacheHitPar/size=0              152B ± 0%      152B ± 0%     ~     (all equal)
CacheHitPar/size=0-4            152B ± 0%      152B ± 0%     ~     (all equal)
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%      152B ± 0%     ~     (all equal)
CacheNoHitProc/size=0-4         152B ± 0%      152B ± 0%     ~     (all equal)
CacheNoHitProc/size=16          153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitProc/size=16-4        153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitProc/size=128         153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitProc/size=128-4       153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitProc/size=512         153B ± 0%      153B ± 0%     ~     (p=1.000 n=3+3)
CacheNoHitProc/size=512-4       153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitProc/size=4096        153B ± 0%      153B ± 0%     ~     (all equal)
CacheNoHitProc/size=4096-4      153B ± 0%      153B ± 0%     ~     (all equal)
CacheHitProc/size=0             152B ± 0%      152B ± 0%     ~     (all equal)
CacheHitProc/size=0-4           152B ± 0%      152B ± 0%     ~     (all equal)
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.00 ± 0%      3.00 ± 0%     ~     (all equal)
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                 3.00 ± 0%      3.00 ± 0%     ~     (all equal)
CacheHit/size=0-4               3.00 ± 0%      3.00 ± 0%     ~     (all equal)
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.00 ± 0%     ~     (all equal)
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              3.00 ± 0%      3.00 ± 0%     ~     (all equal)
CacheHitPar/size=0-4            3.00 ± 0%      3.00 ± 0%     ~     (all equal)
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.00 ± 0%      3.00 ± 0%     ~     (all equal)
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.00 ± 0%      3.00 ± 0%     ~     (all equal)
CacheNoHitProc/size=4096-4      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
CacheHitProc/size=0             3.00 ± 0%      3.00 ± 0%     ~     (all equal)
CacheHitProc/size=0-4           3.00 ± 0%      3.00 ± 0%     ~     (all equal)
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)
parent 0e2be3b3
...@@ -465,15 +465,10 @@ func tryMerge(prev, next, cur *revCacheEntry) bool { ...@@ -465,15 +465,10 @@ func tryMerge(prev, next, cur *revCacheEntry) bool {
// ---- garbage collection ---- // ---- garbage collection ----
//trace:event traceCacheGCStart(c *Cache)
//trace:event traceCacheGCFinish(c *Cache)
// gc performs garbage-collection. // gc performs garbage-collection.
// //
// must be called with .gcMu locked. // must be called with .gcMu locked.
func (c *Cache) gc() { func (c *Cache) gc() {
traceCacheGCStart(c)
defer traceCacheGCFinish(c)
//fmt.Printf("\n> gc\n") //fmt.Printf("\n> gc\n")
//defer fmt.Printf("< gc\n") //defer fmt.Printf("< gc\n")
......
...@@ -31,9 +31,6 @@ import ( ...@@ -31,9 +31,6 @@ import (
"testing" "testing"
"github.com/kylelemons/godebug/pretty" "github.com/kylelemons/godebug/pretty"
"lab.nexedi.com/kirr/go123/tracing"
"lab.nexedi.com/kirr/neo/go/xcommon/xtesting"
) )
// tStorage implements read-only storage for cache testing // tStorage implements read-only storage for cache testing
...@@ -103,21 +100,6 @@ func xidat(oid Oid, tid Tid) Xid { ...@@ -103,21 +100,6 @@ func xidat(oid Oid, tid Tid) Xid {
return Xid{Oid: oid, At: tid} return Xid{Oid: oid, At: tid}
} }
// tracer which collects tracing events from all needed-for-tests sources
type tTracer struct {
*xtesting.SyncTracer
}
type evCacheGCStart struct {
c *Cache
}
func (t *tTracer) traceCacheGCStart(c *Cache) { t.Trace1(&evCacheGCStart{c}) }
type evCacheGCFinish struct {
c *Cache
}
func (t *tTracer) traceCacheGCFinish(c *Cache) { t.Trace1(&evCacheGCFinish{c}) }
func TestCache(t *testing.T) { func TestCache(t *testing.T) {
// XXX hack; place=ok? // XXX hack; place=ok?
pretty.CompareConfig.PrintStringers = true pretty.CompareConfig.PrintStringers = true
...@@ -513,29 +495,11 @@ func TestCache(t *testing.T) { ...@@ -513,29 +495,11 @@ func TestCache(t *testing.T) {
// ---- verify LRU eviction ---- // ---- verify LRU eviction ----
// (attach to Cache GC tracepoints)
tracer := &tTracer{xtesting.NewSyncTracer()}
pg := &tracing.ProbeGroup{}
//defer pg.Done()
tracing.Lock()
traceCacheGCStart_Attach(pg, tracer.traceCacheGCStart)
traceCacheGCFinish_Attach(pg, tracer.traceCacheGCFinish)
tracing.Unlock()
// trace-checker for the events
tc := xtesting.NewTraceChecker(t, tracer.SyncTracer)
gcstart := &evCacheGCStart{c}
gcfinish := &evCacheGCFinish{c}
checkOIDV(1) checkOIDV(1)
checkOCE(1, rce1_h3, rce1_h6, rce1_h7, rce1_h8, rce1_h9, rce1_h15, rce1_h19, rce1_h21) checkOCE(1, rce1_h3, rce1_h6, rce1_h7, rce1_h8, rce1_h9, rce1_h15, rce1_h19, rce1_h21)
checkMRU(17, rce1_h15, rce1_h6, rce1_h8, rce1_h21, rce1_h19, rce1_h9, rce1_h7, rce1_h3) checkMRU(17, rce1_h15, rce1_h6, rce1_h8, rce1_h21, rce1_h19, rce1_h9, rce1_h7, rce1_h3)
go c.SetSizeMax(16) // < c.size by 1 -> should trigger gc c.SetSizeMax(16) // < c.size by 1 -> should trigger gc
tc.Expect(gcstart, gcfinish)
// evicted: // evicted:
// - 3] (lru.1, nodata, size=0) XXX ok to evict nodata & friends? // - 3] (lru.1, nodata, size=0) XXX ok to evict nodata & friends?
...@@ -547,8 +511,7 @@ func TestCache(t *testing.T) { ...@@ -547,8 +511,7 @@ func TestCache(t *testing.T) {
checkMRU(15, rce1_h15, rce1_h6, rce1_h8, rce1_h21) checkMRU(15, rce1_h15, rce1_h6, rce1_h8, rce1_h21)
// reload 19] -> 21] should be evicted // reload 19] -> 21] should be evicted
go c.Load(ctx, xidat(1,19)) c.Load(ctx, xidat(1,19))
tc.Expect(gcstart, gcfinish)
// - evicted 21] (lru.1, www, size=3) // - evicted 21] (lru.1, www, size=3)
// - loaded 19] (zz, size=2) // - loaded 19] (zz, size=2)
...@@ -561,8 +524,7 @@ func TestCache(t *testing.T) { ...@@ -561,8 +524,7 @@ func TestCache(t *testing.T) {
checkMRU(14, rce1_h19_2, rce1_h15, rce1_h6, rce1_h8) checkMRU(14, rce1_h19_2, rce1_h15, rce1_h6, rce1_h8)
// load big 77] -> several rce must be evicted // load big 77] -> several rce must be evicted
go c.Load(ctx, xidat(1,77)) c.Load(ctx, xidat(1,77))
tc.Expect(gcstart, gcfinish)
// - evicted 8] (lru.1, ioerr, size=0) // - evicted 8] (lru.1, ioerr, size=0)
// - evicted 6] (lru.2, hello, size=5) // - evicted 6] (lru.2, hello, size=5)
...@@ -576,16 +538,14 @@ func TestCache(t *testing.T) { ...@@ -576,16 +538,14 @@ func TestCache(t *testing.T) {
checkMRU(12, rce1_h77, rce1_h19_2) checkMRU(12, rce1_h77, rce1_h19_2)
// sizeMax=0 evicts everything from cache // sizeMax=0 evicts everything from cache
go c.SetSizeMax(0) c.SetSizeMax(0)
tc.Expect(gcstart, gcfinish)
checkOIDV() checkOIDV()
checkMRU(0) checkMRU(0)
// and still loading works (because even if though rce's are evicted // and still loading works (because even if though rce's are evicted
// they stay live while someone user waits and uses it) // they stay live while someone user waits and uses it)
go checkLoad(xidat(1,4), b(hello), 4, nil) checkLoad(xidat(1,4), b(hello), 4, nil)
tc.Expect(gcstart, gcfinish)
checkOIDV() checkOIDV()
checkMRU(0) checkMRU(0)
...@@ -614,7 +574,6 @@ func TestCache(t *testing.T) { ...@@ -614,7 +574,6 @@ func TestCache(t *testing.T) {
// it is hard to check this via stable tracepoints because, if done so, // it is hard to check this via stable tracepoints because, if done so,
// after the problem is fixed the test will deadlock. // after the problem is fixed the test will deadlock.
// So test it probabilistically instead. // So test it probabilistically instead.
pg.Done()
c.SetSizeMax(0) // we want to GC to be constantly running c.SetSizeMax(0) // we want to GC to be constantly running
for i := 0; i < 1e4; i++ { for i := 0; i < 1e4; i++ {
// issue Prefetch: this should create RCE and spawn loadRCE for it // issue Prefetch: this should create RCE and spawn loadRCE for it
......
// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
package zodb
// code generated for tracepoints
import (
"lab.nexedi.com/kirr/go123/tracing"
"unsafe"
)
// traceevent: traceCacheGCFinish(c *Cache)
type _t_traceCacheGCFinish struct {
tracing.Probe
probefunc func(c *Cache)
}
var _traceCacheGCFinish *_t_traceCacheGCFinish
func traceCacheGCFinish(c *Cache) {
if _traceCacheGCFinish != nil {
_traceCacheGCFinish_run(c)
}
}
func _traceCacheGCFinish_run(c *Cache) {
for p := _traceCacheGCFinish; p != nil; p = (*_t_traceCacheGCFinish)(unsafe.Pointer(p.Next())) {
p.probefunc(c)
}
}
func traceCacheGCFinish_Attach(pg *tracing.ProbeGroup, probe func(c *Cache)) *tracing.Probe {
p := _t_traceCacheGCFinish{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceCacheGCFinish)), &p.Probe)
return &p.Probe
}
// traceevent: traceCacheGCStart(c *Cache)
type _t_traceCacheGCStart struct {
tracing.Probe
probefunc func(c *Cache)
}
var _traceCacheGCStart *_t_traceCacheGCStart
func traceCacheGCStart(c *Cache) {
if _traceCacheGCStart != nil {
_traceCacheGCStart_run(c)
}
}
func _traceCacheGCStart_run(c *Cache) {
for p := _traceCacheGCStart; p != nil; p = (*_t_traceCacheGCStart)(unsafe.Pointer(p.Next())) {
p.probefunc(c)
}
}
func traceCacheGCStart_Attach(pg *tracing.ProbeGroup, probe func(c *Cache)) *tracing.Probe {
p := _t_traceCacheGCStart{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceCacheGCStart)), &p.Probe)
return &p.Probe
}
// trace export signature
func _trace_exporthash_6392b85af001a55df3eb1603d80173377a81fc9a() {}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment