tests/test-stack.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sat, 13 Apr 2024 23:40:28 +0200
changeset 51592 24844407fa0d
parent 37004 68fcc5503ec5
permissions -rw-r--r--
perf: clear vfs audit_cache before each run When generating a stream clone, we spend a large amount of time auditing path. Before this changes, the first run was warming the vfs cache for the other runs, leading to a large runtime difference and a "faulty" reported timing for the operation. We now clear this important cache between run to get a more realistic timing. Below are some example of median time change when clearing these cases. The maximum time for a run did not changed significantly. ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # benchmark.name = hg.perf.exchange.stream.generate # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.version = latest no-clearing: 17.289905 cache-clearing: 21.587965 (+24.86%, +4.30) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog no-clearing: 32.670748 cache-clearing: 40.467095 (+23.86%, +7.80) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog no-clearing: 37.838858 cache-clearing: 46.072749 (+21.76%, +8.23) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog no-clearing: 32.969395 cache-clearing: 39.646209 (+20.25%, +6.68) In addition, this significantly reduce the timing difference between the performance command, from the perf extensions and a `real `hg bundle` call producing a stream bundle. Some significant differences remain especially on the "mozilla-try" repositories, but they are now smaller. Note that some of that difference will actually not be attributable to the stream generation (like maybe phases or branch map computation). Below are some benchmarks done on a currently draft changeset fixing some unrelated slowness in `hg bundle` (34a78972af409d1ff37c29e60f6ca811ad1a457d) ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default hg.perf.exchange.stream.generate: 21.587965 hg.command.bundle: 24.301799 (+12.57%, +2.71) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 40.467095 hg.command.bundle: 44.831317 (+10.78%, +4.36) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 39.646209 hg.command.bundle: 45.395258 (+14.50%, +5.75) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog hg.perf.exchange.stream.generate: 46.072749 hg.command.bundle: 55.882608 (+21.29%, +9.81) ## data-env-vars.name = mozilla-try-2023-03-22-zlib-general-delta hg.perf.exchange.stream.generate: 334.716708 hg.command.bundle: 377.856767 (+12.89%, +43.14) ## data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 302.972301 hg.command.bundle: 326.098755 (+7.63%, +23.13)


This test test the low-level definition of stack, agnostic from all formatting

Initial setup

  $ cat << EOF >> $HGRCPATH
  > [ui]
  > logtemplate = {rev} {branch} {phase} {desc|firstline}\n
  > [extensions]
  > rebase=
  > [experimental]
  > evolution=createmarkers,exchange,allowunstable
  > EOF

  $ hg init main
  $ cd main
  $ hg branch other
  marked working directory as branch other
  (branches are permanent and global, did you want a bookmark?)
  $ echo aaa > aaa
  $ hg add aaa
  $ hg commit -m c_a
  $ echo aaa > bbb
  $ hg add bbb
  $ hg commit -m c_b
  $ hg branch foo
  marked working directory as branch foo
  $ echo aaa > ccc
  $ hg add ccc
  $ hg commit -m c_c
  $ echo aaa > ddd
  $ hg add ddd
  $ hg commit -m c_d
  $ echo aaa > eee
  $ hg add eee
  $ hg commit -m c_e
  $ echo aaa > fff
  $ hg add fff
  $ hg commit -m c_f
  $ hg log -G
  @  5 foo draft c_f
  |
  o  4 foo draft c_e
  |
  o  3 foo draft c_d
  |
  o  2 foo draft c_c
  |
  o  1 other draft c_b
  |
  o  0 other draft c_a
  

Check that stack doesn't include public changesets
--------------------------------------------------

  $ hg up other
  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
  $ hg log -G -r "stack()"
  @  1 other draft c_b
  |
  o  0 other draft c_a
  
  $ hg phase --public 'branch("other")'
  $ hg log -G -r "stack()"
  $ hg up foo
  4 files updated, 0 files merged, 0 files removed, 0 files unresolved

Simple test
-----------

'stack()' list all changeset in the branch

  $ hg branch
  foo
  $ hg log -G -r "stack()"
  @  5 foo draft c_f
  |
  o  4 foo draft c_e
  |
  o  3 foo draft c_d
  |
  o  2 foo draft c_c
  |
  ~

Case with some of the branch unstable
------------------------------------

  $ hg up 3
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ echo bbb > ddd
  $ hg commit --amend
  2 new orphan changesets
  $ hg log -G
  @  6 foo draft c_d
  |
  | *  5 foo draft c_f
  | |
  | *  4 foo draft c_e
  | |
  | x  3 foo draft c_d
  |/
  o  2 foo draft c_c
  |
  o  1 other public c_b
  |
  o  0 other public c_a
  
  $ hg log -G -r "stack()"
  @  6 foo draft c_d
  |
  ~
  $ hg up -r "desc(c_e)"
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg log -G -r "stack()"
  @  4 foo draft c_e
  |
  x  3 foo draft c_d
  |
  ~
  $ hg up -r "desc(c_d)"
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved

  $ hg log -G -r "stack()"
  @  6 foo draft c_d
  |
  ~

Case with multiple topological heads
------------------------------------

Make things linear again

  $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()'
  rebasing 4:4f2a69f6d380 "c_e"
  rebasing 5:913c298d8b0a "c_f"
  $ hg log -G
  o  8 foo draft c_f
  |
  o  7 foo draft c_e
  |
  @  6 foo draft c_d
  |
  o  2 foo draft c_c
  |
  o  1 other public c_b
  |
  o  0 other public c_a
  

Create the second branch

  $ hg up 'desc(c_d)'
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo aaa > ggg
  $ hg add ggg
  $ hg commit -m c_g
  created new head
  $ echo aaa > hhh
  $ hg add hhh
  $ hg commit -m c_h
  $ hg log -G
  @  10 foo draft c_h
  |
  o  9 foo draft c_g
  |
  | o  8 foo draft c_f
  | |
  | o  7 foo draft c_e
  |/
  o  6 foo draft c_d
  |
  o  2 foo draft c_c
  |
  o  1 other public c_b
  |
  o  0 other public c_a
  

Test output

  $ hg log -G -r "stack(10)"
  @  10 foo draft c_h
  |
  o  9 foo draft c_g
  |
  ~
  $ hg log -G -r "stack(8)"
  o  8 foo draft c_f
  |
  o  7 foo draft c_e
  |
  ~
  $ hg log -G -r "stack(head())"
  @  10 foo draft c_h
  |
  o  9 foo draft c_g
  |
  ~
  o  8 foo draft c_f
  |
  o  7 foo draft c_e
  |
  ~
Check the stack order
  $ hg log -r "first(stack())"
  9 foo draft c_g
  $ hg log -r "first(stack(10))"
  9 foo draft c_g
  $ hg log -r "first(stack(8))"
  7 foo draft c_e
  $ hg log -r "first(stack(head()))"
  7 foo draft c_e

Case with multiple heads with unstability involved
--------------------------------------------------

We amend the message to make sure the display base pick the right changeset

  $ hg up 'desc(c_d)'
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ echo ccc > ddd
  $ hg commit --amend -m 'c_D'
  4 new orphan changesets
  $ hg rebase -d . -s 'desc(c_g)'
  rebasing 9:2ebb6e48ab8a "c_g"
  rebasing 10:634f38e27a1d "c_h"
  $ hg log -G
  o  13 foo draft c_h
  |
  o  12 foo draft c_g
  |
  @  11 foo draft c_D
  |
  | *  8 foo draft c_f
  | |
  | *  7 foo draft c_e
  | |
  | x  6 foo draft c_d
  |/
  o  2 foo draft c_c
  |
  o  1 other public c_b
  |
  o  0 other public c_a
  

We should improve stack definition to also show 12 and 13 here
  $ hg log -G -r "stack()"
  @  11 foo draft c_D
  |
  ~