1. 14 Jan, 2019 5 commits
    • Yedidya Feldblum's avatar
      Fix folly/io/async/test/SSLContextTest.cpp under gcc8 with -Wshadow · b0c8ad2d
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `folly/io/async/test/SSLContextTest.cpp` under gcc8 with `-Wshadow`.
      
      ```
      folly/io/async/test/SSLContextTest.cpp: In member function 'virtual void folly::SSLContextTest_TestLoadCertificateChain_Test::TestBody()':
      folly/io/async/test/SSLContextTest.cpp:143:31: error: declaration of 'ctx' shadows a member of 'folly::SSLContextTest_TestLoadCertificateChain_Test' [-Werror=shadow]
      folly/io/async/test/SSLContextTest.cpp:29:14: note: shadowed declaration is here
      ```
      
      Reviewed By: knekritz
      
      Differential Revision: D13610440
      
      fbshipit-source-id: 3998a8a7434afdb27e9a89b3e85e87364cd2e72c
      b0c8ad2d
    • Yedidya Feldblum's avatar
      Fix folly/gen/test/ParallelBenchmark.cpp under gcc8 with -Wshadow · e2d788ff
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `folly/gen/test/ParallelBenchmark.cpp` under gcc8 with `-Wshadow`.
      
      ```
      In file included from folly/gen/test/Bench.h:19,
                       from folly/gen/test/ParallelBenchmark.cpp:26:
      folly/Benchmark.h: In instantiation of 'typename std::enable_if<std::is_invocable<Lambda, unsigned int>::value>::type folly::addBenchmark(const char*, const char*, Lambda&&) [with Lambda = <lambda(unsigned int)>; typename std::enable_if<std::is_invocable<Lambda, unsigned int>::value>::type = void]':
      folly/gen/test/ParallelBenchmark.cpp:96:279:   required from here
      folly/Benchmark.h:185:10: error: declaration of 'start' shadows a global declaration [-Werror=shadow]
      folly/gen/test/ParallelBenchmark.cpp:83:6: note: shadowed declaration is here
      ```
      
      Reviewed By: Orvid
      
      Differential Revision: D13605092
      
      fbshipit-source-id: ac791942edbfeda70809d4ab80d21bb3ff7dd8de
      e2d788ff
    • Yedidya Feldblum's avatar
      Fix folly/test/stl_tests/StlVectorTest.cpp under gcc8 with -Wparentheses · bb1efade
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `folly/test/stl_tests/StlVectorTest.cpp` under gcc8 with `-Wparentheses`.
      
      ```
      folly/test/stl_tests/StlVectorTest.cpp: In function 'void test_copyConstruction(std::nullptr_t, Vector&, int)':
      folly/test/stl_tests/StlVectorTest.cpp:1780:11: error: unnecessary parentheses in declaration of 'ca2' [-Werror=parentheses]
      ```
      
      Reviewed By: Gownta
      
      Differential Revision: D13604947
      
      fbshipit-source-id: 36c0b596e07a19d4b282266574d1f4b837d5af4a
      bb1efade
    • Yedidya Feldblum's avatar
      Fix folly/test/small_vector_test.cpp under gcc8 with -Wshadow · a2782696
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `folly/test/small_vector_test.cpp` under gcc8 with `-Wshadow`.
      
      ```
      folly/test/small_vector_test.cpp: In member function 'virtual void small_vector_NoCopyCtor_Test::TestBody()':
      folly/test/small_vector_test.cpp:898:10: error: declaration of 'struct small_vector_NoCopyCtor_Test::TestBody()::Test' shadows a previous local [-Werror=shadow]
      In file included from folly/portability/GTest.h:33,
                       from folly/test/small_vector_test.cpp:33:
      third-party-buck/platform007/build/googletest/include/gtest/gtest.h:371:52: note: shadowed declaration is here
      ```
      
      Reviewed By: Orvid
      
      Differential Revision: D13603337
      
      fbshipit-source-id: 84747335787df4c9288d93f19bd0629c53a68e4d
      a2782696
    • Yedidya Feldblum's avatar
      Fix FixedString taking address of temporary array · 811057f7
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `FixedString` taking address of temporary array with latest versions of GCC.
      
      ```
      In file included from folly/test/FixedStringTest.cpp:20:
      folly/FixedString.h: In instantiation of 'constexpr folly::BasicFixedString<Char, N>& folly::BasicFixedString<Char, N>::erase(std::size_t, std::size_t) [with Char = char; long unsigned int N = 26; std::size_t = long unsigned int]':
      folly/test/FixedStringTest.cpp:421:14:   required from here
      folly/FixedString.h:1466:11: error: taking address of temporary array
      ```
      
      Reviewed By: ericniebler
      
      Differential Revision: D13602969
      
      fbshipit-source-id: fefa24eb00021b205498cbc7ebf7c43595d6aa8c
      811057f7
  2. 13 Jan, 2019 2 commits
    • Eric Niebler's avatar
      Update range-v3 to v1.0-beta from upstream. · 67f61a81
      Eric Niebler authored
      Summary:
      The v1.0-beta branch of range-v3 has better compile times and improved conformance to the C++20 standard range interfaces.
      
      I will update this again when range-v3 v1.0 final is released, but at this point the benefits are great, and I am concerned about interface drift.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13647816
      
      fbshipit-source-id: 340da2c177e1dc053facc84506a96e767e11f10d
      67f61a81
    • Eric Niebler's avatar
      Add allocator_type typedefs to the folly sorted vector types · 9a9d6efb
      Eric Niebler authored
      Summary: All standard containers have an allocator_type typedef; so should sorted_vector_map and sorted_vector_set
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13648217
      
      fbshipit-source-id: ccf0b74af88f77b2b28620317cba8a868e9f9b0f
      9a9d6efb
  3. 12 Jan, 2019 1 commit
    • Yedidya Feldblum's avatar
      Fix crash in SingletonRelaxedCounter · 02447777
      Yedidya Feldblum authored
      Summary: [Folly] Fix crash in `SingletonRelaxedCounter` when recreating threads.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D13645448
      
      fbshipit-source-id: dea09925f1943ebf2141d69b791a9259524c19e1
      02447777
  4. 11 Jan, 2019 6 commits
    • Stepan Palamarchuk's avatar
      Add benchmark for througput of timed_wait with cancelation · 700f1926
      Stepan Palamarchuk authored
      Summary:
      This adds a simple benchmark to measure the throughput of calling `Baton::timed_wait` with later fulfillment of Baton without hitting the timeout. This benchmark is useful to make sure that we don't regress when migrating to HHWheelTimer.
      
      It adds 3 case with 1, 5 and 10000 different timeout values used. Below are the results of running the benchmarks:
      
      ```
      ============================================================================
      folly/fibers/test/FibersBenchmark.cpp           relative  time/iter  iters/s
      ============================================================================
      FiberManagerCancelledTimeouts_Single_300                   366.57ms     2.73
      FiberManagerCancelledTimeouts_Five                         365.44ms     2.74
      FiberManagerCancelledTimeouts_TenThousand                  693.06ms     1.44
      ============================================================================
      ```
      
      Note, that the 10k case is slower because internally `TimeoutController` has `O(num_timeouts)` loop for looking up the correct queue.
      
      Reviewed By: jmswen
      
      Differential Revision: D13624361
      
      fbshipit-source-id: 4c2324229f524b55d9cf2371ec2acca35db6f4ff
      700f1926
    • Stepan Palamarchuk's avatar
      Avoid duplicate call to steady_clock::now · 24e19946
      Stepan Palamarchuk authored
      Summary:
      Currently we call `steady_clock::now` twice within just few instructions (one in `setScheduled` and one in `calcNextTick`) which adds unnecessary overhead.
      
      This diff makes us call it only once and use it for both computation of the deadline and tick number.
      
      This allows to achieve almost ~2x improvement in perf.
      
      Reviewed By: jmswen, vitaut
      
      Differential Revision: D13624360
      
      fbshipit-source-id: 40bc3b3ad5123d22a5edcabd60d91c0f7efcbda7
      24e19946
    • Stepan Palamarchuk's avatar
      Remove HHWheelTimer::Callback::getCurTime and its overrides · 32236ec4
      Stepan Palamarchuk authored
      Summary:
      This function is being overridden in only one class (with a duplicate) that is used in only a single test with no clear semantics of what is being tested (the only effect it has is that cascading logic will see 0, which can be achieved with a simple sleep).
      
      Removing this customization point allows us to avoid doing additional call to steady_clock::now per each timeout (stacked diff) and thus improving performance by ~2x (measured as part of Fibers benchmark after migrating FiberManager to use HHWheelTimer, also stacked).
      
      Reviewed By: jmswen
      
      Differential Revision: D13624362
      
      fbshipit-source-id: ef3abd066d2a4f46b369f65d64dd58399ebf5e46
      32236ec4
    • Kirk Shoop's avatar
      remove stale benchmark report · 136b6536
      Kirk Shoop authored
      Summary: deleting a stale benchmark report
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13632256
      
      fbshipit-source-id: b3ff7e109d51389179cd48c7260ab16cb9eb6e22
      136b6536
    • David Lively's avatar
      introduce TimekeeperScheduledExecutor (adaptor) · 6bef3cca
      David Lively authored
      Summary:
      `TimekeeperScheduledExecutor` adapts a (non-Scheduled) `Executor` to provide a `ScheduledExecutor` interface using a `Timekeeper`.
      
      Note this executor does not hold onto a pointer to the `Timekeeper`, but rather relies on the one returned by the `getTimekeeper` callback arg to `create` (default `folly::details::getTimekeeperSingleton`) when scheduling a task in the future, raising a `TimekeeperScheduledExecutorNoTimekeeper` exception if it returns null.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D13005248
      
      fbshipit-source-id: fc075026f00de763cf5e67c0d7f5e657704e04a3
      6bef3cca
    • Joe Loser's avatar
      Replace std::random_shuffle with std::shuffle (#993) · dc13d4a3
      Joe Loser authored
      Summary:
      - `std::random_shuffle` is deprecated in C++14 and removed in C++17.
      - While `Folly` only depends on C++14, it should not hinder users from
        building in C++17 mode.
      - To support users building with C++17 where `std::random_shuffle` is
        removed from the standard library, migrate the one call site to use
        `std::shuffle`.
      Pull Request resolved: https://github.com/facebook/folly/pull/993
      
      Reviewed By: Orvid
      
      Differential Revision: D13620930
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 630d1125155e022f4b3e804f92c02ec663a86c3b
      dc13d4a3
  5. 10 Jan, 2019 2 commits
    • Chad Austin's avatar
      Disallow constructing folly::Optional with nullptr · b9967308
      Chad Austin authored
      Summary:
      Disallow initializing folly::Optional with nullptr as if it were
      folly::none. The previous behavior was a footgun when transitioning to
      C++17's std::optional. For example, given:
      
      ```
      folly::Optional<bool> o1 = nullptr;
      std::optional<bool> o2 = nullptr;
      ```
      
      o1 would be none, but o2 would have the value `{false}`.
      
      This diff makes the former illegal, preventing behavior changes
      when transitioning to std::optional.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12843022
      
      fbshipit-source-id: 165d19a963672c04d9ec687cb687ca89f1837e21
      b9967308
    • Lewis Baker's avatar
      Revert workarounds for Clang coroutines bugs in tests · c339c77a
      Lewis Baker authored
      Summary:
      The CoroTest.cpp file had some tests that were failing under Clang optimised builds due to a compiler bug.
      
      This rolls back those work arounds to re-expose the bug as a way of validating that the bug has been fixed.
      
      Reviewed By: tks2103
      
      Differential Revision: D13383774
      
      fbshipit-source-id: ac219c6ed0a0c8c3b8c3c06e3d01e5ed4ade81bc
      c339c77a
  6. 09 Jan, 2019 2 commits
  7. 08 Jan, 2019 5 commits
    • Victor Zverovich's avatar
      Minor improvements to Rcu.h · fdac3c4e
      Victor Zverovich authored
      Summary:
      Minor improvements to `Rcu.h`:
      * Spell out the first use of RCU for the sake of people who are not familiar
        with the abbreviation.
      * Correct the default template argument type in the comment: it's `RcuTag`, not
        `void`.
      * Don't expose `rcu_token` constructor to the users because it's only supposed
        to be obtained via `lock_shared`.
      * Make other single-argument constructors explicit to prevent undesirable
        conversions.
      * Parameterize `rcu_token` on the tag type to prevent cross-domain use.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13510133
      
      fbshipit-source-id: d5d214cfa3b30d0857c14ac293da6e4310db1100
      fdac3c4e
    • Victor Zverovich's avatar
      Replace `_t<enable_if<...>>` with `enable_if_t<...>` · c3dd651c
      Victor Zverovich authored
      Summary:
      Since we require C++14 in Folly and use `std::enable_if_t` in some places, there
      is no need for the `_t` workaround. Replace `_t<enable_if<...>>` with
      `enable_if_t<...>`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13511564
      
      fbshipit-source-id: 314b4a63281ce6b8275174ae89fab5fba1101bfb
      c3dd651c
    • Yedidya Feldblum's avatar
      SingletonRelaxedCounter · f2074bfe
      Yedidya Feldblum authored
      Summary: [Folly] `SingletonRelaxedCounter`, a singleton-per-tag relaxed counter.
      
      Differential Revision: D13149336
      
      fbshipit-source-id: 7cf0144758e9595e188465137a336d712c5d9a76
      f2074bfe
    • Yedidya Feldblum's avatar
      Cut unused hazptr dep on Singleton · 80368973
      Yedidya Feldblum authored
      Summary: [Folly] Cut unused `hazptr` dep on `Singleton`.
      
      Reviewed By: magedm
      
      Differential Revision: D13586564
      
      fbshipit-source-id: e0e87807f51f0d050e045961b5e40e600026f182
      80368973
    • Yedidya Feldblum's avatar
      Alias std::apply for libc++ if c++17 · cf24695c
      Yedidya Feldblum authored
      Summary:
      [Folly] Alias `std::apply` for libc++ if c++17, and for msvc.
      
      Fixes #987.
      
      Reviewed By: gkmhub
      
      Differential Revision: D13562821
      
      fbshipit-source-id: b1fef92eed24ce201e50dda72d1ee8b6db9ed6dd
      cf24695c
  8. 07 Jan, 2019 4 commits
  9. 04 Jan, 2019 7 commits
    • Dan Melnic's avatar
      Add takeOwnershipBenchmark IOBuf benchmark · 44f373be
      Dan Melnic authored
      Summary: Add takeOwnershipBenchmark IOBuf benchmark
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13580855
      
      fbshipit-source-id: 6c8e81e580daf8e097be03235f3720e79eadc21f
      44f373be
    • Dan Melnic's avatar
      Expose the IOBuf SharedInfo::userData · ec0bb779
      Dan Melnic authored
      Summary:
      Expose the IOBuf SharedInfo::userData
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13577451
      
      fbshipit-source-id: b52ebbf77d00594a04c26e629d5c208e92801d93
      ec0bb779
    • Lewis Baker's avatar
      folly::coro::Task now preserves RequestContext across suspend/resume points · d5f9c13d
      Lewis Baker authored
      Summary:
      The folly::coro::Task coroutine type now captures the current RequestContext when the coroutine suspends and restores it when it later resumes.
      
      This means that folly::coro::Task can now be used safely with RequestContext and RequestContextScopeGuard.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D9973428
      
      fbshipit-source-id: 41ea54baf334f0af3dd46ceb32465580f06fb37e
      d5f9c13d
    • Nathan Bronson's avatar
      use conditional compilation rather than skip for unsupported tests · 73044d85
      Nathan Bronson authored
      Reviewed By: mengz0
      
      Differential Revision: D13580163
      
      fbshipit-source-id: 195e3007c6cbf4bf7281435c48a9b6f6c6eada5b
      73044d85
    • Andrii Grynenko's avatar
      Make sure SemiFuture can't be used as a inline task · 19febc92
      Andrii Grynenko authored
      Summary:
      Before this change one could write:
        SemiFuture<void> f() {
          co_await f1();
          co_await f2();
        }
      where SemiFuture coroutine would have semantics of an InlineTask (f1 called inline, f2 would be called on the executor which completes f1). This doesn't match the semantics of SemiFuture with deferred work (both f1() and f2() called on the executor that was passed to SemiFuture's via).
      
      Drop support for SemiFuture coroutines, because that isn't used anywhere except for toSemiFuture function.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D13501140
      
      fbshipit-source-id: d77f491821e6a77cef0c92d83839bff538552b32
      19febc92
    • Lewis Baker's avatar
      Add simple SharedMutex to folly::coro · fbe60fe1
      Lewis Baker authored
      Summary:
      Adds a simple SharedMutex type to the folly::coro namespace.
      
      The `co_[scoped_]lock[_shared]()` methods return semi-awaitables that require the caller to provide an executor to resume on in the case that the lock could not be acquired synchronously. This avoids some potential issues that could occur if the `.unlock()` operation were to resume awaiting coroutines inline.
      
      If you are awaiting within a `folly::coro::Task` then the current executor is implicitly provided. Otherwise, the caller can explicitly provide an executor by calling `.viaIfAsync()`.
      
      The implementation has not been optimised and currently just relies on a `SpinLock` to synchronise access to internal state.
      
      The main aim for this change is to make available a SharedMutex abstraction with the desired API that applications can start writing against which we can later optimise as required.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D9995286
      
      fbshipit-source-id: aa141ad241d29daff2df5f7296161517c99ab8ef
      fbe60fe1
    • Orvid King's avatar
      Add functions to get the NetworkSockets out of various types of sockets · 61a8ac33
      Orvid King authored
      Summary: As interim steps to codemod to.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13568657
      
      fbshipit-source-id: b143b5bab0a64c196892358a30fce17037b19b21
      61a8ac33
  10. 03 Jan, 2019 6 commits
    • Nathan Bronson's avatar
      fix F14MapTest on android · f7f0026f
      Nathan Bronson authored
      Summary:
      Skip F14Map.continuousCapacity* tests if intrinsics are not
      available, and don't use c++17 API in the test.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13575479
      
      fbshipit-source-id: 1cbbd10990ba5f0cc64ad1b29d4701b700dd16be
      f7f0026f
    • Nathan Bronson's avatar
      import farmhash · e84801b9
      Nathan Bronson authored
      Summary:
      This diff imports farmhash.h and farmhash.cc from
      https://github.com/google/farmhash and updates the public_tld license
      file accordingly. Build integration and namespace changes will occur in
      later diffs.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13436553
      
      fbshipit-source-id: 7a081032cb35a1a3e1cd14e2edf2685906956396
      e84801b9
    • Nick Terrell's avatar
      Add support for zstd-1.3.8 · ad036b61
      Nick Terrell authored
      Summary:
      Adds support for zstd-1.3.8 so OSS builds work.
      We can support zstd < 1.3.8 for some time with this small compatibility layer.
      I plan on always supporting at minimum the latest 2 zstd versions.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13569550
      
      fbshipit-source-id: 67d53c9ad0051a889b810c9ad46a2f349122cf7e
      ad036b61
    • Tomas's avatar
      Added a precision example (#988) · 8b1bbbf1
      Tomas authored
      Summary:
      Because it wasn't clear for non-python developers. And this document is referenced in Spark AR documentation.
      Pull Request resolved: https://github.com/facebook/folly/pull/988
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13570180
      
      Pulled By: Orvid
      
      fbshipit-source-id: 2e1f787c5e1bb50a90c85a12e6801a79a3b46999
      8b1bbbf1
    • Dan Melnic's avatar
      Add AsyncUDPSocket support for sendmmsg · c533bbd1
      Dan Melnic authored
      Summary: Add AsyncUDPSocket support for sendmmsg
      
      Reviewed By: djwatson
      
      Differential Revision: D13521601
      
      fbshipit-source-id: 89382e18943e01012ff1e56a40f655d634a6e146
      c533bbd1
    • Yedidya Feldblum's avatar
      Add a missing blank line (style nit) · 0c1847c1
      Yedidya Feldblum authored
      Summary: [Folly] Add a missing blank line (style nit).
      
      Reviewed By: lewissbaker
      
      Differential Revision: D13571222
      
      fbshipit-source-id: 1dd23f4fc895e5698f94be6b2cbf90a9f30aae41
      0c1847c1