Mercurial > hg
comparison tests/test-chg.t @ 40999:dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
This greatly speeds up repository operation with lots of obsolete markers:
$ ls -lh .hg/store/obsstore
-rw-r--r-- 1 yuya yuya 21M Dec 2 17:55 .hg/store/obsstore
$ time hg log -G -l10 --pager no
(hg) 1.79s user 0.13s system 99% cpu 1.919 total
(chg uncached) 0.00s user 0.01s system 0% cpu 1.328 total
(chg cached) 0.00s user 0.00s system 3% cpu 0.180 total
As you can see, the implementation of the preloader function is highly
experimental. It works, but I'm yet to be sure how things can be organized.
So I don't want to formalize the API at this point.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 31 Oct 2018 22:43:08 +0900 |
parents | 042ed354b9eb |
children | f05d10ef42e3 |
comparison
equal
deleted
inserted
replaced
40998:042ed354b9eb | 40999:dcac24ec935b |
---|---|
1 #require chg | 1 #require chg |
2 | 2 |
3 $ mkdir log | 3 $ mkdir log |
4 $ cp $HGRCPATH $HGRCPATH.unconfigured | |
4 $ cat <<'EOF' >> $HGRCPATH | 5 $ cat <<'EOF' >> $HGRCPATH |
5 > [cmdserver] | 6 > [cmdserver] |
6 > log = $TESTTMP/log/server.log | 7 > log = $TESTTMP/log/server.log |
7 > max-log-files = 1 | 8 > max-log-files = 1 |
8 > max-log-size = 10 kB | 9 > max-log-size = 10 kB |
11 | 12 |
12 $ filterlog () { | 13 $ filterlog () { |
13 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \ | 14 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \ |
14 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \ | 15 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \ |
15 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \ | 16 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \ |
17 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \ | |
16 > -e 's!\(pid\)=[0-9]*!\1=...!g' \ | 18 > -e 's!\(pid\)=[0-9]*!\1=...!g' \ |
17 > -e 's!\(/server-\)[0-9a-f]*!\1...!g' | 19 > -e 's!\(/server-\)[0-9a-f]*!\1...!g' |
18 > } | 20 > } |
19 | 21 |
20 init repo | 22 init repo |
228 | 230 |
229 print only the last 10 lines, since we aren't sure how many records are | 231 print only the last 10 lines, since we aren't sure how many records are |
230 preserved: | 232 preserved: |
231 | 233 |
232 $ cat log/server.log.1 log/server.log | tail -10 | filterlog | 234 $ cat log/server.log.1 log/server.log | tail -10 | filterlog |
235 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...) | |
233 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... | 236 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... |
234 YYYY/MM/DD HH:MM:SS (PID)> received fds: ... | 237 YYYY/MM/DD HH:MM:SS (PID)> received fds: ... |
235 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload' | 238 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload' |
236 YYYY/MM/DD HH:MM:SS (PID)> setumask 18 | 239 YYYY/MM/DD HH:MM:SS (PID)> setumask 18 |
237 YYYY/MM/DD HH:MM:SS (PID)> setenv: ... | 240 YYYY/MM/DD HH:MM:SS (PID)> setenv: ... |
238 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... | 241 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... |
239 YYYY/MM/DD HH:MM:SS (PID)> validate: [] | 242 YYYY/MM/DD HH:MM:SS (PID)> validate: [] |
240 YYYY/MM/DD HH:MM:SS (PID)> repository: $TESTTMP/extreload | |
241 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...) | 243 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...) |
242 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting. | 244 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting. |
245 | |
246 repository cache | |
247 ---------------- | |
248 | |
249 $ rm log/server.log* | |
250 $ cp $HGRCPATH.unconfigured $HGRCPATH | |
251 $ cat <<'EOF' >> $HGRCPATH | |
252 > [cmdserver] | |
253 > log = $TESTTMP/log/server.log | |
254 > max-repo-cache = 1 | |
255 > track-log = command, repocache | |
256 > EOF | |
257 | |
258 isolate socket directory for stable result: | |
259 | |
260 $ OLDCHGSOCKNAME=$CHGSOCKNAME | |
261 $ mkdir chgsock | |
262 $ CHGSOCKNAME=`pwd`/chgsock/server | |
263 | |
264 create empty repo and cache it: | |
265 | |
266 $ hg init cached | |
267 $ hg id -R cached | |
268 000000000000 tip | |
269 $ sleep 1 | |
270 | |
271 modify repo (and cache will be invalidated): | |
272 | |
273 $ touch cached/a | |
274 $ hg ci -R cached -Am 'add a' | |
275 adding a | |
276 $ sleep 1 | |
277 | |
278 read cached repo: | |
279 | |
280 $ hg log -R cached | |
281 changeset: 0:ac82d8b1f7c4 | |
282 tag: tip | |
283 user: test | |
284 date: Thu Jan 01 00:00:00 1970 +0000 | |
285 summary: add a | |
286 | |
287 $ sleep 1 | |
288 | |
289 discard cached from LRU cache: | |
290 | |
291 $ hg clone cached cached2 | |
292 updating to branch default | |
293 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
294 $ hg id -R cached2 | |
295 ac82d8b1f7c4 tip | |
296 $ sleep 1 | |
297 | |
298 read uncached repo: | |
299 | |
300 $ hg log -R cached | |
301 changeset: 0:ac82d8b1f7c4 | |
302 tag: tip | |
303 user: test | |
304 date: Thu Jan 01 00:00:00 1970 +0000 | |
305 summary: add a | |
306 | |
307 $ sleep 1 | |
308 | |
309 shut down servers and restore environment: | |
310 | |
311 $ rm -R chgsock | |
312 $ sleep 2 | |
313 $ CHGSOCKNAME=$OLDCHGSOCKNAME | |
314 | |
315 check server log: | |
316 | |
317 $ cat log/server.log | filterlog | |
318 YYYY/MM/DD HH:MM:SS (PID)> init cached | |
319 YYYY/MM/DD HH:MM:SS (PID)> id -R cached | |
320 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) | |
321 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached | |
322 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a' | |
323 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) | |
324 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached | |
325 YYYY/MM/DD HH:MM:SS (PID)> log -R cached | |
326 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) | |
327 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2 | |
328 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2 | |
329 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s) | |
330 YYYY/MM/DD HH:MM:SS (PID)> log -R cached | |
331 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) |