mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
a31f57db1a
Summary: In glibc, pthread cancellation support adds two atomic CAS operations to each "cancellation point" syscall (see pthreads(7)). This includes read() and write(). We can avoid that overhead by disabling pthread cancellation at the start of the FUSE worker threads. This saves two CAS operations (~40 ns) in the critical FUSE request processing loop. Reviewed By: simpkins Differential Revision: D21469690 fbshipit-source-id: 7f28a2a8e831006351657981e901dc572c58cf48
23 lines
513 B
C++
23 lines
513 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#include "eden/fs/utils/Thread.h"
|
|
#include <pthread.h>
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
void disablePthreadCancellation() {
|
|
int oldstate;
|
|
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
|
|
int oldtype;
|
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
|
|
}
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|