1. 03 May, 2018 9 commits
    • Orvid King's avatar
      Lower the number of samples in tdigest_test · 021f9853
      Orvid King authored
      Summary: It's timing out in open source test runs because each individual test was taking 10 seconds. They each now take 2.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7841938
      
      fbshipit-source-id: eb81c67cc26e98fb0b4b0c736bea747e985f2fcf
      021f9853
    • Marshall Cline's avatar
      future/semifuture poll() - use ?: · 06e7a0c4
      Marshall Cline authored
      Summary:
      `{Future,SemiFuture}::poll()`:
      - minor chg to impl from assignment to stateless ?:
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7840466
      
      fbshipit-source-id: 201dd7121b713324bb054b72c8ecdf6f4f163b97
      06e7a0c4
    • Andrii Grynenko's avatar
      Always manage lifetime of a SerialExecutor using KeepAlive tokens · f07d48a0
      Andrii Grynenko authored
      Summary: SerialExecutor is always wrapping another Executor, so we shouldn't force users to coordinate their lifetimes.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7856146
      
      fbshipit-source-id: ac7caaa0f181406dfb6b59d36ae4efe6d1343590
      f07d48a0
    • Andrii Grynenko's avatar
      Template KeepAlive with Executor type · d233e724
      Andrii Grynenko authored
      Summary:
      This allows using KeepAlive token as a pointer to an specific Executor sub-type (e.g. SequencedExecutor).
      getKeepAliveToken() has to be a free function to achieve this goal.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7847884
      
      fbshipit-source-id: 95dc62433d30212ceb9b9b2fc7d6b38cb5425311
      d233e724
    • Dave Watson's avatar
      dynamic CPUThreadPoolExecutor · 68a6b5b5
      Dave Watson authored
      Summary:
      This diff adds dynamic thread creation/destruction to ThreadPoolExecutor (mostly CPU).
      
      1) Threads are lazily created when the first task is add()ed (or getEventBase is called), applies to both IO and CPU
      
      and
      
      2) after a timeout in LifoSem, threads are joined in CPUThreadPoolExecutor.
      
      Most of the logic is in ThreadPoolExecutor.  A separate dynamic IOThreadPoolExecutor will be a follow on diff.
      
      To keep the previous behavior, users can set minthread == maxthreads, or gflags --dynamic_cputhreadpoolexecutor=false
      
      Reviewed By: magedm
      
      Differential Revision: D7477390
      
      fbshipit-source-id: 855a35380861111de33656e8fb1b681ae8cd2807
      68a6b5b5
    • Chad Austin's avatar
      formatting typos in Function.md · 484f75dd
      Chad Austin authored
      Summary: Fixes two tiny formatting issues with the folly::Function documentation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7856507
      
      fbshipit-source-id: dc82256a35f6c2b1eb66a868f419f2c800f1ddc5
      484f75dd
    • Yedidya Feldblum's avatar
      Avoid duplicating throw_exception instances taking string literal · 10f5670b
      Yedidya Feldblum authored
      Summary: [Folly] Avoid duplicating throw_exception instances taking string literal, which differ only in the length of the string literal.
      
      Reviewed By: marshallcline
      
      Differential Revision: D7853216
      
      fbshipit-source-id: a4648952cc10661322e5e23c6317ba4b75c268fb
      10f5670b
    • Nathan Bronson's avatar
      destructuring for F14*Set::emplace · 9a33b9b1
      Nathan Bronson authored
      Summary:
      This diff optimizes the operation of F14 set emplace when
      the argument list happens to be a single reference to a key_type.
      An intermediate key_type value is removed in that case, which avoids a
      move in all cases and avoids a copy when the emplace finds that the key
      is already present in the set.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7845720
      
      fbshipit-source-id: 16a639f53993d9843ffe265edd58c0d74de0c1f7
      9a33b9b1
    • Marc Celani's avatar
      shrink_to_fit TDigest after merge · ede7e6eb
      Marc Celani authored
      Summary:
      When used in a QuantileEstimator, some sliding window buckets can be sparse or all together empty. In this case, reserving memory in the constructor and in merge is wasteful. Don't reserve in the constructor (this is a complete waste) and call shrink_to_fit in merge.
      
      It's worth noting that the benchmarks *are* shrinking the digest, because the digests are only 85 or so items big, so it is exercising this path.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7855242
      
      fbshipit-source-id: 61bcbaaf17dd46f8b98d171af43516ceb8d84510
      ede7e6eb
  2. 02 May, 2018 11 commits
    • Steve O'Brien's avatar
      folly/small_vector: remove unneeded include of `type_traits.hpp` · 15c7ad65
      Steve O'Brien authored
      Summary: Included but not used.  Dropped this (expensive) include
      
      Reviewed By: Orvid
      
      Differential Revision: D7781674
      
      fbshipit-source-id: 11180d34cda63ef91f70c64c84bf89346e5d1729
      15c7ad65
    • Marshall Cline's avatar
      Improve Promise move-ctor & move-assign · 4520e4b9
      Marshall Cline authored
      Summary:
      - Promise move ctor: use folly::exchange()
      - Promise move assign: make 33% faster, more eager to release memory, use folly::exchange()
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7838311
      
      fbshipit-source-id: 6d0ee8d3121ab703b3c54c72532f34d66bd4259c
      4520e4b9
    • Marshall Cline's avatar
      fix CoreAndCallbackReference move-ctor · 513eb37d
      Marshall Cline authored
      Summary:
      Fix CoreAndCallbackReference move-ctor so it doesn't call this->detach() (my bad; see D7723078).
      
      Also (for clarity/pedantry/obviousness), explicitly delete the class' move-assignment op.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7848370
      
      fbshipit-source-id: bc051120b3df0557ce9b01cbad8c00a57b8780d8
      513eb37d
    • Dave Watson's avatar
      Only wake a single waker, instead of all waiters · 30b22b4a
      Dave Watson authored
      Summary: Only wake a single waiter.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D6595881
      
      fbshipit-source-id: 9393618bb619cb22b75ca91b27291b784fc5097c
      30b22b4a
    • Dave Watson's avatar
      update small locks benchmark · b4d8c0a7
      Dave Watson authored
      Summary: Re-run small locks bench.  Add server type to comment.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7830168
      
      fbshipit-source-id: 4b60ec6845bb3518a98f4645e521e95599072433
      b4d8c0a7
    • Yedidya Feldblum's avatar
      No need to optimize MicroSpinLock::lock in folly/futures/ · 86087f42
      Yedidya Feldblum authored
      Summary: [Folly] No need to optimize `MicroSpinLock::lock` in `folly/futures/` after {D7828158} (facebook/folly@6f9d8a145e1c37b2b47ff91491c647fe321de787).
      
      Reviewed By: nbronson
      
      Differential Revision: D7843192
      
      fbshipit-source-id: b40bcc0abcfed561a141864e135d72fe33f4067d
      86087f42
    • Matthieu Martin's avatar
      Allow python asyncio Future to wrap folly Fibers · ced29774
      Matthieu Martin authored
      Summary:
      This implements a new AsyncioLoopController for FiberManager, wrapping AsyncioExecutor.
      Thanks to recent simplication of LoopController, if I haven't missed anything, code is fairly simple, though not optimizer for thread-local.
      
      fiber_manager.pxd|pyx allow to link the life-time of AsyncioLoopController/FiberManager to the asyncio event loop.
      Code is similar to (and rely on) executor.pxd|pyd, which does the same for AsyncioExecutor.
      
      fibers.h|pxd provide a helper function for C++/python callers.
      Code is similar to futures.h|pyd, which does the same for folly Future.
      This is the main reason to keep a separate function/callback parameters. Not necessary for fibers, but a generic callback implementation can work for both fibers/future, which is convenient.
      
      There are a few lines that feel duplicated between future/fibers implementation, but it felt overkill to abstract further.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7811432
      
      fbshipit-source-id: af0a07d7554acbab1fac44b7a9a6a98340501ef4
      ced29774
    • Yedidya Feldblum's avatar
      Remove deactivation from Future · 4e033e0c
      Yedidya Feldblum authored
      Summary: [Folly] Remove deactivation, a rarely-used facility, from `Future`.
      
      Reviewed By: marshallcline
      
      Differential Revision: D7788059
      
      fbshipit-source-id: 38db16fc3c2694b3cd772844fdafe71f6033a97c
      4e033e0c
    • Orvid King's avatar
      std::chrono'ize AsyncSSLSocketConnector · ea8e5b3b
      Orvid King authored
      Summary: Nothing breaks so....
      
      Reviewed By: yfeldblum, siyengar
      
      Differential Revision: D4377965
      
      fbshipit-source-id: 53c42e7f6f3a71aedd4b9a089ffca9d3c8472029
      ea8e5b3b
    • Julien Verlaguet's avatar
      Added DefaultKeepAliveExecutor.h to folly/Makefile.am · fd89379f
      Julien Verlaguet authored
      Reviewed By: yfeldblum
      
      Differential Revision: D7832437
      
      fbshipit-source-id: 036a89693e247e0d6356980c3bf9db84d322f408
      fd89379f
    • Matthieu Martin's avatar
      Delete PyGILStateGuard · c366fa15
      Matthieu Martin authored
      Summary: This abstraction is currently only used in functions executed on Python threads, so it should be unecessary.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7828136
      
      fbshipit-source-id: a9ea8b23ffc26505c576106c49e850e1894648d5
      c366fa15
  3. 01 May, 2018 20 commits
    • Orvid King's avatar
      Rename FOLLY_GCC_DISABLE_WARNING to FOLLY_GNU_DISABLE_WARNING · 9bc01de8
      Orvid King authored
      Summary: This should allow better differentation between compilers in situations where warnings need to be disabled for a specific compiler. I've reclaimed the GCC_DISABLE version to have it now refer to only GCC, rather than GCC+CLANG, and also added a version for clang only.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7834730
      
      fbshipit-source-id: 7e0b076f5d9bc55870cfb7e67281190b4add82e6
      9bc01de8
    • Marshall Cline's avatar
      FutureBase::assign() consumes its arg, so pass that arg via rvalue-ref · fce8cf56
      Marshall Cline authored
      Summary:
      future/semifuture move-assignment operators call this->assign(). The latter's arg was passed as an lvalue-ref. Result: now that arg is an rvalue-ref.
      
      Note: I adjusted the assign() calling convention to avoid a forwarding ref. It would have been okay but it's easier to avoid a forwarding-ref than to explain why it happens to always be an rvalue-ref.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7831539
      
      fbshipit-source-id: cf1c66cd498f768905ac3d21e39f693d7a652b39
      fce8cf56
    • Nathan Bronson's avatar
      native aarch64 support for F14 hash tables · 19c316ae
      Nathan Bronson authored
      Summary:
      This diff adds support for the F14 algorithm using the advanced
      SIMD instructions (NEON) that are part of aarch64.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7765273
      
      fbshipit-source-id: 866a8a3481ad60b8aadcfb39718d6a5e62bbe07c
      19c316ae
    • Marshall Cline's avatar
      fix std::move() of a forwarding-ref - use std::forward instead · 25f4df21
      Marshall Cline authored
      Summary:
      Forwarding refs may hold lvalue-refs as well as rvalue-refs, so generally should be forward'd not move'd (to avoid erroneously consuming an lvalue).
      
      The `initial` param of `folly::reduce(first, last, initial, func)` (also used by `folly::reduce(container, initial, func)`) is a forwarding-ref but the code used `std::move(initial)`. Goal: change that to `std::forward<T>(initial)`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7827721
      
      fbshipit-source-id: 12d4ee0ae3cfb0de71269575289c7cd8246eb468
      25f4df21
    • Marshall Cline's avatar
      remove `inline`s that don't add value · b7012f16
      Marshall Cline authored
      Summary: (self explanatory)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7825123
      
      fbshipit-source-id: 60c99950b3af351536c0fd0ba306b5796572e1b6
      b7012f16
    • Marshall Cline's avatar
      constify constifiable methods · 6161b9a5
      Marshall Cline authored
      Summary:
      Make these const:
      - {Future,SemiFuture}::hasValue()
      - {Future,SemiFuture}::hasException()
      - {Future,SemiFuture}::isActive()
      - Promise::throwIfFulfilled()
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7824879
      
      fbshipit-source-id: 035b4bbcfd5b88825580e22b37b13e07158898f3
      6161b9a5
    • Marshall Cline's avatar
      Make CoreAndCallbackReference move-ctor faster, release memory eagerly/sooner · 38f07639
      Marshall Cline authored
      Summary:
      Avoid swap() in move-ctor:
        - slightly faster
        - frees resources eagerly/sooner vs. later
      
      Side benefit: added `noexcept` to a few appropriate methods.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7723078
      
      fbshipit-source-id: f2d08b5ce094c42cb114deda7a6841052d1b785a
      38f07639
    • Aaryaman Sagar's avatar
      Remove Timekeeper.h · 78443cdc
      Aaryaman Sagar authored
      Summary:
      Timekeeper.h had a weird circular dependence issue that would show up when
      included from within the future implementation headers.  The stuff in
      Timekeeper.h should ideally be within the future headers themselves
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D7787275
      
      fbshipit-source-id: a6309c0cc5edca4f5bd12d2651c828299681df54
      78443cdc
    • Adam Simpkins's avatar
      remove Logging.h · cae28c3b
      Adam Simpkins authored
      Summary: Remove the Logging.h shim that was simply redirecting includes to GLog.h
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7783879
      
      fbshipit-source-id: 8d1c1d8501c6a2b067ef72471885fedb3e9f7b10
      cae28c3b
    • Andrii Grynenko's avatar
      Fix NotificationQueueExecutor to use RequestContextScopeGuard · a6ddaecc
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D7819076
      
      fbshipit-source-id: 1dae43c27b88ea1a78d2a54f556687e8c4bbc008
      a6ddaecc
    • Yi Cheng's avatar
      Add previous for EliasFano · 1f5581d8
      Yi Cheng authored
      Summary: Add previous for EliasFano reader. Here the equation is: reader == reader.next().previous();
      
      Reviewed By: ot
      
      Differential Revision: D7497171
      
      fbshipit-source-id: 33dc3316036b94a5da278c328322ea4c3322588e
      1f5581d8
    • Marshall Cline's avatar
      Fix "segfault if consumed/moved-out" in Future/SemiFuture/Promise · 57e4ac80
      Marshall Cline authored
      Summary:
      - Fix all cases of "segfault if consumed/moved-out"
        - In Future, SemiFuture, Promise.
        - Those now throw NoState instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7721921
      
      fbshipit-source-id: 76fafcbd30e23d63150196d3d7e404f348b220f2
      57e4ac80
    • Alex Chow's avatar
      Add global ThreadPoolExecutor list, support naming ThreadPoolExecutors · 7e5f29b8
      Alex Chow authored
      Summary: There isn't a good way to access ThreadPoolExecutors to add instrumentation, such as grabbing basic stats on all executors to better understand pool capacity. This provides a way to do that.
      
      Reviewed By: yfeldblum, djwatson
      
      Differential Revision: D7658144
      
      fbshipit-source-id: 3e72acdccf25742b76d438d2895d586049a0cc17
      7e5f29b8
    • Marc Celani's avatar
      Optimize MicroSpinLock for the unlocked case · 6f9d8a14
      Marc Celani authored
      Summary:
      MicroSpinLock was doing a non-relaxed load before cas, which seems odd because typically we expect spin locks to be unlocked. This diff flips the order and assumes the lock is unlocked before doing a load-loop.
      
      While the benchmark results for SmallLocksBenchmark are a little mixed, the results in a more real world use case in stats/DigestBuilderBenchmark show that this is a real winner.
      
      Reviewed By: djwatson
      
      Differential Revision: D7828158
      
      fbshipit-source-id: e195b9739ce931a67a39ffb9715a228aef59f6bc
      6f9d8a14
    • Doug Rabson's avatar
      Add SIGQUIT to the fatal signals list · 2378b40e
      Doug Rabson authored
      Summary: Some infrastructure sends `SIGQUIT` to stuck processes and we would like to be able to log stacktraces for these.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7819980
      
      fbshipit-source-id: d99a1232ca259bd95aed82505751e6591af748ff
      2378b40e
    • Marc Celani's avatar
      Re-run SmallLocksBenchmark · c0511309
      Marc Celani authored
      Summary:
      Just re-running it on newer hardware:
      
      32 processors
      model name      : Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7828138
      
      fbshipit-source-id: 30a25c6bf7bd0294f32f7598c701b49f045ab235
      c0511309
    • Steve O'Brien's avatar
      folly/fibers/Traits: remove dependency on boost/type_traits · 1b2c1c83
      Steve O'Brien authored
      Summary: Small change so that a template class `ExtractFirstArg` can do the same thing without relying on an expensive header, `boost/type_traits.hpp`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7781675
      
      fbshipit-source-id: 1e5f431217da6cdd31ba1d77a8fc2b19a43808aa
      1b2c1c83
    • Steve O'Brien's avatar
      folly/ThreadLocal: remove dependency on iterator_facade · 641b9df1
      Steve O'Brien authored
      Summary: In a test build `<iterator/iterator_facade>` showed up as the most heavyweight include.  Remove this include, dependency on the boost lib, and implement whatever's needed for the bidirectional iterator interface.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7781659
      
      fbshipit-source-id: 380e0ae85b18c245845f479b2d268fdd3e16d54a
      641b9df1
    • Adam Simpkins's avatar
      move folly/experimental/logging to folly/logging/ · f3bc89fd
      Adam Simpkins authored
      Summary:
      Promote the folly logging code out of the experimental subdirectory.
      We have been using this for several months in a few projects and are pretty
      happy with it so far.
      
      After moving it out of the experimental/ subdirectory I plan to update
      folly::Init() to automatically support configuring it via a `--logging` command
      line flag (similar to the initialization it already does today for glog).
      
      Reviewed By: yfeldblum, chadaustin
      
      Differential Revision: D7755455
      
      fbshipit-source-id: 052db34c97f7516728f7cbb1a5ad959def2f6efb
      f3bc89fd
    • Marc Celani's avatar
      Track min and max in TDigest, do not allow estimates to go out of bounds · b9d5fd6e
      Marc Celani authored
      Summary: As title. We were special casing q == 1 or q == 0 improperly before. This led to some strange results where p100 < p99.9. Track min and max (useful anyway), and use those for boundaries.
      
      Reviewed By: anakryiko
      
      Differential Revision: D7800645
      
      fbshipit-source-id: 5fa3e1d0d286d4b31442196ba74b072030706786
      b9d5fd6e