1. 23 Jun, 2020 4 commits
    • Lewis Baker's avatar
      Add folly::StrandExecutor type · c289b7f5
      Lewis Baker authored
      Summary:
      This diff adds a new StrandExecutor executor-type that is similar
      to SerialExecutor in that it serialises execution of work enqueued
      to it, but is more general in that it allows different tasks to be
      executed on different executors.
      
      To do this, it separates the queue out into a StrandContext object
      which can be passed to multiple StrandExecutor objects, allowing them
      each to share a queue, while allowing each StrandExecutor to dispatch
      work queued to it to a different parent Executor.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D21848165
      
      fbshipit-source-id: 4dda6bd13a9cd5b275a11f13101242cd73b327e7
      c289b7f5
    • Shrikrishna Khare's avatar
      fbcode_builder: getdeps: OpenNSA update source URL · 59ce0d0d
      Shrikrishna Khare authored
      Summary:
      We had to fork OpenNSA and clone from it, see D19437386 for details.
      Broadcom has now started hosting OpenNSA as a tarball.
      Thus, we no longer need to maintain a fork (yay!)
      
      This patch points opennsa manifest to fetch opennsa from this new location.
      
      Reviewed By: bkoray
      
      Differential Revision: D22175932
      
      fbshipit-source-id: 51cd777ab836e4f191d78fbb2312925e446ca38f
      59ce0d0d
    • Zeyi (Rice) Fan's avatar
      fix encoding bug · 66e13083
      Zeyi (Rice) Fan authored
      Summary: This bug can be triggered when your computer name contains emoji. getdeps.py will fail to create this file due to Python attempts to write the file as cp1252 (Windows's default encoding)
      
      Reviewed By: wez
      
      Differential Revision: D22171935
      
      fbshipit-source-id: fc3be2d1050c17ddbe05a0fc91d6613865f092ce
      66e13083
    • Giuseppe Ottaviano's avatar
      Specialize F14Table default constructor to avoid reserve() instantiation · f74b4d5f
      Giuseppe Ottaviano authored
      Summary: F14 class member fields are often in headers, and often the default constructor is implicit. The current implementation unconditionally instantiates `reserve()`, which has non-negligible cost. By specializing the default constructor we can avoid that in the common case.
      
      Reviewed By: philippv, luciang
      
      Differential Revision: D22166465
      
      fbshipit-source-id: d31ebc7f6ab71392d49a6722545f8df9027d034b
      f74b4d5f
  2. 22 Jun, 2020 1 commit
  3. 21 Jun, 2020 2 commits
    • Dan Melnic's avatar
      Try to fix the OSS build · 2f7890ec
      Dan Melnic authored
      Summary: Try to fix the OSS build
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22145695
      
      fbshipit-source-id: a1290441b982f8df78ffa8dcd772f0c02c4535aa
      2f7890ec
    • Yedidya Feldblum's avatar
      Missing public base class for unicode_error · b974fa36
      Yedidya Feldblum authored
      Summary: [Folly] Missing public base class for `unicode_error`. which should publicly inherit `std::runtime_error`.
      
      Reviewed By: Mizuchi
      
      Differential Revision: D22153547
      
      fbshipit-source-id: 4c60e8e072f0fc9240d199b6d81c7e85c99eaf34
      b974fa36
  4. 19 Jun, 2020 4 commits
    • Giuseppe Ottaviano's avatar
      Kill small skip optimization in EliasFanoReader · b7eba90d
      Giuseppe Ottaviano authored
      Summary:
      These optimizations were introduced in D1793554, mostly to mitigate the high cost of `select64`. We've had an efficient implementation of `select64` for Haswell for a while, and Haswell is more than 5 years old, so we can drop the optimization, which actually harms performance on modern microarchitectures.
      
      While on a real workload this shows significant benefits, the microbenchmarks for very small skips are degraded:
      ```
      ============================================================================  ====================
      folly/experimental/test/EliasFanoCodingTest.cpp relative  time/iter  iters/s    time/iter  iters/s
      ============================================================================  ====================
      Next                                                         2.58ns  388.22M       2.55ns  391.93M
      Skip_ForwardQ128(1)                                          4.81ns  207.72M       4.31ns  231.79M
      Skip_ForwardQ128(2)                                          5.96ns  167.75M       4.67ns  214.07M
      Skip_ForwardQ128(4_pm_1)                                     7.40ns  135.16M       4.87ns  205.29M
      Skip_ForwardQ128(16_pm_4)                                    8.20ns  121.97M       5.38ns  185.93M
      Skip_ForwardQ128(64_pm_16)                                  12.04ns   83.06M       8.97ns  111.51M
      Skip_ForwardQ128(256_pm_64)                                 16.84ns   59.39M      13.19ns   75.79M
      Skip_ForwardQ128(1024_pm_256)                               17.67ns   56.61M      14.19ns   70.45M
      Jump_ForwardQ128                                            25.37ns   39.41M      25.47ns   39.26M
      ----------------------------------------------------------------------------  --------------------
      SkipTo_SkipQ128(1)                                           7.27ns  137.59M      10.77ns   92.87M
      SkipTo_SkipQ128(2)                                          10.99ns   91.01M      14.39ns   69.51M
      SkipTo_SkipQ128(4_pm_1)                                     13.53ns   73.93M      16.15ns   61.90M
      SkipTo_SkipQ128(16_pm_4)                                    20.58ns   48.59M      17.72ns   56.45M
      SkipTo_SkipQ128(64_pm_16)                                   32.08ns   31.18M      31.16ns   32.09M
      SkipTo_SkipQ128(256_pm_64)                                  38.66ns   25.87M      38.22ns   26.16M
      SkipTo_SkipQ128(1024_pm_256)                                42.32ns   23.63M      42.07ns   23.77M
      JumpTo_SkipQ128                                             47.95ns   20.86M      47.85ns   20.90M
      ----------------------------------------------------------------------------  --------------------
      Encode_10                                                  103.99ns    9.62M     104.89ns    9.53M
      Encode                                                       7.60ms   131.53       7.55ms   132.46
      ----------------------------------------------------------------------------  --------------------
      defaultNumLowerBits                                          3.59ns  278.69M       3.61ns  276.97M
      slowDefaultNumLowerBits                                     10.88ns   91.90M      10.98ns   91.06M
      ============================================================================  ====================
      ```
      
      It is important to note however that these micro-benchmarks have very little variability in terms of effective skip distance for small skips, producing almost perfect branch prediction in the linear scan loop. In a real workload, the overhead of branch misprediction ends up being significant.
      
      Reviewed By: philippv
      
      Differential Revision: D22139846
      
      fbshipit-source-id: 8df17a74aa57c92413709d9e11c60a77d5462422
      b7eba90d
    • Giuseppe Ottaviano's avatar
      Better compiler hints in EliasFanoCoding · f1dd8b18
      Giuseppe Ottaviano authored
      Summary: Without FDO Clang generates very suboptimal code, adding this hints brings it almost to parity with FDO-compiled code.
      
      Reviewed By: philippv, luciang
      
      Differential Revision: D22139847
      
      fbshipit-source-id: 2cdaf383ca1afd21db1b7ad2aafb3d3c7ce335b0
      f1dd8b18
    • Mikhail Shatalov's avatar
      Avoid shared_ptr copy in EventBaseLocal::getOrCreate · 28fd04bd
      Mikhail Shatalov authored
      Summary: `folly::get_default()` returns a copy of shared_ptr that gets immediately discarded. The change avoids that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22119215
      
      fbshipit-source-id: 36aab580d7042d19b6b076cad20586697fbfa5e3
      28fd04bd
    • Matthieu Martin's avatar
      async::promiseWait · d0b905b1
      Matthieu Martin authored
      Summary:
      Provide an Async wrapper for fibers::await, which blocks current task until promise is fulfilled.
      This isn't a build block that is used in very common scenario, so prefered to put it in its own file.
      
      Differential Revision: D22135318
      
      fbshipit-source-id: 753dbefc4ac9a907f5b1f656f70291c88187b5e8
      d0b905b1
  5. 18 Jun, 2020 3 commits
    • Zhengxu Chen's avatar
      Make RequestContext rootid value atomic in RequestContext::StaticContext. · 72e91069
      Zhengxu Chen authored
      Summary:
      Currently RequestContext::getRootidsFromAllThreads() can access StaticContext root ids concurrently with RequestContext::setRequestContext() without synchronization guards, which is not safe cross other platforms than x64 and also causing TSAN warnings when used in server contexts.
      Therefore we can make it std::atomic and access it with relaxed order. This won't affect performance in major platform like x64 since the loads/stores instructions will be the same.
      Also as a side effect this prevents RequestContext::StaticContext from generating copy/move constructor, so we remove an extra copy of root id in StaticContext in setRequestContext path.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22083558
      
      fbshipit-source-id: ed70e394f1172b07ba00c15f05a370f84265785c
      72e91069
    • darionyaphet's avatar
      Fix typo about Executor (#1386) · 7e9c1601
      darionyaphet authored
      Summary: Pull Request resolved: https://github.com/facebook/folly/pull/1386
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21992975
      
      Pulled By: Orvid
      
      fbshipit-source-id: 7d52e3e9f8db899079263ef15e9f1bbfbedadc44
      7e9c1601
    • Michael Park's avatar
      Remove `TIMED_SYNCHRONIZED(_CONST)` and replace its usage with `wlock`/`rlock` functions. · e2886185
      Michael Park authored
      Summary: This macro has been deprecated and given that there are not that many uses, it seems relatively simple to remove it entirely.
      
      Reviewed By: yfeldblum, aary
      
      Differential Revision: D16904736
      
      fbshipit-source-id: 56daffd480c586be2a5636b3ce20c6fe1d5ea018
      e2886185
  6. 17 Jun, 2020 8 commits
    • Andrii Grynenko's avatar
      Add a method to disable shutdown timer · 266c62de
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D22071829
      
      fbshipit-source-id: c7f0e1bc5a4257731bafee09144c33c9fb474e10
      266c62de
    • Doug Rabson's avatar
      Remove unused type alias · 29adc304
      Doug Rabson authored
      Summary: The ValueType alias in the multiplex function is not used and caused a build failure when I tried to use it, possibly because we have some extra warnings enabled in our code.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D21685780
      
      fbshipit-source-id: 3235c6444a623d5f484f0849679b1497f9456fa9
      29adc304
    • Lukas Piatkowski's avatar
      cargo_from_buck: add the patch section to Cargo workspace and allow workspace... · f6d0e220
      Lukas Piatkowski authored
      cargo_from_buck: add the patch section to Cargo workspace and allow workspace appending to existing manifest
      
      Summary:
      Two changes here:
      1. The `[patch.crates-io]` section of `third-party/rust/Cargo.toml` is being now copied over to workspaces generated by autocargo for OSS and in the runtime generated Cargo.toml file for cargo-fbcode builds. Without that some projects could be buildable in Buck internally, but not externally on GitHub due to missing patches.
      2. If a `[workspace]` Cargo.toml file is being generated and there is already a generated Cargo.toml file in the same directory then instead of overriding that file the `[workspace]` (and `[patch]`) sections are appended to that Cargo.toml file.
      
      Reviewed By: farnz
      
      Differential Revision: D22023144
      
      fbshipit-source-id: dec54491c36c2ee0ab29eefb722b3eceaef6ffe1
      f6d0e220
    • Mark Santaniello's avatar
      Default constructible folly::SysArenaAllocator · f0471228
      Mark Santaniello authored
      Summary:
      Adjust `CxxAllocatorAdaptor` such that it becomes default constructible.  This makes `SysArenaAllocator` default constructible too, which makes it much easier to use.
      
      A default-constructed `SysArenaAllocator` is not useful at all.  Any attempt to allocate just throws `std::bad_alloc`.  But it makes it possible to at least compile code like this:
      
      ```
      using MyAlloc = SysArenaAllocator<char>;
      struct Foo {
         Foo() = default;  // BOOM
         Foo(MyAlloc &a) : v(a) {};
         vector<int, MyAlloc> v;
      }
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21967640
      
      fbshipit-source-id: 5b74c6db14d75364b374cad71d0069b17769e5d6
      f0471228
    • Sumeet Khullar's avatar
      Revert D22027490: Specialize F14Table default constructor to avoid reserve() instantiation · d72d1b57
      Sumeet Khullar authored
      Differential Revision:
      D22027490
      
      Original commit changeset: 964d9fa19ca9
      
      fbshipit-source-id: 2c92ea47c64450cb031be4a6df3c3be4901500b7
      d72d1b57
    • Lewis Baker's avatar
      Only run Futex.clock_source test on Linux platforms · 61a434e9
      Lewis Baker authored
      Summary:
      On Linux platforms the folly::futexWait() functions are implemented using the
      futex() syscall, which requires passing a timeout parameter that specifies a
      an expiry time either in CLOCK_REALTIME or CLOCK_MONOTONIC.
      
      The futexWait() implementation currently assumes that the std::chrono::system_clock
      and std::chrono::steady_clock implementations are thin wrappers over these
      clock types and that we can directly convert the .time_since_epoch() values to
      a timespec value that we can pass to the futex() syscall.
      
      The Futex.clock_source test is checking this assumption about the implementation
      of the std::chrono clocks.
      
      Unfortunately, this assumption does not hold on recent libc++ implementations for
      Apple platforms, which now uses the CLOCK_UPTIME_RAW clock for the
      std::chrono::steady_clock implementation and so this test was failing on the
      Mac platforms.
      
      However, since we aren't actually relying on this assumption on platforms other than
      Linux, we can just disable this test for non-Linux platforms.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22075639
      
      fbshipit-source-id: 229995ba7c01b52d1949ef5942774920876d0994
      61a434e9
    • Andrii Grynenko's avatar
      Stop using atomic_thread_fence in SaturatingSemaphore · b77dcf05
      Andrii Grynenko authored
      Summary: Thread fences are not supported by TSAN
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22056483
      
      fbshipit-source-id: dfe5b462656605f2e659302125e248b287037629
      b77dcf05
    • Matt Ma's avatar
      Back out "Resubmit: Allow using different symbolizer mode in signal handler." · 23cadde7
      Matt Ma authored
      Summary:
      Original commit changeset: 25d4049019e4
      
      Base diff broke fboss build (using fbcode_builder) with the following error:
      
      /tmp/fbcode_builder_getdeps-ZrootZfboss2.gitZbuildZfbcode_builder-root/installed/folly/include/folly/init/Init.h:22:10: fatal error: folly/experimental/symbolizer/SymbolizerMode.h: No such file or directory
       #include <folly/experimental/symbolizer/SymbolizerMode.h>
      
      Revert this first to unblock fboss while I am investigating the failure.
      
      Reviewed By: shri-khare
      
      Differential Revision: D22077183
      
      fbshipit-source-id: 8bafc0518df82c61922104b7d59ef5ee20fdd572
      23cadde7
  7. 16 Jun, 2020 2 commits
  8. 15 Jun, 2020 8 commits
    • Matt Ma's avatar
      Resubmit: Allow using different symbolizer mode in signal handler. · 792d3247
      Matt Ma authored
      Summary: Fixed the missed initialization in InitOptions.
      
      Reviewed By: luciang
      
      Differential Revision: D22023637
      
      fbshipit-source-id: 25d4049019e42708c98e5b589ed4838e2870d39b
      792d3247
    • Giuseppe Ottaviano's avatar
      Specialize F14Table default constructor to avoid reserve() instantiation · 8d4e8ede
      Giuseppe Ottaviano authored
      Summary: F14 class member fields are often in headers, and often the default constructor is implicit. The current implementation unconditionally instantiates `reserve()`, which has non-negligible cost. By specializing the default constructor we can avoid that in the common case.
      
      Reviewed By: philippv, luciang
      
      Differential Revision: D22027490
      
      fbshipit-source-id: 964d9fa19ca92797bcb209e09959dc4706af39d4
      8d4e8ede
    • Pranav Thulasiram Bhat's avatar
      Deduction guide for Async · 248b90f6
      Pranav Thulasiram Bhat authored
      Summary:
      This diff implements a deduction guide for explicitly creating and returning Async objects in lambdas and functions with deduced return types.
      
      This saves the user from having to specify often lengthy return types when annotating such functions.
      
      Reviewed By: A5he
      
      Differential Revision: D21770141
      
      fbshipit-source-id: f80898ef6eeadee7c5a7168aaae4031e224a0935
      248b90f6
    • Pranav Thulasiram Bhat's avatar
      Async traits · 641a5030
      Pranav Thulasiram Bhat authored
      Summary: This diff implements traits to aid in the development of templated functions accepting annotated functions.
      
      Reviewed By: yfeldblum, A5he
      
      Differential Revision: D21770066
      
      fbshipit-source-id: 40ae340aeeb484c4f9769c13b5c9a92a97723801
      641a5030
    • Pranav Thulasiram Bhat's avatar
      Awaiting Coro · d1f59dd5
      Pranav Thulasiram Bhat authored
      Summary:
      This diff implements `coro_wait`, an annotated helper to block on the execution of a coroutine.
      
      The goal here is to provide an easy way to migrate from fibers to coroutines.
      
      Reviewed By: A5he
      
      Differential Revision: D21978610
      
      fbshipit-source-id: d59a222978d9db2963656312e71c7dcb2b9a11e9
      d1f59dd5
    • Pranav Thulasiram Bhat's avatar
      Awaiting futures · a7d768ee
      Pranav Thulasiram Bhat authored
      Summary:
      This diff adds `future_wait`, an annotated helper to run blocking `get` operations on futures.
      
      `future_wait` will help annotate functions (and their caller stack) that block on futures.
      
      For semifutures, deferred work is performed on fiber-main context, so there is no concern of bleeding fibers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21965552
      
      fbshipit-source-id: 79941c3b73c67d63d83dcdc778c62a0fc9051de3
      a7d768ee
    • Chad Austin's avatar
      re-enable lz4 compression for rocksdb on macOS and Linux · 3b5ce36b
      Chad Austin authored
      Summary:
      I think LZ4 was disabled accidentally in our rocksdb getdeps build in
      D21319896. Enable it again on macOS and Linux, because otherwise this
      breaks people with EdenFS mounts containing LZ4-compressed proxy
      hashes.
      
      Reviewed By: xavierd
      
      Differential Revision: D21990356
      
      fbshipit-source-id: b9166c2992ae51f09de3fa9a4f114143aa008f43
      3b5ce36b
    • Lewis Baker's avatar
      Add folly::tag_invoke · 66dc0a6f
      Lewis Baker authored
      Summary:
      Adds a helper utility called 'tag_invoke' for defining CPOs that dispatch to a call to an overload of the ADL-name 'tag_invoke()' that takes the CPO as the first argument instead of to a CPO-specific ADL-name.
      
      This makes it possible to build generic adapters, such as type-erasing adapters, that can forward through calls to all CPOs through to an underlying object.
      
      Adds FOLLY_DECLVAL(T) helper macro used in the implementation of some of the traits.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D17867173
      
      fbshipit-source-id: fadae6ec97498008a5238036b7310a1e0ae119a2
      66dc0a6f
  9. 13 Jun, 2020 1 commit
    • Nathan Bronson's avatar
      add explicit cast for narrowing on 32-bit platforms · 6bdbdb6f
      Nathan Bronson authored
      Summary:
      folly::Hash<Range<T>> uses SpookyHashV2::Hash64 (for integral
      T). On 32-bit platforms we need an explicit cast to avoid a narrowing
      warning when converting this to size_t.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: shixiao
      
      Differential Revision: D21491467
      
      fbshipit-source-id: 1cbd05553c61b8dccb664ec4478cfb0b049dc5b5
      6bdbdb6f
  10. 12 Jun, 2020 4 commits
    • Lucian Grijincu's avatar
      Revert D21918702: Allow using different symbolizer mode in signal handler. · 780050d9
      Lucian Grijincu authored
      Differential Revision:
      D21918702
      
      Original commit changeset: 3213e9536147
      
      fbshipit-source-id: 4e9394b2026f0d6d74e668c7c72b3612a42770ea
      780050d9
    • Giuseppe Ottaviano's avatar
      Outline most of TimedDrivableExecutor implementation · 4bbd587c
      Giuseppe Ottaviano authored
      Summary: This header is widely included (via `Future.h`) and instantiations of `UnboundedQueue`'s methods are expensive, so outline them (note that the template methods will only be instantiated if used, so that's fine).
      
      Reviewed By: philippv
      
      Differential Revision: D22014083
      
      fbshipit-source-id: b6a71c38c142917e9e0d86fbb64a88462382952a
      4bbd587c
    • Matt Ma's avatar
      Allow using different symbolizer mode in signal handler. · 8ae59d46
      Matt Ma authored
      Summary: This would allow us have better stack trace with inline functions in signal handler output.
      
      Reviewed By: luciang
      
      Differential Revision: D21918702
      
      fbshipit-source-id: 3213e9536147759a4e59f5b6f68d22d941d36c7f
      8ae59d46
    • Yedidya Feldblum's avatar
      Wrap _r_debug per platform · 55a91da8
      Yedidya Feldblum authored
      Summary: [Folly] Wrap `_r_debug` per platform, since the way to get it varies by platform.
      
      Reviewed By: ot, luciang
      
      Differential Revision: D22004737
      
      fbshipit-source-id: 6f6a6163c9709da0a5042b807cdd88fcdf2e57eb
      55a91da8
  11. 11 Jun, 2020 3 commits
    • Andrii Grynenko's avatar
      Stop using atomic_thread_fence in folly::Baton · f75211c0
      Andrii Grynenko authored
      Summary: Thread fences are not supported by TSAN
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21989519
      
      fbshipit-source-id: bb657c82a64abe025e8f4c030916c0cacc3c0b81
      f75211c0
    • Derek Brown's avatar
      Coroutines Method Typo (#1385) · 2c9b2aad
      Derek Brown authored
      Summary:
      The `collectSemiFuture` method doesn't exist.  Use `collectAllSemiFuture` instead.
      Pull Request resolved: https://github.com/facebook/folly/pull/1385
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21991532
      
      Pulled By: DerekTBrown
      
      fbshipit-source-id: 4ba3378fe34b7e6bb910f7045267fdbab87ebb14
      2c9b2aad
    • Yedidya Feldblum's avatar
      Back out "EventBase::getRecentSteadyTime" · 82dd413a
      Yedidya Feldblum authored
      Summary:
      Original commit changeset: 8eb472ce50bf
      
      This breaks time measurement to include measuring the wait preceding handler/callback invocation.
      
      Reviewed By: w-o-o
      
      Differential Revision: D21986042
      
      fbshipit-source-id: 42701b929878c3f56d736de5ca0417814c64fce1
      82dd413a