Commit Graph

47 Commits

Author SHA1 Message Date
Pierre-Yves David
f0e0234ea1 branchmap: use set for update code
We are doing membership test and substraction. new code is marginally faster.
2014-01-06 15:19:31 -08:00
Pierre-Yves David
fc97641ca7 branchmap: simplify update code
We drop iterrevs which are not needed anymore. The know head are never a
descendant of the updated set. It was possible with the old strip code. This
simplification make the code easier to read an update.
2014-01-06 14:26:49 -08:00
Pierre-Yves David
7641136888 branchmap: stop useless rev -> node -> rev round trip
We never use the node of new revisions unless in the very specific case of
closed heads. So we can just use the revision number.

So give another handfull of percent speedup.
2014-01-03 16:44:23 -08:00
Pierre-Yves David
4a3c0bd301 branchmap: stop membership test in update logic
Now that no user try to update the cache on a truncated repo we can drop the
extra lookup. Give an handfull percent speedup on big branchmap update.
2013-01-15 20:04:12 +01:00
Pierre-Yves David
f4aa184d64 branchmap: remove silly line break
The line fit in 80 character limit without it. It is even shorter without it.
2014-01-03 17:06:07 -08:00
Mads Kiilerich
1428b73c06 help: branch names primarily denote the tipmost unclosed branch head
Was the behavior correct and the description wrong so it should be updated as
in this patch? Or should the code work as the documentation says?

Both ways could make some sense ... but none of them are obvious in all cases.

One place where it currently cause problems is when the current revision has
another branch head that is closer to tip but closed. 'hg rebase' refuses to
rebase to that as it only see the tip-most unclosed branch head which is the
current revision.

/me kind of likes named branches, but no so much how branch closing works ...
2013-11-21 15:17:18 -05:00
Brodie Rao
34af0d72ea branchmap: introduce iterbranches() method 2013-09-16 01:08:29 -07:00
Brodie Rao
f0a5d60210 branchmap: introduce branchheads() method 2013-09-16 01:08:29 -07:00
Brodie Rao
b2b08444eb branchmap: introduce branchtip() method 2013-09-16 01:08:29 -07:00
Brodie Rao
a446720e09 branchmap: cache open/closed branch head information
This lets us determine the open/closed state of a branch without
reading from the changelog (which can be costly over NFS and/or with
many branches).
2013-09-16 01:08:29 -07:00
Brodie Rao
b8ea796521 branchmap: add documentation on the branchcache on-disk format 2013-11-15 23:18:08 -05:00
Augie Fackler
2859ed15ec subsettable: move from repoview to branchmap, the only place it's used
This is a step towards breaking an import cycle between revset and
repoview. Import cycles happened to work in Python 2 with implicit
relative imports, but breaks on Python 3 when we start using explicit
relative imports via 2to3 rewrite rules.
2013-11-06 14:38:34 -05:00
Pierre-Yves David
b5bc8d504a branchmap: stop looking for stripped branch
Since repoview in 2.5 we do not make special call to `branchmap` when stripping.
We just recompute the branchmap from a lower subset that still has valid
branchmap. So I'm dropping this dead code.
2013-09-30 17:42:38 +02:00
Pierre-Yves David
64005d41eb branchmap: remove the droppednodes logic
It was unused. note how it is only extended if the list is empty. So it's always
empty at the end.

We could try to fix that, however this would part of the code is to be removed
in the next changeset as we do not run `branchmap` on truncated repo since
`repoview` in 2.5.
2013-09-30 17:31:39 +02:00
Pierre-Yves David
a58c8b0406 branchmap: fix blank line position
The blank line was after was after the `if` condition instead of before.
2013-09-30 15:52:37 +02:00
Mads Kiilerich
5787baee50 spelling: fix some minor issues found by spell checker 2013-02-10 18:24:29 +01:00
Pierre-Yves David
e0122c56e3 branchmap: display filtername when updatebranch fails to do its jobs
We have a very handy assert at the ends of `branchmap.updatecache` that check
the resulting branchmap is actually valid.

I know we do not like assert in mercurial but this one is very handy for
debugging. There is really not reason for `branchmap.updatecache` to have this
kind of issue but this happened and handful of time during the development of
this or introduction of other related feature. I advice to keep it around until
we are a bit more confident with the new code.
2013-01-19 02:29:56 +01:00
Mads Kiilerich
641f4b8a6c localrepo: store branchheads sorted 2013-01-15 02:59:12 +01:00
Pierre-Yves David
77db5734c1 branchmap: Save changectx creation during update
The newly introduced `branchmap` function allows us to skip the
creation of changectx objects. This speeds up the construction of
the branchmap.

On the mozilla repository (117293 changesets, 15490 mutable)

Before:
  ! impactable 19.9
  ! mutable 0.576
  ! unserved 3.16

After:
  ! impactable 7.03 (2.8x faster)
  ! mutable 0.352 (1.6x)
  ! unserved 1.15 (2.7x)

On the cpython repository (81418 changesets, 6418 mutable)

Before:
  ! impactable 15.9
  ! mutable 0.451
  ! unserved 0.861

After:
  ! impactable 6.55 (2.4x faster)
  ! mutable 0.170 (2.6x faster)
  ! unserved 0.289 (2.9x faster)

On the pypy repository (58852 changesets)

Before:
  ! impactable 13.6

After:
  ! impactable 6.17 (2.2x faster)

On my Mercurial repository (18295 changesets, 2210 mutable)

Before:
  ! impactable 23.9
  ! mutable 0.368
  ! unserved 0.057

After:
  ! impactable 1.31 (18x faster)
  ! mutable 0.042 (8.7x)
  ! unserved 0.025 (2.2x)
2013-01-11 18:47:42 +01:00
Pierre-Yves David
4bd2fce08b branchmap: pass revision insteads of changectx to the update function
Creation of changectx objects is very slow, and they are not very
useful. We are going to drop them. The first step is to change the
function argument type.
2013-01-08 01:28:39 +01:00
Pierre-Yves David
01b68ae973 branchmap: allow to use cache of subset
Filtered repository are *subset* of unfiltered repository. This means that a
filtered branchmap could be use to compute the unfiltered version.

And filtered version happen to be subset of each other:
- "all() - unserved()" is a subset of "all() - hidden()"
- "all() - hidden()" is a subset of "all()"

This means that branchmap with "unfiltered" filter can be used as a base for
"hidden" branchmap that itself could be used as a base for unfiltered
branchmap.

   unserved < hidden < None

This changeset implements this mechanism. If the on disk branchcache is not valid
we use the branchcache of the nearest subset as base instead of computing it from
scratch. Such fallback can be cascaded multiple time is necessary.

Note that both "hidden" and "unserved" set are a bit volatile. We will add more
stable filtering in next changesets.

This changeset enables collaboration between no filtering and "unserved"
filtering. Fixing performance regression introduced by 7bff5f37cb97
2013-01-07 17:23:25 +01:00
Pierre-Yves David
7b8d884b29 branchmap: add a copy method
If we want branchcache of different filter to collaborate, they need a simple
way to copy each other. This will ensure that each filtered have no side effect
on other filter level cache.
2013-01-02 01:40:42 +01:00
Pierre-Yves David
ea8f599221 branchmap: drop _cacheabletip usage in updatecache
Nobody overwrite the `_cacheabletip` any more. We always update the cache for
the whole repo and write it to disk (or at list try to). The `updatecache` code
is simplied to remove the double phase logic associated with _cacheabletip.
2013-01-04 01:25:55 +01:00
Pierre-Yves David
e5d81232c2 branchmap: ignore Abort error while writing cache
Read only vfs can now raise Abort exception. Note that encoding.local are also a
possible raiser.
2013-01-04 04:52:57 +01:00
Pierre-Yves David
f01949c09e branchmap: read return None in case of failure
This makes a clear distinction between having read a valid cache on disk or not.
This will help caches of various filtering level to collaborate.
2012-12-22 19:41:11 +01:00
Pierre-Yves David
0cd9115520 branchmap: enable caching for filtered version too
The `_branchcache` attribute is turned into a dictionary. Key are filter name and
value is a `branchcache` object. Unfiltered version is cached as `None` filter.

The attribute is renamed to `_branchcaches` to avoid confusion with the previous
one. Both old and new contents are dictionary even if their contents are
different. I prefer possible extension code to crash right away instead of just
messing the wrong dictionary.

As all different caches work isolated to each other, this code keeps the
previous behavior of using the unfiltered cache  we nothing is filtered.  This
is a cheap way to have cache collaborate and nullify potential impact in the
default case.
2012-12-24 03:21:15 +01:00
Pierre-Yves David
daf9851247 branchmap: report filtername when read fails
Now that we can have multiple one, we need to know which filecache failed to be
read from disk.
2013-01-01 21:27:13 +01:00
Pierre-Yves David
256c2dfbf0 branchmap: use a different file name for filtered view of repo 2012-12-24 03:06:03 +01:00
Pierre-Yves David
4ad32b10f3 branchmap: move the cache file name into a dedicated function
Filtered view of the repo will want to write they file name in a different file.
2012-12-24 03:04:12 +01:00
Pierre-Yves David
d7e9f7c173 branchmap: read and write key part related to filtered revision
Now that we have a third part for the cache key we need to write and read it on
disk. It is only written when there is filtered revision. This keep the format
compatible with older version.

Notes that, at this state, filtered repository does not use any disk caches yet.
2013-01-01 18:19:24 +01:00
Pierre-Yves David
4898e4fe72 branchmap: takes filtered revision in account for cache calculation
Tracking tipnode and tiprev is not enough to ensure validaty of the cache as
they do not help distinguish a cache that ignored various revisions below
tiprev.

To detect such difference, we build a hash of all ignored revisions. This hash
is then used when checking the validity of a cache for a repo.
2012-12-31 18:11:18 -06:00
Pierre-Yves David
c5a39ef698 branchmap: improve computation of target tip
With revision filtering the effective revision number of "tip" may be lower than:

    len(changelog) - 1

We now use a more correct version preventing useless writing on disk in some
case.
2012-12-24 02:57:23 +01:00
Pierre-Yves David
186fef84cd branchmap: improve invalid cache message when reading
This factors out the generation of the message. This helps future error reporting
when reading cache for filtered repository.
2012-12-28 00:13:32 +01:00
Pierre-Yves David
2e407bdb0d branchmap: move validity logic in the object itself
In several place, We check if a branchcache is still valid regarding the current
state of the repository. This changeset puts this logic in a method of the object
that can be reused when necessary.

A branch map is considered valid whenever it is up to date or a strict subset of
the repository state.

The change will help making branchcache aware of filtered revision.

The change in keyword is expected. the branch cache is actually invalid after
the amend. The previous check did not detected it.
2012-12-24 02:49:59 +01:00
Pierre-Yves David
5e4e0ce72d branchmap: make update a method 2012-12-22 17:08:15 +01:00
Pierre-Yves David
3b1070cfe3 branchmap: make update responsible to update the cache key
The update function have all necessary data to keep the branchcache key
up to date with its value.

This saves assignment to the cache key that each caller of update had to do by
hand.

The strip case is a bit more complicated to handles from inside the function but
I do not expect any impact.
2012-12-24 02:22:04 +01:00
Pierre-Yves David
26e77ac183 branchmap: factorise changelog access in update
This both improves readability and performance. Access to changelog of filtered
repository currently have a minor overhead.
2012-12-22 02:11:12 +01:00
Pierre-Yves David
a3a3d2bc58 branchmap: make write a method on the branchmap object 2012-12-20 16:28:43 +01:00
Pierre-Yves David
1bc937448e branchmap: simplify write signature
All necessary data (cache value and key) are now stored in the branchcache
object. Any extra parameter is superfluous.
2012-12-22 02:04:49 +01:00
Pierre-Yves David
9602b376b6 branchmap: add the tiprev (cache key) on the branchmap object
The actual cache key used on disk is the (tipnode, tiprev) pair. There is no
reason not to use the revision number for the in memory version.
2012-12-22 02:06:26 +01:00
Pierre-Yves David
72ccce9263 branchmap: add the tipnode (cache key) on the branchcache object
Gathering data and cache key paves the way to a lot of simplification.
2012-12-22 01:59:05 +01:00
Pierre-Yves David
0b84a3fa35 branchmap: store branchcache in a dedicated object
Value and key of branchcache would benefit from being hold by the same object.
Moreover some logic (update, write, validation) could be move on such object.

The creation of this object is the first step toward this move. The result will
clarify branchcache related code and hide most of the detail in the class
itself. This encapsulation will greatly helps implementation of branchcache for
filtered view of the repo.
2012-12-22 01:44:42 +01:00
Pierre-Yves David
dc5b484bd1 branchmap: extract updatebranchcache from repo 2012-12-20 14:45:17 +01:00
Pierre-Yves David
0e27877238 branchmap: extract _updatebranchcache from repo 2012-12-19 14:49:06 +01:00
Pierre-Yves David
b588a59cfa branchmap: extract read logic from repo 2012-12-19 14:46:57 +01:00
Pierre-Yves David
ef0f47c598 branchmap: extract write logic from localrepo 2012-12-20 13:37:37 +01:00
Pierre-Yves David
83c3a96189 branchmap: create a mercurial.branchmap module
This is the foundation stone for an extraction of branches map logic from local
repository class.  Most of the branches map logic have very few caller and
therefor does not fit in the current criteria for code held by the localrepo
class. Important change will be made to this code in relation with revision
filtering. So we extract it in a dedicated module before adding additional
complexity.


Follow up commit do the actual code movement.
2012-12-19 14:43:33 +01:00