1. 30 Apr, 2018 2 commits
    • 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
  2. 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
  3. 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
  4. 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
  5. 25 Apr, 2018 7 commits
    • Adam Simpkins's avatar
      rename Logging.h to GLog.h · bdb012ae
      Adam Simpkins authored
      Summary:
      Rename folly/Logging.h to folly/GLog.h.  This header primarily exists to just
      include <glog/logging.h>, and it also defines a single `FB_LOG_EVERY_MS()`
      macro.
      
      I plan to move the folly/experimental/logging/ directory to folly/logging/
      soon, and I want to avoid confusing between this `Logging.h` header and the
      separate `folly/logging/` code.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7754543
      
      fbshipit-source-id: c91b8016d303cd0fae9e688e8782b22d095a6554
      bdb012ae
    • Adam Simpkins's avatar
      fix CMake build to link to libunwind correctly again · afa77d5d
      Adam Simpkins authored
      Summary:
      D7642870 accidentally broke linking of folly when libunwind is available.
      It change the code to use the contents of `${FOLLY_LINK_LIBRARIES}` in
      folly-deps.cmake, but libunwind was added to `${FOLLY_LINK_LIBRARIES}` after
      folly-deps.cmake was included, in FollyConfigChecks.cmake.
      
      This moves the check for libunwind to folly-deps.cmake to fix this issue.  All
      of the other checks for external libraries are already in folly-deps.cmake.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7764762
      
      fbshipit-source-id: 922459a7eefcbd92d3d77c02e9c215bb1a5467cc
      afa77d5d
    • Andrii Grynenko's avatar
      Make keep-alive token a valid pointer for every Executor · 708e7e70
      Andrii Grynenko authored
      Summary: This allows using a keep-alive token in places where Executor* was previously used.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7751516
      
      fbshipit-source-id: af2cb31191a78306439408dbee78dcd923492e30
      708e7e70
    • Philip Pronin's avatar
      add PRETTY_TIME_HMS pretty printer · 772e5ce4
      Philip Pronin authored
      Summary:
      `PRETTY_TIME_HMS` extends `PRETTY_TIME` by adding additional minutes
      and hours units which are more useful for human-reporting of time intervals.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7762524
      
      fbshipit-source-id: 881936916db182c163a3df14196f4f11fb649527
      772e5ce4
    • Yedidya Feldblum's avatar
      Avoid using gmock private macros · 5e15f45f
      Yedidya Feldblum authored
      Summary: [Folly] Avoid using gmock private macros - instead, use only the public interface.
      
      Reviewed By: knekritz
      
      Differential Revision: D7752463
      
      fbshipit-source-id: 625465e7ec93613869e259fe1fe0b08aee7bb7d0
      5e15f45f
    • Xiao Shi's avatar
      add `getAllocatedMemorySize` for F14 sets, fix corner cases · f726637b
      Xiao Shi authored
      Summary:
      This diff adds a method to calculate the amount of memory allocated by F14
      sets. It mimics the node structure in `std::unordered_map` to calculate the
      results. For certain keys and hashers, the libstdc++ implementation of
      `std::unordered_map` caches a hash code in the node. libcpp seems to do this
      for everything.
      
      https://github.com/gcc-mirror/gcc/blob/9ce5a00d2d3b8b107cb1ca0e23bf1e31a095f9b6/libstdc%2B%2B-v3/include/bits/hashtable.h#L45-L49
      https://github.com/llvm-mirror/libcxx/blob/58bcf28c63e0cf2ee5828e7811829c98bd244dda/include/__hash_table#L117
      
      Depends on D7715573.
      
      Reviewed By: nbronson
      
      Differential Revision: D7728281
      
      fbshipit-source-id: 0aa3ab60c746d3ab6bdb7c879f2f987110e0329d
      f726637b
    • Orvid King's avatar
      Only enable C++17 usings under MSVC if C++17 mode is enabled · faf8f098
      Orvid King authored
      Summary: Because not everyone is at C++17 yet.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7751672
      
      fbshipit-source-id: bcca4d4da67d56be0217a940144977f1cc98e5a1
      faf8f098
  6. 24 Apr, 2018 6 commits
    • Orvid King's avatar
      Add the concurrency tests to the CMake build · 24eaeed1
      Orvid King authored
      Summary: Add the currency tests to the CMake build so they can be built in open-source.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7750783
      
      fbshipit-source-id: a6e7f9490e0b88bcfab8b2aa706e1504f2a28c66
      24eaeed1
    • Kevin Ventullo's avatar
      Fixing comment · 61acda5e
      Kevin Ventullo authored
      Summary:
      This looked like a copypasta error. Since there is no duration passed
      in, there is no notion of timeout.
      
      Reviewed By: shixiao, Orvid
      
      Differential Revision: D7747574
      
      fbshipit-source-id: 279992d237dd0924ea0be9deafab94c1aef48838
      61acda5e
    • Yedidya Feldblum's avatar
      Fix autotools build afte removing folly/Optional.cpp · c56ca684
      Yedidya Feldblum authored
      Summary: [Folly] Fix autotools build afte removing `folly/Optional.cpp`.
      
      Reviewed By: akrieger
      
      Differential Revision: D7737170
      
      fbshipit-source-id: 1a9286f240bf5a15ee08b707b69377f8d3cfdb48
      c56ca684
    • Anirudh Ramachandran's avatar
      Make AsyncSSLSocket aware of OpenSSL 1.1.0's async API · 72e652d1
      Anirudh Ramachandran authored
      Summary:
      OpenSSL 1.1.0 uses a fiber-based (makecontext/swapcontext) API to do
      asynchronous operations. When some operation deep inside the stack calls
      ASYNC_pause_job, SSL_accept returns -1 with error SSL_ERROR_WANT_ASYNC.
      OpenSSL chose to use fds to wait on, so after SSL_accept returns, we create an
      AsyncPipeReader to restart SSL_accept when the pipe becomes readable, which is our
      indication that the async job processing has finished.
      
      Also implemented a test to kick off an async job in a different thread that creates a pipe
      and gives the read end back to the SSL* before calling ASYNC_pause_job
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5977514
      
      fbshipit-source-id: 3aba2e45b9357dc28cf7cf785654072f8ba8dd65
      72e652d1
    • Matthieu Martin's avatar
      Fiber LoopController's schedule cleanup · 03b404df
      Matthieu Martin authored
      Summary: On top of the recent/big EventBaseLoopController cleanup away from most EventBase internal, this is unecessary
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7734236
      
      fbshipit-source-id: df38cc30fc52df929f096fb878bc1a4b6894850a
      03b404df
    • Murali Vilayannur's avatar
      Expose an interface to expose a given settings' metadata info · 199a5bc8
      Murali Vilayannur authored
      Summary:
      We don't have a way to get the metadata associated with a given setting name
      from outside. This is useful to know the expected type associated with a
      given setting name.
      
      Reviewed By: alikhtarov
      
      Differential Revision: D7721340
      
      fbshipit-source-id: e9ad07dd03c172f6f2d4bde5164614ca987c4fd8
      199a5bc8
  7. 23 Apr, 2018 8 commits
    • Yedidya Feldblum's avatar
      Use throw_exception in Optional · fc471c5e
      Yedidya Feldblum authored
      Summary: [Folly] Use `throw_exception` in `Optional`, which also respects all stated reasons why the `throw` statement is moved to a separate `.cpp` - to outline it and to permit replacement of its implementation with a call to `std::terminate`.
      
      Reviewed By: akrieger
      
      Differential Revision: D7728129
      
      fbshipit-source-id: 0539f9d16a719b52f5a81b13b5d2ce2b61d36de0
      fc471c5e
    • Marc Celani's avatar
      Significantly improve merge performance by leveraging inplace_merge · 9f646cf0
      Marc Celani authored
      Summary:
      The sorting approach used in TDigest is inefficient because it is not leveraging the fact that there are k sorted subarrays. This diff leverages inplace_merge to improve performance.
      
      The cost of merging k digests of size m used to be O(km * log(km)). It is now O(km * log(k)).
      
      Reviewed By: anakryiko
      
      Differential Revision: D7690143
      
      fbshipit-source-id: 1307db153b3cae0bb952d4b872aede8c40ce292c
      9f646cf0
    • Kirk Shoop's avatar
      swap does not compile for Poly · bd1c3af4
      Kirk Shoop authored
      Summary:
      The issue is that std::swap must have the same type for both parameters but the member .swap() for PolyVal takes Poly and then uses std::swap(*this, that).
      
      the fix uses static_cast to change the Poly to a PolyVal for std::swap
      
      Reviewed By: ericniebler
      
      Differential Revision: D7730948
      
      fbshipit-source-id: 8dd93fc3c86b87938a7c0c12ccb3b5209a593730
      bd1c3af4
    • Marc Celani's avatar
      Avoid some unnecessary floating point operations in TDigest · 7aff1428
      Marc Celani authored
      Summary: Further performance improvements to TDigest by diverging from the algorithm in the paper slightly, but in a manner that does not impact the results at all.
      
      Reviewed By: anakryiko
      
      Differential Revision: D7687476
      
      fbshipit-source-id: f71884b0fb21c9e78418643b82b099b01e96e4c9
      7aff1428
    • Yedidya Feldblum's avatar
      Fix build failures in folly/io/async/test/AsyncUDPSocketTest.cpp · 3593da7e
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix build failures in `folly/io/async/test/AsyncUDPSocketTest.cpp`, which uses private gmock macros to try to override base-class member functions marked `noexcept`.
      
      Using private macros belonging to another library is not the way to go.
      
      Reviewed By: siyengar
      
      Differential Revision: D7728285
      
      fbshipit-source-id: 84c96826f25679dfb8dd0ec5e5985c3cc19f6e3d
      3593da7e
    • Marc Celani's avatar
      Improve TDigest merge performance, respect compression factor properly · 5ab8094f
      Marc Celani authored
      Summary:
      I suspect the algorithm in the tdigest paper is slightly off. Instead of setting boundaries at k = 1, 2, 3...d, it sets boundaries at k_last_elem + 1. This results in two issues:
      
      1) It is possible to have more than d elements in the digest. Now, that is no longer possible, and we can properly reserve the right number of elements.
      2) Additional floating point operations are computed than necessary.
      
      Reviewed By: anakryiko
      
      Differential Revision: D7654147
      
      fbshipit-source-id: 131184d456353a9d936c4ed385e2b5e75d468676
      5ab8094f
    • Aaryaman Sagar's avatar
      Remove extra folly:: prefix in folly::lock · 1b41d8dd
      Aaryaman Sagar authored
      Reviewed By: yfeldblum
      
      Differential Revision: D7726522
      
      fbshipit-source-id: fa5ad9fc29152b52c5256849c2822885acd49c23
      1b41d8dd
    • Yedidya Feldblum's avatar
      Cut dead reference to executorLock_ in Futures test · 3e53ef8d
      Yedidya Feldblum authored
      Summary: [Folly] Cut dead reference to `executorLock_` in Futures test - this field was recently removed.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D7725446
      
      fbshipit-source-id: a522b66da77bbefeb69970bee20feea46dcc72a5
      3e53ef8d