1. 07 May, 2018 5 commits
    • Yedidya Feldblum's avatar
      Fix outdated mention of TSSLSocketFactory · 2c2452d0
      Yedidya Feldblum authored
      Summary: [Folly] Fix outdated mention of `TSSLSocketFactory`.
      
      Reviewed By: stevegury, knekritz
      
      Differential Revision: D7892382
      
      fbshipit-source-id: 7b267e5de857f9c5976b26d53d36b1545a46af2a
      2c2452d0
    • Yedidya Feldblum's avatar
      Use size_t for ThreadPoolExecutor::getPendingTaskCountImpl · a463b55e
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `size_t` for `ThreadPoolExecutor::getPendingTaskCountImpl`, as it is the canonical size type for counting the number of entries in in-memory data structures.
      
      Prevents confusion when using values returned from this function with other sizes, especially in contexts where the two types are required to match as might occur in calls to `std::min` without explicitly specifying the type.
      
      Fixes #843.
      
      Reviewed By: djwatson
      
      Differential Revision: D7898443
      
      fbshipit-source-id: eec789f661351d09545bc7118f2e4b3587fd7302
      a463b55e
    • Dan Melnic's avatar
      Add thread local destroy benchmark · 82a8271d
      Dan Melnic authored
      Summary: Add thread local destroy benchmark
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7892479
      
      fbshipit-source-id: f16462820354a6cf27d9348a76b28be027cef20c
      82a8271d
    • Marshall Cline's avatar
      Future::get() - make postcond testable by callers · 7c9d20fd
      Marshall Cline authored
      Summary:
      SemiFuture::get() & Future::get() both render the `this` object in a consumed / moved-out state. However Future::get()'s postcondition was untestable by callers - it consumed the value within the core but left `this->valid()` true.
      
      Goal: make Future::get():
      - function like SemiFuture::get()
      - testable by callers (see `valid()`)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7840699
      
      fbshipit-source-id: 5102e9c3de026c021bf322b5109aafcc115207a2
      7c9d20fd
    • Marshall Cline's avatar
      add valid() to Future, SemiFuture, Promise · afb57872
      Marshall Cline authored
      Summary:
      Lets callers determine whether a Future/SemiFuture/Promise has a shared-state.
      `x.valid()` (where `x` is a Future, SemiFuture, or Promise) is is true if/only if the object has a shared state.
      
      The `valid()` method will also be key in a near-term diff that will use it to clarify the contracts/rules.
      
      Note: the concept of validity already shows up in the doc-blocks; this gives callers a conceptual oppty to check it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7839038
      
      fbshipit-source-id: f8390b3d1a8c3d5d89356ae48937e03c424d1174
      afb57872
  2. 06 May, 2018 1 commit
    • Léonard Gérard's avatar
      Remove implied POSITION_INDEPENDENT_CODE property · 7897c65f
      Léonard Gérard authored
      Summary:
      PIC is implied by BUILD_SHARED_LIBS in CMake, so the test is confusing.
      Note that if one wants to build static and use it to create a shared library with it, he will need to compile either shared
      or static with CMake option -DCMAKE_POSITION_INDEPENDENT_CODE
      Closes https://github.com/facebook/folly/pull/833
      
      Reviewed By: Orvid
      
      Differential Revision: D7890111
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: e3996cb83d30ae368dc5fdd4f55b721f7f89d0a0
      7897c65f
  3. 05 May, 2018 1 commit
    • Alex Yarmula's avatar
      add a repeat-n-times overload to folly::window · 54ee5225
      Alex Yarmula authored
      Summary:
      Add the ability to use folly::window without providing a vector ahead of time.
      This allows window to scale to a large number of iterations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7863481
      
      fbshipit-source-id: 86c6b7926e9c3b7510233fac20a50c1fb38f5b57
      54ee5225
  4. 04 May, 2018 5 commits
    • Andrii Grynenko's avatar
      Fix casting operators in Executor::KeepAlive · 8b829f52
      Andrii Grynenko authored
      Summary:
      Pointer value may change when casting.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: lbrandy
      
      Differential Revision: D7884048
      
      fbshipit-source-id: aa55e1b3530bc28f7d2ffd356761d962d6029832
      8b829f52
    • Matthieu Martin's avatar
      Implement KeepAlive in AsyncioLoopController · 64b6d1b6
      Matthieu Martin authored
      Summary:
      I'm continue to try keeping the implementation simple, instead of copy-pasting EventBase/EventBaseLoopController code.
      My understanding is that AsyncioExecutor/AsyncioLoopController will always be single threaded because they are tied to a unique asyncio event_loop, so I don't need an atomic counter.
      Then it should be cheap to just always aquire/release the counter in runLoop.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7875202
      
      fbshipit-source-id: 900a03e6870c5e4828521a99785cfa976baac54a
      64b6d1b6
    • Matthieu Martin's avatar
      Add FiberManager::Options parameter to folly::python::getFiberManager · 7672324a
      Matthieu Martin authored
      Summary:
      Copied the `const folly::fibers::FiberManager::Options& opts = {}` signature from main `getFiberManager`.
      Discussed with Andrii if I should key the FiberManager cache by options' address, but he voted to keep the behavior consistent with FiberManagerMap.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7873868
      
      fbshipit-source-id: 0c7f6e6ef0ebe50d9658c2eee7ab1e098dd86ddd
      7672324a
    • Yedidya Feldblum's avatar
      Fix Build: folly/io/RecordIO.cpp under MSVC 2015u3 · 0a511014
      Yedidya Feldblum authored
      Summary: [Folly] Fix Build: `folly/io/RecordIO.cpp` under MSVC 2015u3, which inexplicably gives `error C2872: 'detail': ambiguous symbol`.
      
      Reviewed By: Orvid
      
      Differential Revision: D7875032
      
      fbshipit-source-id: 2ff5a60c941e20ef9a05cedb2e7d8224a9e83ed2
      0a511014
    • Andrii Grynenko's avatar
      Reduce KeepAlive object size to 1 pointer · 367d3cfa
      Andrii Grynenko authored
      Summary: Use a single pointer to store Executor pointer and dummy flag.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7857087
      
      fbshipit-source-id: 529fbfdc6ad14954f5bdd9bef3eb1e335b233ec9
      367d3cfa
  5. 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
  6. 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
  7. 01 May, 2018 8 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