Mercurial > hg
changeset 16477:70b5e25f1598 stable
bdiff.bdiff: release the GIL before doing expensive diff operations
This means that threaded webservers will have more of a chance of
doing something useful while the C extension is busy computing a
delta. Not doing this was causing problems for Google Code with a 25
meg text file that takes O(7 minutes) to deltify.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 20 Apr 2012 11:08:14 -0500 |
parents | 83622954b64d |
children | cbf2ea2f5ca1 |
files | mercurial/bdiff.c |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bdiff.c Fri Apr 20 11:57:14 2012 -0500 +++ b/mercurial/bdiff.c Fri Apr 20 11:08:14 2012 -0500 @@ -339,10 +339,12 @@ struct line *al, *bl; struct hunk l, *h; int an, bn, len = 0, la, lb, count; + PyThreadState *_save; if (!PyArg_ParseTuple(args, "s#s#:bdiff", &sa, &la, &sb, &lb)) return NULL; + _save = PyEval_SaveThread(); an = splitlines(sa, la, &al); bn = splitlines(sb, lb, &bl); if (!al || !bl) @@ -361,6 +363,8 @@ la = h->a2; lb = h->b2; } + PyEval_RestoreThread(_save); + _save = NULL; result = PyBytes_FromStringAndSize(NULL, len); @@ -385,6 +389,8 @@ } nomem: + if (_save) + PyEval_RestoreThread(_save); free(al); free(bl); freehunks(l.next);