##// END OF EJS Templates
nodemap: also use persistent nodemap for manifest...
nodemap: also use persistent nodemap for manifest The manifest as a different usage pattern than the changelog. First, while the lookup in changelog are not garanteed to match, the lookup in the manifest nodemap come from changelog and will exist in the manifest. In addition, looking up a manifest almost always result in unpacking a manifest an operation that rarely come cheap. Nevertheless, using a persistent nodemap provide a significant gain for some operations. For our measurementw, we use `hg cat --rev REV FILE` on the our reference mozilla-try. On this repository the persistent nodemap cache is about 29 MB in side for a total store side of 11,988 MB File with large history (file: b2g/config/gaia.json, revision: 195a1146daa0) no optimisation: 0.358s using mmap for index: 0.297s (-0.061s) persistent nodemap for changelog only: 0.275s (-0.024s) persistent nodemap for manifest too: 0.258s (-0.017s) File with small history (file: .hgignore, revision: 195a1146daa0) no optimisation: 0.377s using mmap for index: 0.296s (-0.061s) persistent nodemap for changelog only: 0.274s (-0.022s) persistent nodemap for manifest too: 0.257s (-0.017s) Same file but using a revision (8ba995b74e18) with a smaller manifest (3944829 bytes vs 10 bytes) no optimisation: 0.192s (-0.185s) using mmap for index: 0.131s (-0.061s) persistent nodemap for changelog only: 0.106s (-0.025s) persistent nodemap for manifest too: 0.087s (-0.019s) Differential Revision: https://phab.mercurial-scm.org/D8410

File last commit:

r36781:90f8fe72 default
r45290:640d5b3b default
Show More
xutils.c
150 lines | 3.1 KiB | text/x-c | CLexer
Jun Wu
xdiff: vendor xdiff library from git...
r36689 /*
* LibXDiff by Davide Libenzi ( File Differential Library )
* Copyright (C) 2003 Davide Libenzi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Davide Libenzi <davidel@xmailserver.org>
*
*/
#include <limits.h>
#include <assert.h>
#include "xinclude.h"
Jun Wu
xdiff: replace {unsigned ,}long with {u,}int64_t...
r36840 int64_t xdl_bogosqrt(int64_t n) {
int64_t i;
Jun Wu
xdiff: vendor xdiff library from git...
r36689
/*
* Classical integer square root approximation using shifts.
*/
for (i = 1; n > 0; n >>= 2)
i <<= 1;
return i;
}
Jun Wu
xdiff: replace {unsigned ,}long with {u,}int64_t...
r36840 void *xdl_mmfile_first(mmfile_t *mmf, int64_t *size)
Jun Wu
xdiff: vendor xdiff library from git...
r36689 {
*size = mmf->size;
return mmf->ptr;
}
Jun Wu
xdiff: replace {unsigned ,}long with {u,}int64_t...
r36840 int64_t xdl_mmfile_size(mmfile_t *mmf)
Jun Wu
xdiff: vendor xdiff library from git...
r36689 {
return mmf->size;
}
Jun Wu
xdiff: replace {unsigned ,}long with {u,}int64_t...
r36840 int xdl_cha_init(chastore_t *cha, int64_t isize, int64_t icount) {
Jun Wu
xdiff: vendor xdiff library from git...
r36689
cha->head = cha->tail = NULL;
cha->isize = isize;
cha->nsize = icount * isize;
cha->ancur = cha->sncur = NULL;
cha->scurr = 0;
return 0;
}
void xdl_cha_free(chastore_t *cha) {
chanode_t *cur, *tmp;
for (cur = cha->head; (tmp = cur) != NULL;) {
cur = cur->next;
xdl_free(tmp);
}
}
void *xdl_cha_alloc(chastore_t *cha) {
chanode_t *ancur;
void *data;
if (!(ancur = cha->ancur) || ancur->icurr == cha->nsize) {
if (!(ancur = (chanode_t *) xdl_malloc(sizeof(chanode_t) + cha->nsize))) {
return NULL;
}
ancur->icurr = 0;
ancur->next = NULL;
if (cha->tail)
cha->tail->next = ancur;
if (!cha->head)
cha->head = ancur;
cha->tail = ancur;
cha->ancur = ancur;
}
data = (char *) ancur + sizeof(chanode_t) + ancur->icurr;
ancur->icurr += cha->isize;
return data;
}
Jun Wu
xdiff: replace {unsigned ,}long with {u,}int64_t...
r36840 int64_t xdl_guess_lines(mmfile_t *mf, int64_t sample) {
int64_t nl = 0, size, tsize = 0;
Jun Wu
xdiff: vendor xdiff library from git...
r36689 char const *data, *cur, *top;
if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) {
for (top = data + size; nl < sample && cur < top; ) {
nl++;
if (!(cur = memchr(cur, '\n', top - cur)))
cur = top;
else
cur++;
}
tsize += (long) (cur - data);
}
if (nl && tsize)
nl = xdl_mmfile_size(mf) / (tsize / nl);
return nl + 1;
}
Jun Wu
xdiff: remove unused flags parameter...
r36841 int xdl_recmatch(const char *l1, int64_t s1, const char *l2, int64_t s2)
Jun Wu
xdiff: vendor xdiff library from git...
r36689 {
if (s1 == s2 && !memcmp(l1, l2, s1))
return 1;
Jun Wu
xdiff: remove whitespace related feature...
r36779 return 0;
Jun Wu
xdiff: vendor xdiff library from git...
r36689 }
Jun Wu
xdiff: remove unused flags parameter...
r36841 uint64_t xdl_hash_record(char const **data, char const *top) {
Jun Wu
xdiff: replace {unsigned ,}long with {u,}int64_t...
r36840 uint64_t ha = 5381;
Jun Wu
xdiff: vendor xdiff library from git...
r36689 char const *ptr = *data;
for (; ptr < top && *ptr != '\n'; ptr++) {
ha += (ha << 5);
ha ^= (unsigned long) *ptr;
}
*data = ptr < top ? ptr + 1: ptr;
return ha;
}
Jun Wu
xdiff: use int64 for hash table size...
r36843 unsigned int xdl_hashbits(int64_t size) {
int64_t val = 1;
unsigned int bits = 0;
Jun Wu
xdiff: vendor xdiff library from git...
r36689
Jun Wu
xdiff: use int64 for hash table size...
r36843 for (; val < size && bits < (int64_t) CHAR_BIT * sizeof(unsigned int); val <<= 1, bits++);
Jun Wu
xdiff: vendor xdiff library from git...
r36689 return bits ? bits: 1;
}