view tests/svn/replace.svndump @ 40021:c537144fdbef

wireprotov2: support response caching One of the things I've learned from managing VCS servers over the years is that they are hard to scale. It is well known that some companies have very beefy (read: very expensive) servers to power their VCS needs. It is also known that specialized servers for various VCS exist in order to facilitate scaling servers. (Mercurial is in this boat.) One of the aspects that make a VCS server hard to scale is the high CPU load incurred by constant client clone/pull operations. To alleviate the scaling pain associated with data retrieval operations, I want to integrate caching into the Mercurial wire protocol server as robustly as possible such that servers can aggressively cache responses and defer as much server load as possible. This commit represents the initial implementation of a general caching layer in wire protocol version 2. We define a new interface and behavior for a wire protocol cacher in repository.py. (This is probably where a reviewer should look first to understand what is going on.) The bulk of the added code is in wireprotov2server.py, where we define how a command can opt in to being cached and integrate caching into command dispatching. From a very high-level: * A command can declare itself as cacheable by providing a callable that can be used to derive a cache key. * At dispatch time, if a command is cacheable, we attempt to construct a cacher and use it for serving the request and/or caching the request. * The dispatch layer handles the bulk of the business logic for caching, making cachers mostly "dumb content stores." * The mechanism for invalidating cached entries (one of the harder parts about caching in general) is by varying the cache key when state changes. As such, cachers don't need to be concerned with cache invalidation. Initially, we've hooked up support for caching "manifestdata" and "filedata" commands. These are the simplest to cache, as they should be immutable over time. Caching of commands related to changeset data is a bit harder (because cache validation is impacted by changes to bookmarks, phases, etc). This will be implemented later. (Strictly speaking, censoring a file should invalidate caches. I've added an inline TODO to track this edge case.) To prove it works, this commit implements a test-only extension providing in-memory caching backed by an lrucachedict. A new test showing this extension behaving properly is added. FWIW, the cacher is ~50 lines of code, demonstrating the relative ease with which a cache can be added to a server. While the test cacher is not suitable for production workloads, just for kicks I performed a clone of just the changeset and manifest data for the mozilla-unified repository. With a fully warmed cache (of just the manifest data since changeset data is not cached), server-side CPU usage dropped from ~73s to ~28s. That's pretty significant and demonstrates the potential that response caching has on server scalability! Differential Revision: https://phab.mercurial-scm.org/D4773
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 26 Sep 2018 17:16:56 -0700
parents 5fb924ee44d5
children
line wrap: on
line source

SVN-fs-dump-format-version: 2

UUID: 97a955ef-0269-44f2-a58f-abd4ad400b2b

Revision-number: 0
Prop-content-length: 56
Content-length: 56

K 8
svn:date
V 27
2010-11-26T18:01:12.912988Z
PROPS-END

Revision-number: 1
Prop-content-length: 108
Content-length: 108

K 7
svn:log
V 7
initial
K 10
svn:author
V 7
pmezard
K 8
svn:date
V 27
2010-11-26T18:01:13.106933Z
PROPS-END

Node-path: branches
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Node-path: trunk
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Node-path: trunk/a
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 2
Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b
Content-length: 12

PROPS-END
a


Node-path: trunk/d
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Node-path: trunk/d/b
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 2
Text-content-md5: 3b5d5c3712955042212316173ccf37be
Text-content-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b
Content-length: 12

PROPS-END
b


Node-path: trunk/d2
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Node-path: trunk/d2/a
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 2
Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b
Content-length: 12

PROPS-END
a


Node-path: trunk/dlink
Node-kind: file
Node-action: add
Prop-content-length: 33
Text-content-length: 6
Text-content-md5: cca56829f18345718a4980bb02b6d8c3
Text-content-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49
Content-length: 39

K 11
svn:special
V 1
*
PROPS-END
link d

Node-path: trunk/dlink2
Node-kind: file
Node-action: add
Prop-content-length: 33
Text-content-length: 6
Text-content-md5: cca56829f18345718a4980bb02b6d8c3
Text-content-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49
Content-length: 39

K 11
svn:special
V 1
*
PROPS-END
link d

Node-path: trunk/dlink3
Node-kind: file
Node-action: add
Prop-content-length: 33
Text-content-length: 6
Text-content-md5: cca56829f18345718a4980bb02b6d8c3
Text-content-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49
Content-length: 39

K 11
svn:special
V 1
*
PROPS-END
link d

Revision-number: 2
Prop-content-length: 117
Content-length: 117

K 7
svn:log
V 15
clobber symlink
K 10
svn:author
V 7
pmezard
K 8
svn:date
V 27
2010-11-26T18:01:14.073483Z
PROPS-END

Node-path: trunk/dlink3
Node-kind: file
Node-action: change
Prop-content-length: 10
Text-content-length: 2
Text-content-md5: e29311f6f1bf1af907f9ef9f44b8328b
Text-content-sha1: e983f374794de9c64e3d1c1de1d490c0756eeeff
Content-length: 12

PROPS-END
d


Revision-number: 3
Prop-content-length: 106
Content-length: 106

K 7
svn:log
V 8
clobber1
K 10
svn:author
V 4
evil
K 8
svn:date
V 27
2010-11-26T18:01:16.205184Z
PROPS-END

Node-path: trunk/a
Node-kind: dir
Node-action: delete

Node-path: trunk/a
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 2
Node-copyfrom-path: trunk/d




Node-path: trunk/dlink
Node-kind: dir
Node-action: delete

Node-path: trunk/dlink
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 2
Node-copyfrom-path: trunk/d




Revision-number: 4
Prop-content-length: 106
Content-length: 106

K 7
svn:log
V 8
clobber2
K 10
svn:author
V 4
evil
K 8
svn:date
V 27
2010-11-26T18:01:16.395962Z
PROPS-END

Node-path: trunk/dlink3
Node-kind: file
Node-action: delete

Node-path: trunk/dlink3
Node-kind: file
Node-action: add
Node-copyfrom-rev: 3
Node-copyfrom-path: trunk/dlink2
Text-copy-source-md5: cca56829f18345718a4980bb02b6d8c3
Text-copy-source-sha1: 7c54cc5d472b78c94a04382df34b0f4f0f4f2d49




Revision-number: 5
Prop-content-length: 106
Content-length: 106

K 7
svn:log
V 5
adddb
K 10
svn:author
V 7
pmezard
K 8
svn:date
V 27
2010-11-26T18:01:16.445072Z
PROPS-END

Node-path: trunk/d2/b
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 2
Text-content-md5: 3b5d5c3712955042212316173ccf37be
Text-content-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b
Content-length: 12

PROPS-END
b


Revision-number: 6
Prop-content-length: 107
Content-length: 107

K 7
svn:log
V 6
branch
K 10
svn:author
V 7
pmezard
K 8
svn:date
V 27
2010-11-26T18:01:19.075874Z
PROPS-END

Node-path: branches/branch
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 5
Node-copyfrom-path: trunk


Node-path: branches/branch/d2/c
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 2
Text-content-md5: 2cd6ee2c70b0bde53fbe6cac3c8b8bb1
Text-content-sha1: 2b66fd261ee5c6cfc8de7fa466bab600bcfe4f69
Content-length: 12

PROPS-END
c


Node-path: branches/branch/d2/b
Node-action: delete


Revision-number: 7
Prop-content-length: 109
Content-length: 109

K 7
svn:log
V 10
clobberdir
K 10
svn:author
V 4
evil
K 8
svn:date
V 27
2010-11-26T18:01:21.202158Z
PROPS-END

Node-path: trunk/d2
Node-kind: dir
Node-action: delete

Node-path: trunk/d2
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 6
Node-copyfrom-path: branches/branch/d2