tags-fnode-cache: skip building a changectx in getfnode
Building a changectx object is costly, doing it just to retrieve the revision
number is suboptimal. Directly fetching the revision number from the changelog
provide a sizeable speedup to `hg debugupdatecache`.
### data-env-vars.name = mercurial-2018-08-01-zstd-sparse-revlog
# benchmark.name = debug-update-cache
# benchmark.variants.pre-state = warm
before: 0.213229 seconds
after: 0.165577 seconds (-22.35%)
# data-env-vars.name = mercurial-filtered-2019-11-22-zstd-sparse-revlog
before: 1.200383 seconds
after: 1.071618 seconds (-10.73%)
# data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog
before: 1.465735 seconds
after: 0.923128 seconds (-37.02%)
# data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog
before: 6.511771 seconds
after: 4.507316 seconds (-30.78%)
# data-env-vars.name = netbeans-2018-08-01-zstd-sparse-revlog
before: 1.023007 seconds
after: 0.645026 seconds (-36.95%)
# data-env-vars.name = pypy-2018-08-01-zstd-sparse-revlog
before: 0.381141 seconds
after: 0.268654 seconds (-29.51%)
import cffi
import os
ffi = cffi.FFI()
mpatch_c = os.path.join(
os.path.join(os.path.dirname(__file__), '..', 'mpatch.c')
)
with open(mpatch_c) as f:
ffi.set_source(
"mercurial.cffi._mpatch", f.read(), include_dirs=["mercurial"]
)
ffi.cdef(
"""
struct mpatch_frag {
int start, end, len;
const char *data;
};
struct mpatch_flist {
struct mpatch_frag *base, *head, *tail;
};
extern "Python" struct mpatch_flist* cffi_get_next_item(void*, ssize_t);
int mpatch_decode(const char *bin, ssize_t len, struct mpatch_flist** res);
ssize_t mpatch_calcsize(size_t len, struct mpatch_flist *l);
void mpatch_lfree(struct mpatch_flist *a);
static int mpatch_apply(char *buf, const char *orig, size_t len,
struct mpatch_flist *l);
struct mpatch_flist *mpatch_fold(void *bins,
struct mpatch_flist* (*get_next_item)(void*, ssize_t),
ssize_t start, ssize_t end);
"""
)
if __name__ == '__main__':
ffi.compile()