fastmanifest: add number of valid entries in the cache when displaying list

Summary: This could be useful to have the number of valid entries in the cache

Test Plan: Test output changes accordingly

Reviewers: ttung

Differential Revision: https://phabricator.intern.facebook.com/D3343488
This commit is contained in:
Laurent Charignon 2016-05-24 15:33:26 -07:00
parent 17fa2557a1
commit 6c8c7ebe37
2 changed files with 10 additions and 0 deletions

View File

@ -539,14 +539,17 @@ def _cachemanifestpruneall(ui, repo):
def _cachemanifestlist(ui, repo):
cache = fastmanifestcache.getinstance(repo.store.opener, ui)
totalsize = 0
numvalidentries = 0
for entry in cache:
entrysize = cache.entrysize(entry)
if entrysize == -1:
# Entry was deleted by another process
continue
numvalidentries += 1
totalsize += entrysize
ui.status(("%s (size %s)\n" % (entry, util.bytecount(entrysize))))
ui.status(("cache size is: %s\n" % util.bytecount(totalsize)))
ui.status(("number of entries is: %s\n" % numvalidentries))
def _cachemanifestfillandtrim(ui, repo, revs, limit, background):
if background:

View File

@ -208,6 +208,7 @@ there is a concurrency issue to address
faste3738bf5439958f89499a656982023aba57b076e (size 232 bytes)
fastf064a7f8e3e138341587096641d86e9d23cd9778 (size 280 bytes)
cache size is: 1.13 KB
number of entries is: 5
$ hg diff -c . --debug --nodate
cache hit for fastmanifest f064a7f8e3e138341587096641d86e9d23cd9778
cache hit for fastmanifest 7ab5760d084a24168f7595c38c00f4bbc2e308d9
@ -303,6 +304,7 @@ to make the test deterministic:
faste3738bf5439958f89499a656982023aba57b076e (size 232 bytes)
fastf064a7f8e3e138341587096641d86e9d23cd9778 (size 280 bytes)
cache size is: 1.13 KB
number of entries is: 5
Check that trimming to a limit higher than what is cached does nothing
$ hg debugcachemanifest --debug --limit=2048
@ -320,6 +322,7 @@ Trim the cache to at most 1kb
faste3738bf5439958f89499a656982023aba57b076e (size 232 bytes)
fastf064a7f8e3e138341587096641d86e9d23cd9778 (size 280 bytes)
cache size is: 832 bytes
number of entries is: 4
Trim the cache to at most 512 bytes
$ hg debugcachemanifest --debug --limit=512
@ -331,6 +334,7 @@ Trim the cache to at most 512 bytes
faste3738bf5439958f89499a656982023aba57b076e (size 232 bytes)
fastf064a7f8e3e138341587096641d86e9d23cd9778 (size 280 bytes)
cache size is: 512 bytes
number of entries is: 2
Trim the cache to at most 100 bytes
$ hg debugcachemanifest --debug --limit=100
@ -340,6 +344,7 @@ Trim the cache to at most 100 bytes
$ hg debugcachemanifest --debug --list
caching rev: [], background(False), pruneall(False), list(True)
cache size is: 0 bytes
number of entries is: 0
Check that trimming the cache to 0 byte works
$ hg debugcachemanifest -a
@ -360,6 +365,7 @@ Make the results deterministic
faste3738bf5439958f89499a656982023aba57b076e (size 232 bytes)
fastf064a7f8e3e138341587096641d86e9d23cd9778 (size 280 bytes)
cache size is: 1.13 KB
number of entries is: 5
$ hg debugcachemanifest --debug --limit=0
caching rev: [], background(False), pruneall(False), list(False)
removing cached manifest fastf064a7f8e3e138341587096641d86e9d23cd9778
@ -370,6 +376,7 @@ Make the results deterministic
$ hg debugcachemanifest --debug --list
caching rev: [], background(False), pruneall(False), list(True)
cache size is: 0 bytes
number of entries is: 0