sapling/eden/fs
Teng Qin 562d34cf82 Improve folly::RequestContext onSet and onUnset efficiency
Summary:
In previous discussions, it has been pointed out that `folly::RequestContext::setContext` consumes considerable amount of CPU cycles in production environments. After some investigation, we thought that might be caused by looping over all `RequestData` instances can calling the virtual `onSet` and `onUnset` callback of them. Both the iteration and invoking virtual methods are not cheap.

As you can see from this change, most of the derived classes of `RequestData` don't override the `onSet` and `onUnset` methods. Mostly likely they are only used for per-Request tracking. So the natural idea is to skip those instances when iterating and avoid the unnecessary virtual method invoke.

I have explored the solution to dynamically examine if the `RequestData` instance added has `onSet` and `onUnset` method overridden. That is possible with GCC's PMF extension, but not [[ http://lists.llvm.org/pipermail/llvm-bugs/2015-July/041164.html | for Clang ]] and probably many other compilers. This definitely won't be very good for `folly`'s probability, even if we gate it by compiler flags.

Therefore, this Diff adds the `hasCallback` method to `RequestData` class indicating whether the instance would have `onSet` and `onUnset` overridden. To make it clear to users that they need to correctly override it in order for their `onSet` and `onUnset` callback to work, making it abstract so that user must override it to something and would aware of that.

Also made some improvements on documentation.

Reviewed By: myreg

Differential Revision: D6144049

fbshipit-source-id: 4c9fd72e9efaeb6763d55f63760eaf582ee4839e
2017-10-31 14:02:57 -07:00
..
config Ensure explicit dependency on boost_filesystem 2017-10-18 20:34:41 -07:00
fuse Improve folly::RequestContext onSet and onUnset efficiency 2017-10-31 14:02:57 -07:00
inodes Move folly/Array.h 2017-10-29 03:42:55 -07:00
journal tidy up journal subscribers on unmount 2017-10-27 09:01:57 -07:00
model Move folly/Array.h 2017-10-29 03:42:55 -07:00
rocksdb use rocksdb column families to separate key spaces 2017-09-07 14:50:42 -07:00
service tidy up journal subscribers on unmount 2017-10-27 09:01:57 -07:00
store Move folly/Array.h 2017-10-29 03:42:55 -07:00
testharness remove the blocking getSha1ForBlob method 2017-10-18 10:36:29 -07:00
utils CodeMod: Replace includes of folly/Hash.h with folly/hash/Hash.h 2017-10-29 14:13:56 -07:00