index: make revision walk be by position instead of generation number

I don't know why I made it walk by generation number to start
with. Walking by position is better in at least two ways: 1) revsets
now depend on the walks to be by descending index position (though
they could equally well depend on the walks to be by generation number
-- it just needs to be consistent), and 2) the log output gets less
interleaved.

This commit makes the number of bytes in the graphlog output in the
git.git repo drop by ~40% due to the reduced amount of
interleaving. Also, it reduces the time of `jj bench walkrevs v1.0.0
v2.0.0` in the git.git repo by 32% (9.4ms -> 6.4ms) and `jj bench
walkrevs v2.0.0 v1.0.0` by 33% (7.7ms -> 5.1ms).
This commit is contained in:
Martin von Zweigbergk 2021-04-21 16:26:17 -07:00
parent 98f4e24892
commit 6bc1361b84

View file

@ -1009,7 +1009,7 @@ impl PartialOrd for IndexEntryByGeneration<'_> {
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd)]
struct RevWalkWorkItem<'a> {
entry: IndexEntryByGeneration<'a>,
entry: IndexEntryByPosition<'a>,
wanted: bool,
}
@ -1036,7 +1036,7 @@ impl<'a> RevWalk<'a> {
return;
}
self.items.push(RevWalkWorkItem {
entry: IndexEntryByGeneration(self.index.entry_by_pos(pos)),
entry: IndexEntryByPosition(self.index.entry_by_pos(pos)),
wanted: true,
});
}
@ -1046,7 +1046,7 @@ impl<'a> RevWalk<'a> {
return;
}
self.items.push(RevWalkWorkItem {
entry: IndexEntryByGeneration(self.index.entry_by_pos(pos)),
entry: IndexEntryByPosition(self.index.entry_by_pos(pos)),
wanted: false,
});
}