1. 01 May, 2018 18 commits
    • 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
    • Orvid King's avatar
      Support multi-config platforms when finding gmock · 13d672be
      Orvid King authored
      Summary: This should fix running tests in a vcpkg environment.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7822368
      
      fbshipit-source-id: a549febeb0bbea7208386cbed8a6ecb316b98661
      13d672be
    • Orvid King's avatar
      Use uint32_t rather than uint · c2d90c70
      Orvid King authored
      Summary: Because Windows doesn't have `uint` as it's non-standard.
      
      Reviewed By: djwatson
      
      Differential Revision: D7821774
      
      fbshipit-source-id: 4f7ff4468fc56052e28995f386e194fe70c6c513
      c2d90c70
    • Orvid King's avatar
      Use ThreadPtr in CPUThreadPoolExecutor to match the declaration · 71fe1d6a
      Orvid King authored
      Summary: Because it makes Visual Studio's intellisense happier, and it's always better to match exactly, rather than matching implicitly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7821865
      
      fbshipit-source-id: 9e2380884b2d8d12944e3a3fc921e532208b1791
      71fe1d6a
  2. 30 Apr, 2018 5 commits
    • Matthieu Martin's avatar
      Rename NotificationQueueExecutor to AsyncioExecutor · 5840d67a
      Matthieu Martin authored
      Summary:
      And move it to folly::python namespace.
      We are going to make the python bridge work with fibers. This will require to make changes to this executor that are quite specific for the python use case.
      It doesn't hurt to remove YetAnotherExecutor choice from the main executor directory.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7811125
      
      fbshipit-source-id: eec21ccbbbad58aaa795df661ba58f67fa177645
      5840d67a
    • Xiao Shi's avatar
      mark inline library functions `noexcept` · 32e28492
      Xiao Shi authored
      Summary:
      As per discussions on D7784214, to be consistent with the functions used by the
      integral_hasher, mark these `noexcept`. Not much benefit for this diff other
      than consistency.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7797826
      
      fbshipit-source-id: 382c82556efd261841f3f6fb2ae892d26f3ceb0b
      32e28492
    • Stepan Palamarchuk's avatar
      Fix handling time counters · 533ea0cb
      Stepan Palamarchuk authored
      Summary:
      Currently we'll are getting incorrect Idle&Busy time counters for loops when there were no LoopCallbacks. This is because we don't properly refresh the `startWork_` and use the one from the last loop that had LoopCallbacks.
      
      This diff fixes that by properly refreshing `startWork_` even if there're no LoopCallbacks.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7811127
      
      fbshipit-source-id: 94ded08963b1bddc7b7859484f076d4c8a1e897f
      533ea0cb
    • Subodh Iyengar's avatar
      Fix shadow in AsyncUDPSocketTest · 62e3abb2
      Subodh Iyengar authored
      Summary: Fix shadown warning for xplat builds
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7811636
      
      fbshipit-source-id: 609b5acaca3cfdd11059ed1ebbaa969e281487a2
      62e3abb2
    • Subodh Iyengar's avatar
      add connect method to AsyncUDPSocket · 50c13594
      Subodh Iyengar authored
      Summary:
      Calling connect on the UDP socket can avoid route lookups
      on the write path. This would be an optimization that would be
      useful for clients.
      
      There are several caveats of using connect() which we discovered
      during testing. These are documented and unit tests have been written
      for each of them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7802389
      
      fbshipit-source-id: 09b71373a3a95c5dab73ee9345db0dbbf66d4ec5
      50c13594
  3. 28 Apr, 2018 4 commits
    • Marc Celani's avatar
      Move a function to .cpp file · 7a500026
      Marc Celani authored
      Summary: Some links are complaining of multiple definitions. Move to the cpp file to resolve.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7806874
      
      fbshipit-source-id: f25342d647505b676ba3659400c63d6a59344024
      7a500026
    • Marc Celani's avatar
      Remove emmintrin.h header from TDigest.cpp · 410c0a02
      Marc Celani authored
      Summary: This header is no longer needed since D7687476.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7804756
      
      fbshipit-source-id: 6596f5296965b593ab5b0decf4c67203e19b03c8
      410c0a02
    • Marc Celani's avatar
      Missing pragma once in QuantileEstimator-defs.h · 3490edad
      Marc Celani authored
      Summary: As title
      
      Reviewed By: tageorgiou
      
      Differential Revision: D7804647
      
      fbshipit-source-id: 9a58de258cd49a4d15ded05163975304c0e7e83b
      3490edad
    • Marc Celani's avatar
      Build fix for gcc · d60962e9
      Marc Celani authored
      Summary: This worked in clang but not in gcc. Quick fix
      
      Differential Revision: D7800576
      
      fbshipit-source-id: fcd04c0779f8a176043f3dede61289830a1ef607
      d60962e9
  4. 27 Apr, 2018 10 commits
    • Marc Celani's avatar
      QuantileEstimator · 69286490
      Marc Celani authored
      Summary: Introduces two QuantileEstimators. Both estimators use the TDigest for estimating quantiles, and giving accurate sum, count, and mean. One estimator uses a single digest, and the other uses a SlidingWindow of 60 digests. All writes to the data structure are buffered for 1 second.
      
      Reviewed By: anakryiko
      
      Differential Revision: D7645824
      
      fbshipit-source-id: 4f1f2c25388c3280f148591502449f857c6467d3
      69286490
    • Yedidya Feldblum's avatar
      Use invoke_result v.s. std::result_of · d767d0b5
      Yedidya Feldblum authored
      Summary: [Folly] Use `invoke_result` v.s. `std::result_of`, which is deprecated.
      
      Reviewed By: aary, ericniebler
      
      Differential Revision: D7771480
      
      fbshipit-source-id: 1d89d489be98bfbe2014f2d6b5fc037f02147876
      d767d0b5
    • Yedidya Feldblum's avatar
      Cut unused alias isFutureResult · 510f0b03
      Yedidya Feldblum authored
      Summary: [Folly] Cut unused alias `isFutureResult`.
      
      Reviewed By: Orvid
      
      Differential Revision: D7787146
      
      fbshipit-source-id: 44ed51e9e04c71530f67fc6dceb76b247dcadb55
      510f0b03
    • Léonard Gérard's avatar
      Fix LIBCPP cmake check · 33428ecb
      Léonard Gérard authored
      Summary:
      The test was missing a `main` meaning that it would fail even if libc++ was in use, making all the rest fail on macos for example.
      Closes https://github.com/facebook/folly/pull/831
      
      Reviewed By: Orvid
      
      Differential Revision: D7787115
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 4a10323298be3f26f783fa1257cbde2483fb75b9
      33428ecb
    • Xiao Shi's avatar
      mark numerical hasher(s) noexcept · b61b327d
      Xiao Shi authored
      Summary:
      The libstdc++ implementation of `std::unordered_map|set` determines whether to
      cache a per-node hash code based on (1) whether the supplied hasher is fast
      (true by default) and (2) whether the hashing operation will throw.
      
      Mark the `operator()` of hashers of numeric types (integral, float, enum)
      `noexcept`, such that stl unordered containers won't cache a hash code. This is
      essentially free memomy savings, as comparing the cached hash code is as
      expensive as comparing the numerical types directly.
      
      Reviewed By: luciang
      
      Differential Revision: D7784214
      
      fbshipit-source-id: 020e1c38265f33a482b6ba913a11f1a383e840f8
      b61b327d
    • Andrii Grynenko's avatar
      Implement KeepAlive mechanism for thread pool executors · c4350342
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D7765404
      
      fbshipit-source-id: 3f09d6806d0fb98cb59529adc6ea2d51fa7ccbbb
      c4350342
    • Marc Celani's avatar
      BufferedStat · 1aaded41
      Marc Celani authored
      Summary:
      BufferedStat hooks up the DigestBuilder and a Digest or a SlidingWindow
      
      Every windowDuration time, the DigestBuilder builds a new digest that will be merged into the central data structure (either a digest or a sliding window of digests).
      
      This diff removes the shared buffer from DigestBuilder, as the concurrency model was getting overly complex with it.
      
      Reviewed By: simpkins
      
      Differential Revision: D7629082
      
      fbshipit-source-id: 54027363d37c0fdced287550eea5b12caf6b8138
      1aaded41
    • Yedidya Feldblum's avatar
      Use is_invocable_r in MapUtil · bf3343eb
      Yedidya Feldblum authored
      Summary: [Folly] Use `is_invocable_r` in `MapUtil` v.s. reimplementing it.
      
      Reviewed By: aary
      
      Differential Revision: D7771481
      
      fbshipit-source-id: 41565a06198ed2289206f01a088c3c1b3a01bc8e
      bf3343eb
    • Yedidya Feldblum's avatar
      Use is_invocable_r in FunctionRef · 9df80a87
      Yedidya Feldblum authored
      Summary: [Folly] Use `is_invocable_r` in `FunctionRef` v.s. reimplementing it.
      
      Reviewed By: ot
      
      Differential Revision: D7769745
      
      fbshipit-source-id: 3cb7bf9908cc6e93c7d19ace9a91c69ba14cdfae
      9df80a87
    • Mingtao Yang's avatar
      X509_CRL_get0{last,next}Update portability shims · 7884d6d8
      Mingtao Yang authored
      Summary:
      OpenSSL 1.1.0 renamed and deprecated X509_CRL_get_lastUpdate -> X509_CRL_get0_lastUpdate
      along with X509_CRL_get_nextUpdate -> X509_CRL_get0_nextUpdate
      
      Reviewed By: ngoyal, anirudhvr, Orvid
      
      Differential Revision: D7782339
      
      fbshipit-source-id: 63f04284bb54da87d4235a02890107db8abaa4b4
      7884d6d8
  5. 26 Apr, 2018 3 commits
    • Igor Sugak's avatar
      fix -Wreturn-std-move errors · b5105fc5
      Igor Sugak authored
      Summary:
      This was exposed by the latest clang with -Wreturn-std-move enabled:
      ```lang=bash
      folly/FBString.h:2487:12: error: local variable 'rhs' will be copied despite being returned by name [-Werror,-Wreturn-std-move]
          return rhs;
                 ^~~
      folly/test/FBStringTest.cpp:1294:23: note: in instantiation of function template specialization 'folly::operator+<char, std::char_traits<char>, std::allocator<char>, folly::fbstring_core<char> >' requested here
          auto test1 = '\0' + std::move(s1);
                            ^
      folly/FBString.h:2487:12: note: call 'std::move' explicitly to avoid copying
          return rhs;
                 ^~~
                 std::move(rhs)
      2 errors generated.
      ```
      
      Reviewed By: Orvid
      
      Differential Revision: D7776805
      
      fbshipit-source-id: f11ae5a1fc416b8838b8ea74d7f6b488f07cab38
      b5105fc5
    • Dave Watson's avatar
      Drop read lock from getPendingTaskCountImpl · 4e12f97c
      Dave Watson authored
      Summary: Need to also allow calling this function with a writeLock.
      
      Reviewed By: magedm
      
      Differential Revision: D7477326
      
      fbshipit-source-id: 403e2667a3f77be4c1d7d06dbd5f36218a659abc
      4e12f97c
    • Chao Yang's avatar
      folly::to test for trailing space · d0bddaa0
      Chao Yang authored
      Summary: The test is intended to verify the handling of trailing space.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7761229
      
      fbshipit-source-id: 0196f57e6c76562562ef1b724f6dff1c7bfd5d81
      d0bddaa0