Mercurial > hg
view mercurial/mpatch.h @ 48178:f12a19d03d2c
fix: reduce number of tool executions
By grouping together (path, ctx) pairs according to the inputs they would
provide to fixer tools, we can deduplicate executions of fixer tools to
significantly reduce the amount of time spent running slow tools.
This change does not handle clean files in the working copy, which could still
be deduplicated against the files in the checked out commit. It's a little
harder to do that because the filerev is not available in the workingfilectx
(and it doesn't exist for added files).
Anecdotally, this change makes some real uses cases at Google 10x faster. I
think we were originally hesitant to do this because the benefits weren't
obvious, and implementing it efficiently is kind of tricky. If we simply
memoized the formatter execution function, we would be keeping tons of file
content in memory.
Also included is a regression test for a corner case that I broke with my first
attempt at optimizing this code.
Differential Revision: https://phab.mercurial-scm.org/D11280
author | Danny Hooper <hooper@google.com> |
---|---|
date | Thu, 02 Sep 2021 14:08:45 -0700 |
parents | 761355833867 |
children | d86908050375 |
line wrap: on
line source
#ifndef _HG_MPATCH_H_ #define _HG_MPATCH_H_ #define MPATCH_ERR_NO_MEM -3 #define MPATCH_ERR_CANNOT_BE_DECODED -2 #define MPATCH_ERR_INVALID_PATCH -1 struct mpatch_frag { int start, end, len; const char *data; }; struct mpatch_flist { struct mpatch_frag *base, *head, *tail; }; int mpatch_decode(const char *bin, ssize_t len, struct mpatch_flist **res); ssize_t mpatch_calcsize(ssize_t len, struct mpatch_flist *l); void mpatch_lfree(struct mpatch_flist *a); int mpatch_apply(char *buf, const char *orig, ssize_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); #endif