comparison tests/test-tags.t @ 25402:0c2ded041d10

exchange: support transferring .hgtags fnodes mapping On Mozilla's mozilla-beta repository .hgtags fnodes resolution takes ~18s from a clean cache on my machine. This means that the first time a user runs `hg tags`, `hg log`, or any other command that displays or accesses tags data, a ~18s pause will occur. There is no output during this pause. This results in a poor user experience and perception that Mercurial is slow. The .hgtags changeset to filenode mapping is deterministic. This patch takes advantage of that property by implementing support for transferring .hgtags filenodes mappings in a dedicated bundle2 part. When a client advertising support for the "hgtagsfnodes" capability requests a bundle, a mapping of changesets to .hgtags filenodes will be sent to the client. Only mappings of head changesets included in the bundle will be sent. The transfer of this mapping effectively eliminates one time tags cache related pauses after initial clone. The mappings are sent as binary data. So, 40 bytes per pair of SHA-1s. On the aforementioned mozilla-beta repository, 659 * 40 = 26,360 raw bytes of mappings are sent over the wire (in addition to the bundle part headers). Assuming 18s to populate the cache, we only need to transfer this extra data faster than 1.5 KB/s for overall clone + tags cache population time to be shorter. Put into perspective, the mozilla-beta repository is ~1 GB in size. So, this additional data constitutes <0.01% of the cloned data. The marginal overhead for a multi-second performance win on clones in my opinion justifies an on-by-default behavior.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 25 May 2015 17:14:11 -0700
parents 61aea11fb83d
children 3b1fc40626d8
comparison
equal deleted inserted replaced
25401:d29201352af7 25402:0c2ded041d10
623 localtag2 1:a0b6fe111088 623 localtag2 1:a0b6fe111088
624 localtag 1:a0b6fe111088 624 localtag 1:a0b6fe111088
625 globaltag 0:bbd179dfa0a7 625 globaltag 0:bbd179dfa0a7
626 626
627 $ cd .. 627 $ cd ..
628
629 Create a repository with tags data to test .hgtags fnodes transfer
630
631 $ hg init tagsserver
632 $ cd tagsserver
633 $ cat > .hg/hgrc << EOF
634 > [experimental]
635 > bundle2-exp=True
636 > EOF
637 $ touch foo
638 $ hg -q commit -A -m initial
639 $ hg tag -m 'tag 0.1' 0.1
640 $ echo second > foo
641 $ hg commit -m second
642 $ hg tag -m 'tag 0.2' 0.2
643 $ hg tags
644 tip 3:40f0358cb314
645 0.2 2:f63cc8fe54e4
646 0.1 0:96ee1d7354c4
647 $ cd ..
648
649 Cloning should pull down hgtags fnodes mappings and write the cache file
650
651 $ hg --config experimental.bundle2-exp=True clone --pull tagsserver tagsclient
652 requesting all changes
653 adding changesets
654 adding manifests
655 adding file changes
656 added 4 changesets with 4 changes to 2 files
657 updating to branch default
658 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
659
660 Missing tags2* files means the cache wasn't written through the normal mechanism.
661
662 $ ls tagsclient/.hg/cache
663 branch2-served
664 hgtagsfnodes1
665 rbc-names-v1
666 rbc-revs-v1
667
668 Cache should contain the head only, even though other nodes have tags data
669
670 $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1
671 tagsclient/.hg/cache/hgtagsfnodes1: size=96
672 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
673 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
674 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
675 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
676 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....|
677 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.|
678
679 Running hg tags should produce tags2* file and not change cache
680
681 $ hg -R tagsclient tags
682 tip 3:40f0358cb314
683 0.2 2:f63cc8fe54e4
684 0.1 0:96ee1d7354c4
685
686 $ ls tagsclient/.hg/cache
687 branch2-served
688 hgtagsfnodes1
689 rbc-names-v1
690 rbc-revs-v1
691 tags2-visible
692
693 $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1
694 tagsclient/.hg/cache/hgtagsfnodes1: size=96
695 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
696 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
697 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
698 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
699 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....|
700 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.|
701