sapling/eden/scm/contrib/chg/hgclient.h

34 lines
937 B
C
Raw Normal View History

/*
* A command server client that uses Unix domain socket
*
* Copyright (c) 2011 Yuya Nishihara <yuya@tcha.org>
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2 or any later version.
*/
#ifndef HGCLIENT_H_
#define HGCLIENT_H_
#include <sys/types.h>
struct hgclient_tag_;
typedef struct hgclient_tag_ hgclient_t;
hgclient_t* hgc_open(const char* sockname);
void hgc_close(hgclient_t* hgc);
pid_t hgc_peerpgid(const hgclient_t* hgc);
pid_t hgc_peerpid(const hgclient_t* hgc);
unsigned long long hgc_versionhash(const hgclient_t* hgc);
const char**
hgc_validate(hgclient_t* hgc, const char* const args[], size_t argsize);
int hgc_runcommand(hgclient_t* hgc, const char* const args[], size_t argsize);
void hgc_attachio(hgclient_t* hgc);
void hgc_setenv(hgclient_t* hgc, const char* const envp[]);
chg: restart server automatically if handshake takes too long Summary: Usually the handshake process is pretty quick (<0.01 seconds): chg: debug: 0.000148 try connect to ... chg: debug: 0.000338 connected to server chg: debug: 0.000359 initialize context buffer with size 4096 chg: debug: 0.008225 hello received: ... chg: debug: 0.008269 capflags=0x7b03, pid=31941 chg: debug: 0.008282 request setprocname, block size 17 chg: debug: 0.008316 request attachio chg: debug: 0.008978 response read from channel r, size 4 chg: debug: 0.009045 request chdir, block size 45 chg: debug: 0.009092 version matched (6119653365548183087) However, we have seen some OSX cases where the handshake and basically everything takes much longer: chg: debug: 0.000139 try connect to ... chg: debug: 0.000297 connected to server chg: debug: 0.000321 initialize context buffer with size 4096 chg: debug: 0.192316 hello received: ... chg: debug: 0.192362 capflags=0x7b03, pid=55634 chg: debug: 0.192373 request setprocname, block size 17 chg: debug: 0.192420 request attachio chg: debug: 0.229009 response read from channel r, size 4 chg: debug: 0.229072 request chdir, block size 34 chg: debug: 0.229111 version matched (6119653365548183087) (See P59677258 for the full paste) If restart the chg server, the problem goes away and commands will be fast again. Unfortunately I'm not sure about the root cause of the problem. Maybe it's Python's GC doing something very expensive? Maybe it's OSX thinking the server process is "inactive" and put it to some state that's very slow to recover? Or maybe it's some weird 3rdparty service? For now, what we do know are: - The slowness *sometimes* reproduces with chg. - The slowness goes away if chg server is restarted. As a last resort, detect the slowness by measuring the handshake time, then restart the server accordingly. To avoid an infinite restart loop on slow machines, the restart can only happen once. The threshold is set to 0.05 seconds, which is roughly 5x the normal value, and can be disabled by `CHGSTARTTIMECHECK=0`. Reviewed By: phillco Differential Revision: D8294468 fbshipit-source-id: 75246ea4d872045664e7feadb0acc47dfa1d8eae
2018-06-06 07:38:44 +03:00
double hgc_elapsed(hgclient_t* hgc);
#endif /* HGCLIENT_H_ */