[PATCH 4 of 4] chg: change server's process title

Gregory Szorc gregory.szorc at gmail.com
Thu Aug 11 12:00:04 EDT 2016



> On Aug 11, 2016, at 07:28, Yuya Nishihara <yuya at tcha.org> wrote:
> 
>> On Wed, 10 Aug 2016 18:30:00 +0100, Jun Wu wrote:
>> # HG changeset patch
>> # User Jun Wu <quark at fb.com>
>> # Date 1470849617 -3600
>> #      Wed Aug 10 18:20:17 2016 +0100
>> # Node ID e7c880aa65ef1cdf00ffe0db27d4365294cb6a62
>> # Parent  7472b38c08ca30af74668f41056afbd065887c04
>> # Available At https://bitbucket.org/quark-zju/hg-draft
>> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r e7c880aa65ef
>> chg: change server's process title
>> 
>> This patch uses the newly introduced "setprocname" interface to update the
>> process title server-side, to make it easier to tell what a worker is
>> actually doing.
>> 
>> The title is short, "chg:$PID", to fit in prctl's 15-char limit. The new
>> title can be observed using "ps -AO comm" under Linux, and is directly
>> observable using "ps -A" under FreeBSD.
> 
>> +static void updateprocname(hgclient_t *hgc)
>> +{
>> +    /* prctl(PR_SET_NAME) has a 15-char limit. be as short as possible */
>> +    size_t n = (size_t)snprintf(hgc->ctx.data, hgc->ctx.maxdatasize,
>> +            "chg:%d", (int)getpid());
>> +    hgc->ctx.datasize = n;
>> +    writeblockrequest(hgc, "setprocname");
>> +}
> 
> If it's displayed as if argv were {"chg:%d"} on FreeBSD, it would be confusing
> that both client and server are named as "chg".
> 
> I'm not enthusiastic about this series because it requires new C functions
> and command-server command just for ease of debugging, different platform
> behaviors (I guess), no OSX support.

And I've long wanted to abuse process title setting in hgweb servers - especially when they are configured to serve multiple repos. It's difficult to see which repo is consuming CPU *right now* without it.


More information about the Mercurial-devel mailing list