annotate test/org/tmatesoft/hg/test/MapTagsToFileRevisions.java @ 324:283b294d1079

Explore alternatives to access file-changelog combined history
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 03 Oct 2011 06:47:20 +0200
parents b9592e21176a
children d42a45a2c9d6
rev   line source
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 package org.tmatesoft.hg.test;
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2
324
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
3 import static org.tmatesoft.hg.repo.HgRepository.TIP;
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
4
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
5 import java.io.File;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
6 import java.util.ArrayList;
256
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
7 import java.util.Arrays;
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
8 import java.util.HashMap;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
9 import java.util.LinkedList;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
10 import java.util.List;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
11 import java.util.Map;
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12
324
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
13 import org.junit.Assert;
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
14 import org.tmatesoft.hg.core.HgBadStateException;
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
15 import org.tmatesoft.hg.core.HgChangeset;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
16 import org.tmatesoft.hg.core.HgChangesetHandler;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
17 import org.tmatesoft.hg.core.HgException;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
18 import org.tmatesoft.hg.core.HgLogCommand;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
19 import org.tmatesoft.hg.core.Nodeid;
307
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
20 import org.tmatesoft.hg.internal.ArrayHelper;
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
21 import org.tmatesoft.hg.repo.HgChangelog;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
22 import org.tmatesoft.hg.repo.HgDataFile;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
23 import org.tmatesoft.hg.repo.HgLookup;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
24 import org.tmatesoft.hg.repo.HgManifest;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
25 import org.tmatesoft.hg.repo.HgRepository;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
26 import org.tmatesoft.hg.repo.HgTags;
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
27 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
28 import org.tmatesoft.hg.repo.HgManifest.Flags;
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import org.tmatesoft.hg.repo.HgTags.TagInfo;
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
30 import org.tmatesoft.hg.util.CancelledException;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
31 import org.tmatesoft.hg.util.Path;
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 /**
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 * @author Marc Strapetz
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 */
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 public class MapTagsToFileRevisions {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 // Static =================================================================
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
40 public static void main(String[] args) throws Exception {
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
41 MapTagsToFileRevisions m = new MapTagsToFileRevisions();
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
42 System.out.printf("Free mem: %,d\n", Runtime.getRuntime().freeMemory());
304
85b8efde5586 Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
43 // m.collectTagsPerFile();
307
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
44 // m.manifestWalk();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
45 // m.changelogWalk();
324
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
46 // m.revisionMap();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
47 m.buildFile2ChangelogRevisionMap();
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
48 m = null;
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
49 System.gc();
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
50 System.out.printf("Free mem: %,d\n", Runtime.getRuntime().freeMemory());
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
51 }
324
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
52
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
53 /*
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
54 * .hgtags, 261 revisions
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
55 * Approach 1: total 83, init: 0, iteration: 82
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
56 * Approach 2: total 225, init: 206, iteration: 19
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
57 * README, 465 revisions
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
58 * Approach 1: total 162, init: 0, iteration: 161
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
59 * Approach 2: total 231, init: 198, iteration: 32
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
60 * configure.in, 1109 revisions
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
61 * Approach 1: total 409, init: 1, iteration: 407
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
62 * Approach 2: total 277, init: 203, iteration: 74
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
63 */
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
64 private void buildFile2ChangelogRevisionMap() throws Exception {
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
65 final HgRepository repository = new HgLookup().detect(new File("/temp/hg/cpython"));
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
66 final HgChangelog clog = repository.getChangelog();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
67 final HgDataFile fileNode = repository.getFileNode("configure.in");
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
68 // warm-up
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
69 HgChangelog.RevisionMap clogMap = clog.new RevisionMap().init();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
70 HgDataFile.RevisionMap fileMap = fileNode.new RevisionMap().init();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
71 //
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
72 final int latestRevision = fileNode.getLastRevision();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
73 //
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
74 final long start_1 = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
75 fileMap = fileNode.new RevisionMap().init();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
76 final long start_1a = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
77 final Map<Nodeid, Nodeid> changesetToNodeid_1 = new HashMap<Nodeid, Nodeid>();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
78 for (int revision = 0; revision <= latestRevision; revision++) {
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
79 final Nodeid nodeId = fileMap.revision(revision);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
80 // final Nodeid changesetId = fileNode.getChangesetRevision(nodeId);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
81 int localCset = fileNode.getChangesetLocalRevision(revision);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
82 final Nodeid changesetId = clog.getRevision(localCset);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
83 changesetToNodeid_1.put(changesetId, nodeId);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
84 }
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
85 final long end_1 = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
86 //
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
87 final long start_2 = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
88 clogMap = clog.new RevisionMap().init();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
89 fileMap = fileNode.new RevisionMap().init();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
90 final Map<Nodeid, Nodeid> changesetToNodeid_2 = new HashMap<Nodeid, Nodeid>();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
91 final long start_2a = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
92 for (int revision = 0; revision <= latestRevision; revision++) {
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
93 Nodeid nidFile = fileMap.revision(revision);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
94 int localCset = fileNode.getChangesetLocalRevision(revision);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
95 Nodeid nidCset = clogMap.revision(localCset);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
96 changesetToNodeid_2.put(nidCset, nidFile);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
97 }
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
98 final long end_2 = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
99 Assert.assertEquals(changesetToNodeid_1, changesetToNodeid_2);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
100 //
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
101 final long start_3 = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
102 final Map<Nodeid, Nodeid> changesetToNodeid_3 = new HashMap<Nodeid, Nodeid>();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
103 fileNode.walk(0, TIP, new HgDataFile.RevisionInspector() {
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
104
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
105 public void next(int localRevision, Nodeid revision, int linkedRevision) {
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
106 changesetToNodeid_3.put(clog.getRevision(linkedRevision), revision);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
107 }
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
108 });
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
109 final long end_3 = System.nanoTime();
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
110 Assert.assertEquals(changesetToNodeid_1, changesetToNodeid_3);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
111 System.out.printf("Approach 1: total %d, init: %d, iteration: %d\n", (end_1 - start_1)/1000000, (start_1a - start_1)/1000000, (end_1 - start_1a)/1000000);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
112 System.out.printf("Approach 2: total %d, init: %d, iteration: %d\n", (end_2 - start_2)/1000000, (start_2a - start_2)/1000000, (end_2 - start_2a)/1000000);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
113 System.out.printf("Approach 3: total %d\n", (end_3 - start_3)/1000000);
283b294d1079 Explore alternatives to access file-changelog combined history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 311
diff changeset
114 }
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
115
307
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
116 /*
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
117 * Each 5000 revisions from cpython, total 15 revisions
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
118 * Direct clog.getLocalRevision: ~260 ms
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
119 * RevisionMap.localRevision: ~265 ms (almost 100% in #init())
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
120 * each 1000'th revision, total 71 revision: 1 230 vs 270
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
121 * each 2000'th revision, total 36 revision: 620 vs 270
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
122 * each 3000'th revision, total 24 revision: 410 vs 275
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
123 */
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
124 private void revisionMap() throws Exception {
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
125 final HgRepository repository = new HgLookup().detect(new File("/temp/hg/cpython"));
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
126 final HgChangelog clog = repository.getChangelog();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
127 ArrayList<Nodeid> revisions = new ArrayList<Nodeid>();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
128 final int step = 5000;
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
129 for (int i = 0, top = clog.getLastRevision(); i < top; i += step) {
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
130 revisions.add(clog.getRevision(i));
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
131 }
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
132 final long s1 = System.nanoTime();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
133 for (Nodeid n : revisions) {
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
134 int r = clog.getLocalRevision(n);
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
135 if (r % step != 0) {
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
136 throw new IllegalStateException(Integer.toString(r));
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
137 }
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
138 }
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
139 System.out.printf("Direct lookup of %d revisions took %,d ns\n", revisions.size(), System.nanoTime() - s1);
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
140 HgChangelog.RevisionMap rmap = clog.new RevisionMap();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
141 final long s2 = System.nanoTime();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
142 rmap.init();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
143 final long s3 = System.nanoTime();
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
144 for (Nodeid n : revisions) {
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
145 int r = rmap.localRevision(n);
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
146 if (r % step != 0) {
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
147 throw new IllegalStateException(Integer.toString(r));
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
148 }
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
149 }
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
150 System.out.printf("RevisionMap time: %d ms, of that init() %,d ns\n", (System.nanoTime() - s2) / 1000000, s3 - s2);
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
151 }
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
152
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
153 private void changelogWalk() throws Exception {
307
2f2ab5c27f41 Collect sort reverse indexes along with array sorting
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
154 final HgRepository repository = new HgLookup().detect(new File("/temp/hg/cpython"));
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
155 final long start = System.currentTimeMillis();
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
156 repository.getChangelog().all(new HgChangelog.Inspector() {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
157 public int xx = 0;
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
158
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
159 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
160 if (xx+revisionNumber < 0) {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
161 System.out.println(xx);
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
162 System.out.println(revisionNumber);
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
163 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
164 xx += revisionNumber;
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
165 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
166 });
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
167 // cpython: 17 seconds, mem 132,9 -> 129,0 -> 131,7
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
168 // cpyhton: 13 seconds. Of that, cumulative Patch.apply takes 8.8 seconds, RevlogStream.Inspector.next - 1.8
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
169 System.out.printf("Total time: %d ms\n", System.currentTimeMillis() - start);
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
170 System.out.printf("Free mem: %,d\n", Runtime.getRuntime().freeMemory());
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
171 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
172
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
173 private void manifestWalk() throws Exception {
268
c5980f287cc4 Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
174 System.out.println(System.getProperty("java.version"));
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
175 final long start = System.currentTimeMillis();
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
176 final HgRepository repository = new HgLookup().detect(new File("/temp/hg/cpython"));
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
177 repository.getManifest().walk(0, 10000, new HgManifest.Inspector2() {
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
178 public boolean begin(int mainfestRevision, Nodeid nid, int changelogRevision) {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
179 return true;
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
180 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
181 public boolean next(Nodeid nid, String fname, String flags) {
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
182 throw new HgBadStateException(HgManifest.Inspector2.class.getName());
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
183 }
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
184 public boolean next(Nodeid nid, Path fname, Flags flags) {
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
185 return true;
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
186 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
187 public boolean end(int manifestRevision) {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
188 return true;
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
189 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
190 });
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
191 // cpython: 1,1 sec for 0..1000, 43 sec for 0..10000, 115 sec for 0..20000 (Pool with HashMap)
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
192 // 2,4 sec for 1000..2000
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
193 // cpython -r 1000: 484 files, -r 2000: 1015 files. Iteration 1000..2000; fnamePool.size:1019 nodeidPool.size:2989
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
194 // nodeidPool for two subsequent revisions only: 840. 37 sec for 0..10000. 99 sec for 0..20k
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
195 // 0..10000 fnamePool: hits:15989152, misses:3020
268
c5980f287cc4 Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
196 //
c5980f287cc4 Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
197 // With Pool<StringProxy> for fname and flags, Nodeid's ascii2bin through local array, overall byte[] iteration,
c5980f287cc4 Use StringProxy when parsing manifest to minimize number of useless conversions and array instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
198 // 0..10k is 34 seconds now
304
85b8efde5586 Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 285
diff changeset
199 // Another run, 23 seconds now, seems nothing has been changed. Switched to Pool2 with DirectHashSet: 22,5 seconds
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
200 System.out.printf("Total time: %d ms\n", System.currentTimeMillis() - start);
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
201 System.out.printf("Free mem: %,d\n", Runtime.getRuntime().freeMemory());
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
202 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
203
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 259
diff changeset
204 private void collectTagsPerFile() throws HgException, CancelledException {
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
205 final long start = System.currentTimeMillis();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
206 final HgRepository repository = new HgLookup().detect(new File("/temp/hg/cpython"));
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
207 final HgTags tags = repository.getTags();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
208 //
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
209 // build cache
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
210 //
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
211 final TagInfo[] allTags = new TagInfo[tags.getTags().size()];
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
212 tags.getTags().values().toArray(allTags);
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
213 // file2rev2tag value is array of revisions, always of allTags.length. Revision index in the array
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
214 // is index of corresponding TagInfo in allTags;
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
215 final Map<Path, Nodeid[]> file2rev2tag = new HashMap<Path, Nodeid[]>();
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
216 System.out.printf("Collecting manifests for %d tags\n", allTags.length);
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
217 // effective translation of changeset revisions to their local indexes
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
218 final HgChangelog.RevisionMap clogrmap = repository.getChangelog().new RevisionMap().init();
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
219 int[] tagLocalRevs = new int[allTags.length];
259
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
220 int x = 0;
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
221 for (int i = 0; i < allTags.length; i++) {
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
222 final Nodeid tagRevision = allTags[i].revision();
259
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
223 final int tagLocalRev = clogrmap.localRevision(tagRevision);
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
224 if (tagLocalRev != HgRepository.BAD_REVISION) {
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
225 tagLocalRevs[x++] = tagLocalRev;
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
226 }
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
227 }
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
228 if (x != allTags.length) {
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
229 // some tags were removed (recorded Nodeid.NULL tagname)
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
230 int[] copy = new int[x];
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
231 System.arraycopy(tagLocalRevs, 0, copy, 0, x);
ea0c0de86d0e Avoid IAE when repository has removed tags. Do not duplicate pools that are already in ManifestParser
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 256
diff changeset
232 tagLocalRevs = copy;
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
233 }
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
234 System.out.printf("Prepared tag revisions to analyze: %d ms\n", System.currentTimeMillis() - start);
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
235 //
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
236 repository.getManifest().walk(new HgManifest.Inspector2() {
256
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
237 private int[] tagIndexAtRev = new int[4]; // it's unlikely there would be a lot of tags associated with a given cset
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
238
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
239 public boolean begin(int mainfestRevision, Nodeid nid, int changelogRevision) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
240 Nodeid cset = clogrmap.revision(changelogRevision);
256
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
241 Arrays.fill(tagIndexAtRev, -1);
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
242 for (int i = 0, x = 0; i < allTags.length; i++) {
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
243 if (cset.equals(allTags[i].revision())) {
256
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
244 tagIndexAtRev[x++] = i;
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
245 if (x == tagIndexAtRev.length) {
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
246 // expand twice as much
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
247 int[] expanded = new int[x << 1];
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
248 System.arraycopy(tagIndexAtRev, 0, expanded, 0, x);
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
249 expanded[x] = -1; // just in case there'd be no more tags associated with this cset
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
250 tagIndexAtRev = expanded;
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
251 }
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
252 }
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
253 }
256
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
254 if (tagIndexAtRev[0] == -1) {
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
255 System.out.println("Can't happen, provided we iterate over revisions with tags only");
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
256 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
257 return true;
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
258 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
259
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
260 public boolean next(Nodeid nid, String fname, String flags) {
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
261 throw new HgBadStateException(HgManifest.Inspector2.class.getName());
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
262 }
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
263
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
264 public boolean next(Nodeid nid, Path fname, HgManifest.Flags flags) {
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
265 Nodeid[] m = file2rev2tag.get(fname);
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
266 if (m == null) {
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
267 file2rev2tag.put(fname, m = new Nodeid[allTags.length]);
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
268 }
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
269 for (int tagIndex : tagIndexAtRev) {
256
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
270 if (tagIndex == -1) {
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
271 break;
b61ed0f2c4da Yet another slight perf/mem improvement for the tags per file sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 255
diff changeset
272 }
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
273 if (m[tagIndex] != null) {
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
274 System.out.printf("There's another revision (%s) associated with tag %s already while we try to associate %s\n", m[tagIndex].shortNotation(), allTags[tagIndex].name(), nid.shortNotation());
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
275 }
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
276 m[tagIndex] = nid;
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
277 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
278 return true;
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
279 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
280
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
281 public boolean end(int manifestRevision) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
282 return true;
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
283 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
284
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
285 }, tagLocalRevs);
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
286 System.out.printf("Cache built: %d ms\n", System.currentTimeMillis() - start);
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
287 //
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
288 // look up specific file. This part is fast.
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
289 final Path targetPath = Path.create("README");
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
290 HgDataFile fileNode = repository.getFileNode(targetPath);
285
6dbbc53fc46d Use Path instead of plain String for manifest file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 268
diff changeset
291 final Nodeid[] allTagsOfTheFile = file2rev2tag.get(targetPath);
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
292 // TODO if fileNode.isCopy, repeat for each getCopySourceName()
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
293 for (int localFileRev = 0; localFileRev < fileNode.getRevisionCount(); localFileRev++) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
294 Nodeid fileRev = fileNode.getRevision(localFileRev);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
295 int changesetLocalRev = fileNode.getChangesetLocalRevision(localFileRev);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
296 List<String> associatedTags = new LinkedList<String>();
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
297 for (int i = 0; i < allTagsOfTheFile.length; i++) {
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
298 if (fileRev.equals(allTagsOfTheFile[i])) {
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
299 associatedTags.add(allTags[i].name());
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
300 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
301 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
302 System.out.printf("%3d%7d%s\n", localFileRev, changesetLocalRev, associatedTags);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
303 }
255
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
304 System.out.printf("Total time: %d ms\n", System.currentTimeMillis() - start);
5a6ab50b4cbf Improve memory footprint of tag collection (about 14 Mb saved for cpython repo without HashMap.Entry and Entry[])
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 254
diff changeset
305 System.out.printf("Free mem: %,d\n", Runtime.getRuntime().freeMemory());
254
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
306 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
307
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
308 public static void main2(String[] args) throws HgException, CancelledException {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
309 final HgRepository repository = new HgLookup().detect(new File("/temp/hg/cpython"));
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
310 final Path targetPath = Path.create("README");
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
311 final HgTags tags = repository.getTags();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
312 final Map<String, HgTags.TagInfo> tagToInfo = tags.getTags();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
313 final HgManifest manifest = repository.getManifest();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
314 final Map<Nodeid, List<String>> changeSetRevisionToTags = new HashMap<Nodeid, List<String>>();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
315 final HgDataFile fileNode = repository.getFileNode(targetPath);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
316 for (String tagName : tagToInfo.keySet()) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
317 final HgTags.TagInfo info = tagToInfo.get(tagName);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
318 final Nodeid nodeId = info.revision();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
319 // TODO: This is not correct as we can't be sure that file at the corresponding revision is actually our target file (which may have been renamed, etc.)
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
320 final Nodeid fileRevision = manifest.getFileRevision(repository.getChangelog().getLocalRevision(nodeId), targetPath);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
321 if (fileRevision == null) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
322 continue;
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
323 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
324
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
325 final Nodeid changeSetRevision = fileNode.getChangesetRevision(fileRevision);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
326 List<String> revisionTags = changeSetRevisionToTags.get(changeSetRevision);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
327 if (revisionTags == null) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
328 revisionTags = new ArrayList<String>();
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
329 changeSetRevisionToTags.put(changeSetRevision, revisionTags);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
330 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
331 revisionTags.add(tagName);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
332 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
333
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
334 final HgLogCommand logCommand = new HgLogCommand(repository);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
335 logCommand.file(targetPath, true);
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
336 logCommand.execute(new HgChangesetHandler() {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
337 public void next(HgChangeset changeset) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
338 if (changeset.getAffectedFiles().contains(targetPath)) {
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
339 System.out.println(changeset.getRevision() + " " + changeSetRevisionToTags.get(changeset.getNodeid()));
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
340 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
341 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
342 });
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
343 }
a620f0663a37 Collect tags for a file - improve performance of 'sparse' manifest reads
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
344 }