contrib/chg/procutil.h
author Gregory Szorc <gregory.szorc@gmail.com>
Sun, 12 Nov 2017 19:46:15 -0800
changeset 35134 8aa43ff9c12c
parent 31941 ac5527021097
permissions -rw-r--r--
bundle2: implement generic part payload decoder The previous commit extracted _payloadchunks() to a new derived class. There was still a reference to this method in unbundlepart, making unbundlepart unusable on its own. This commit implements a generic version of a bundle2 part payload decoder, without offset tracking. seekableunbundlepart._payloadchunks() has been refactored to consume it, adding offset tracking like before. We also implement unbundlepart._payloadchunks(), which is a thin wrapper for it. Since we never instantiate unbundlepart directly, this new method is not used. This will be changed in subsequent commits. The new implementation also inlines some simple code from unpackermixin and adds some local variable to prevent extra function calls and attribute lookups. `hg perfbundleread` on an uncompressed Firefox bundle seems to show a minor win: ! bundle2 iterparts() ! wall 12.593258 comb 12.250000 user 8.870000 sys 3.380000 (best of 3) ! wall 10.891305 comb 10.820000 user 7.990000 sys 2.830000 (best of 3) ! bundle2 part seek() ! wall 13.173163 comb 11.100000 user 8.390000 sys 2.710000 (best of 3) ! wall 12.991478 comb 10.390000 user 7.720000 sys 2.670000 (best of 3) ! bundle2 part read(8k) ! wall 9.483612 comb 9.480000 user 8.420000 sys 1.060000 (best of 3) ! wall 8.599892 comb 8.580000 user 7.720000 sys 0.860000 (best of 3) ! bundle2 part read(16k) ! wall 9.159815 comb 9.150000 user 8.220000 sys 0.930000 (best of 3) ! wall 8.265361 comb 8.250000 user 7.360000 sys 0.890000 (best of 3) ! bundle2 part read(32k) ! wall 9.141308 comb 9.130000 user 8.220000 sys 0.910000 (best of 3) ! wall 8.290308 comb 8.280000 user 7.330000 sys 0.950000 (best of 3) ! bundle2 part read(128k) ! wall 8.880587 comb 8.850000 user 7.960000 sys 0.890000 (best of 3) ! wall 8.204900 comb 8.150000 user 7.210000 sys 0.940000 (best of 3) Function call overhead in Python strikes again! Of course, bundle2 decoding CPU overhead is likely small compared to decompression and changegroup application. But every little bit helps. Differential Revision: https://phab.mercurial-scm.org/D1387
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30693
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     1
/*
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     2
 * Utilities about process handling - signal and subprocess (ex. pager)
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     3
 *
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     4
 * Copyright (c) 2011 Yuya Nishihara <yuya@tcha.org>
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     5
 *
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     6
 * This software may be used and distributed according to the terms of the
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     7
 * GNU General Public License version 2 or any later version.
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     8
 */
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
     9
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    10
#ifndef PROCUTIL_H_
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    11
#define PROCUTIL_H_
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    12
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    13
#include <unistd.h>
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    14
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    15
void restoresignalhandler(void);
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    16
void setupsignalhandler(pid_t pid, pid_t pgid);
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    17
31941
ac5527021097 chg: respect environment variables for pager
Jun Wu <quark@fb.com>
parents: 30693
diff changeset
    18
pid_t setuppager(const char *pagercmd, const char *envp[]);
30693
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    19
void waitpager(void);
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    20
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
    21
#endif /* PROCUTIL_H_ */