tests/test-glog-topological.t
author Gregory Szorc <gregory.szorc@gmail.com>
Sun, 06 Dec 2015 19:04:10 -0800
changeset 27371 45d996a566d7
parent 23569 3ecbcffdeb0c
child 28627 d7af9b4ae7dd
permissions -rw-r--r--
util: reimplement lrucachedict As part of attempting to more aggressively use the existing lrucachedict, collections.deque operations were frequently showing up in profiling output, negating benefits of caching. Searching the internet seems to tell me that the most efficient way to implement an LRU cache in Python is to have a dict indexing the cached entries and then to use a doubly linked list to track freshness of each entry. So, this patch replaces our existing lrucachedict with a version using such a pattern. The recently introduced perflrucachedict command reveals the following timings for 10,000 operations for the following cache sizes for the existing cache: n=4 init=0.004079 gets=0.003632 sets=0.005188 mixed=0.005402 n=8 init=0.004045 gets=0.003998 sets=0.005064 mixed=0.005328 n=16 init=0.004011 gets=0.004496 sets=0.005021 mixed=0.005555 n=32 init=0.004064 gets=0.005611 sets=0.005188 mixed=0.006189 n=64 init=0.003975 gets=0.007684 sets=0.005178 mixed=0.007245 n=128 init=0.004121 gets=0.012005 sets=0.005422 mixed=0.009471 n=256 init=0.004143 gets=0.020295 sets=0.005227 mixed=0.013612 n=512 init=0.004039 gets=0.036703 sets=0.005243 mixed=0.020685 n=1024 init=0.004193 gets=0.068142 sets=0.005251 mixed=0.033064 n=2048 init=0.004070 gets=0.133383 sets=0.005160 mixed=0.050359 n=4096 init=0.004053 gets=0.265194 sets=0.004868 mixed=0.048352 n=8192 init=0.004087 gets=0.542218 sets=0.004562 mixed=0.032753 n=16384 init=0.004106 gets=1.064055 sets=0.004179 mixed=0.020367 n=32768 init=0.004034 gets=2.097620 sets=0.004260 mixed=0.013031 n=65536 init=0.004108 gets=4.106390 sets=0.004268 mixed=0.010191 As the data shows, the existing cache's retrieval performance diminishes linearly with cache size. (Keep in mind the microbenchmark is testing 100% cache hit rate.) The new cache implementation reveals the following: n=4 init=0.006665 gets=0.006541 sets=0.005733 mixed=0.006876 n=8 init=0.006649 gets=0.006374 sets=0.005663 mixed=0.006899 n=16 init=0.006570 gets=0.006504 sets=0.005799 mixed=0.007057 n=32 init=0.006854 gets=0.006459 sets=0.005747 mixed=0.007034 n=64 init=0.006580 gets=0.006495 sets=0.005740 mixed=0.006992 n=128 init=0.006534 gets=0.006739 sets=0.005648 mixed=0.007124 n=256 init=0.006669 gets=0.006773 sets=0.005824 mixed=0.007151 n=512 init=0.006701 gets=0.007061 sets=0.006042 mixed=0.007372 n=1024 init=0.006641 gets=0.007620 sets=0.006387 mixed=0.007464 n=2048 init=0.006517 gets=0.008598 sets=0.006871 mixed=0.008077 n=4096 init=0.006720 gets=0.010933 sets=0.007854 mixed=0.008663 n=8192 init=0.007383 gets=0.015969 sets=0.010288 mixed=0.008896 n=16384 init=0.006660 gets=0.025447 sets=0.011208 mixed=0.008826 n=32768 init=0.006658 gets=0.044390 sets=0.011192 mixed=0.008943 n=65536 init=0.006836 gets=0.082736 sets=0.011151 mixed=0.008826 Let's go through the results. The new cache takes longer to construct. ~6.6ms vs ~4.1ms. However, this is measuring 10,000 __init__ calls, so the difference is ~0.2us/instance. We currently only create lrucachedict for manifest instances, so this regression is not likely relevant. The new cache is slightly slower for retrievals for cache sizes < 1024. It's worth noting that the only existing use of lurcachedict is in manifest.py and the default cache size is 4. This regression is worrisome. However, for n=4, the delta is ~2.9s for 10,000 lookups, or ~0.29us/op. Again, this is a marginal regression and likely not relevant in the real world. Timing `hg log -p -l 100` for mozilla-central reveals that cache lookup times are dominated by decompression and fulltext resolution (even with lz4 manifests). The new cache is significantly faster for retrievals at larger capacities. Whereas the old implementation has retrieval performance linear with cache capacity, the new cache is constant time until much larger values. And, when it does start to increase significantly, it is a few magnitudes faster than the current cache. The new cache does appear to be slower for sets when capacity is large. However, performance is similar for smaller capacities. Of course, caches should generally be optimized for retrieval performance because if a cache is getting more sets than gets, it doesn't really make sense to cache. If this regression is worrisome, again, taking the largest regression at n=65536 of ~6.9ms for 10,000 results in a regression of ~0.68us/op. This is not significant in the grand scheme of things. Overall, the new cache is performant at retrievals at much larger capacity values which makes it a generally more useful cache backend. While there are regressions, their absolute value is extremely small. Since we aren't using lrucachedict aggressively today, these regressions should not be relevant. The improved scalability of lrucachedict should enable us to more aggressively utilize lrucachedict for more granular caching (read: higher capacity caches) in the near future. The impetus for this patch is to establish a cache of decompressed revlog revisions, notably manifest revisions. And since delta chains can grow to >10,000 and cache hit rate can be high, the improved retrieval performance of lrucachedict should be relevant.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23565
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     1
This test file aims at test topological iteration and the various configuration it can has.
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     2
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     3
  $ cat >> $HGRCPATH << EOF
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     4
  > [ui]
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     5
  > logtemplate={rev}\n
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     6
  > EOF
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     7
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     8
On this simple example, all topological branch are displayed in turn until we
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     9
can finally display 0. this implies skipping from 8 to 3 and coming back to 7
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    10
later.
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    11
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    12
  $ hg init test01
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    13
  $ cd test01
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    14
  $ hg unbundle $TESTDIR/bundles/remote.hg
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    15
  adding changesets
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    16
  adding manifests
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    17
  adding file changes
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    18
  added 9 changesets with 7 changes to 4 files (+1 heads)
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    19
  (run 'hg heads' to see heads, 'hg merge' to merge)
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    20
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    21
  $ hg log -G
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    22
  o  8
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    23
  |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    24
  | o  7
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    25
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    26
  | o  6
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    27
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    28
  | o  5
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    29
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    30
  | o  4
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    31
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    32
  o |  3
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    33
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    34
  o |  2
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    35
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    36
  o |  1
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    37
  |/
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    38
  o  0
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    39
  
23567
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    40
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    41
(display all nodes)
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    42
23569
3ecbcffdeb0c graphmod: rename graph-topological config to graph-group-branches
Augie Fackler <raf@durin42.com>
parents: 23568
diff changeset
    43
  $ hg --config experimental.graph-group-branches=1 log -G
23565
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    44
  o  8
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    45
  |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    46
  o  3
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    47
  |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    48
  o  2
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    49
  |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    50
  o  1
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    51
  |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    52
  | o  7
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    53
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    54
  | o  6
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    55
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    56
  | o  5
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    57
  | |
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    58
  | o  4
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    59
  |/
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    60
  o  0
996c01bfbec4 graphlog: add a way to test the 'groupbranchiter' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    61
  
23567
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    62
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    63
(revset skipping nodes)
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    64
23569
3ecbcffdeb0c graphmod: rename graph-topological config to graph-group-branches
Augie Fackler <raf@durin42.com>
parents: 23568
diff changeset
    65
  $ hg --config experimental.graph-group-branches=1 log -G --rev 'not (2+6)'
23567
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    66
  o  8
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    67
  |
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    68
  o  3
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    69
  |
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    70
  o  1
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    71
  |
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    72
  | o  7
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    73
  | |
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    74
  | o  5
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    75
  | |
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    76
  | o  4
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    77
  |/
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    78
  o  0
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    79
  
1f080c9c6a35 groupbranchiter: support for non-contiguous revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23565
diff changeset
    80
23568
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    81
(begin) from the other branch
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    82
23569
3ecbcffdeb0c graphmod: rename graph-topological config to graph-group-branches
Augie Fackler <raf@durin42.com>
parents: 23568
diff changeset
    83
  $ hg --config experimental.graph-group-branches=1 --config experimental.graph-group-branches.firstbranch=5 log -G
23568
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    84
  o  7
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    85
  |
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    86
  o  6
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    87
  |
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    88
  o  5
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    89
  |
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    90
  o  4
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    91
  |
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    92
  | o  8
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    93
  | |
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    94
  | o  3
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    95
  | |
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    96
  | o  2
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    97
  | |
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    98
  | o  1
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
    99
  |/
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
   100
  o  0
740ae54573a3 groupbranchiter: allow callers to select the first branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 23567
diff changeset
   101