1. 30 Jun, 2020 1 commit
  2. 29 Jun, 2020 3 commits
    • Matthieu Martin's avatar
      Async interface for addTaskRemoteFuture · 7e6a92c1
      Matthieu Martin authored
      Summary:
      This provides a set of three functions under folly::fibers::async, to schedule then wait for work on a remote fiber manager.
      The functions cover those 3 (legitimate) needs:
      
      - Blocking current thread: `T executeOnRemoteFiberAndWait`
      - Blocking current fiber: `Async<T> executeOnRemoteFiber`
      - Awaitable (barebone version for now): `Future<T> addFiberRemoteFuture`
      
      See code docblock for more details
      
      Reviewed By: pranavtbhat
      
      Differential Revision: D22252598
      
      fbshipit-source-id: add9c23f5bdacb233e47f30b2639d376027167e3
      7e6a92c1
    • Dan Melnic's avatar
      More io_uring file read/write tests · 5b8e0513
      Dan Melnic authored
      Summary: More io_uring file read/write tests
      
      Reviewed By: kevin-vigor
      
      Differential Revision: D22236012
      
      fbshipit-source-id: 37abd398d07af2bb41cfe3b3b6dfeb40410554d5
      5b8e0513
    • Shrikrishna Khare's avatar
      Fix OpenNSA 6.5.19 hash as Brcm modified the tarball · e678005f
      Shrikrishna Khare authored
      Summary:
      Koray reported issue with OpenNSA while using build VM and observed that we
      don't hit the issue on devserver thanks to downloading the lfs cached file.
      
      The root cause:
      
      Broadcom added License notice and uploaded new 6.5.19 with same name.
      This changed the hash though - causing fbcode builder to complain.
      Fix it by adjusting the hash.
      
      See the first line in the recursive diff of before vs. after: P134467317
      
      (the broken symlinks is an unrelated existing issue, which we have reported to
      Broadcom).
      
      Reviewed By: bkoray
      
      Differential Revision: D22280971
      
      fbshipit-source-id: 781079df426f83901509225156cf77a3966d3301
      e678005f
  3. 27 Jun, 2020 1 commit
    • Matthieu Martin's avatar
      Move addFiberFuture from detail:: · 0c27031c
      Matthieu Martin authored
      Summary:
      After pursuing adoption and more discussion, it seems clear that this was probably trying to push "hiding fiber details" one step too far.
      See comment in code for more details
      
      Reviewed By: yfeldblum, pranavtbhat
      
      Differential Revision: D22259585
      
      fbshipit-source-id: 798cada6527332faf7e4db9942a964d6b7cca1e4
      0c27031c
  4. 26 Jun, 2020 2 commits
    • Pranav Thulasiram Bhat's avatar
      Switch await into a callable object · 10dd9f4b
      Pranav Thulasiram Bhat authored
      Summary: This diff converts `await` into a callable object.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22175597
      
      fbshipit-source-id: 689e11c62161a2e4b82699bf52835e92c96beff7
      10dd9f4b
    • Pranav Thulasiram Bhat's avatar
      Mark lambdas in addFiber(Future) mutable · b18832a6
      Pranav Thulasiram Bhat authored
      Summary:
      If `func` is mutable, then the lambda applying `init_await` must be mutable too in order to call `func`'s non-const () operator.
      
      This diff marks the `init_await` applying lambdas mutable.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22238824
      
      fbshipit-source-id: 20f202b121edd0bdfcf7a6f707a4f1d4df0181d8
      b18832a6
  5. 25 Jun, 2020 2 commits
    • Songqiao Su's avatar
      (folly/coro) using atomic_compare_exchange_weak_explicit in coro::Baton · df460658
      Songqiao Su authored
      Summary:
      to avoid hit TSAN issue when using coro::Baton
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: lewissbaker
      
      Differential Revision: D22192037
      
      fbshipit-source-id: ee35179be79deb1d3b79b7b432c8a65c793f7d8f
      df460658
    • Lewis Baker's avatar
      Make sure coroutine final_suspend() methods are declared noexcept · 8a3d5b9c
      Lewis Baker authored
      Summary:
      The C++20 specification for coroutines included a late change that
      now requires the `co_await promise.final_suspend();` expression to
      not be potentially throwing (ie. it needs to be declared `noexcept`).
      
      This change updates all coroutine types in folly to make sure that
      `final_suspend()` methods and the methods on awaitables returned from
      these methods are all declared `noexcept` so that folly can be used
      with compilers that enforce this requirement.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22203834
      
      fbshipit-source-id: 4a5bbcbad644349d2ff0b08f6460fa13c3165aec
      8a3d5b9c
  6. 24 Jun, 2020 10 commits
    • Pranav Thulasiram Bhat's avatar
      Async Readme · df45ceb8
      Pranav Thulasiram Bhat authored
      Summary: This diff adds a README for the async annotation library.
      
      Reviewed By: andriigrynenko, A5he
      
      Differential Revision: D22080510
      
      fbshipit-source-id: 2b1800fd44596e0e4bddff8a321a88fcd9304739
      df45ceb8
    • Mark Santaniello's avatar
      Simplify Arena destructor · aeb4ecf8
      Mark Santaniello authored
      Summary: Use the intrusive list's clear_and_dispose API to simplify things somewhat.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22199152
      
      fbshipit-source-id: fb6ec4e206660bc7628ddd87edba3698d8a2af6d
      aeb4ecf8
    • Pranav Thulasiram Bhat's avatar
      FiberManager - executeOnFiber · 4485ef0c
      Pranav Thulasiram Bhat authored
      Summary:
      This diff implements a new API to schedule a function on a new fiber and block the existing fiber till completion.
      
      The API should be used sparingly to deal with fiber-stack-overflow issues
      
      Reviewed By: A5he
      
      Differential Revision: D22074021
      
      fbshipit-source-id: 893e578b1acd6dd5cca34187fc8431202cdb73da
      4485ef0c
    • Pranav Thulasiram Bhat's avatar
      collectAllFibers and collectFibers · ac28a012
      Pranav Thulasiram Bhat authored
      Summary:
      This diff implements a wrapper around `fibers::collectAll` to accept annotated functors.
      
      It also implements version of `collect` that accepts variadic arguments, and returns a tuple.
      
      Reviewed By: A5he
      
      Differential Revision: D22142416
      
      fbshipit-source-id: dab320f7e1718c3872c54e168c24ea4bc39051d5
      ac28a012
    • Pranav Thulasiram Bhat's avatar
      FiberManager - addFiber · 98759027
      Pranav Thulasiram Bhat authored
      Summary:
      This diff implements addFiber, a wrapper around fiberManager.addTask.
      
      It should mainly be used to 'fire-and-forget' a fiber.
      
      Reviewed By: A5he
      
      Differential Revision: D22073924
      
      fbshipit-source-id: 52516e86b7b03a7bc59166fae4db79f60cddffb7
      98759027
    • Pranav Thulasiram Bhat's avatar
      FiberManager - addFiberFuture and blockingWait · 7c81dc02
      Pranav Thulasiram Bhat authored
      Summary:
      This diff has two goals:
      - To provide an API that allows users to schedule async annotated functors to run on fibers (thereby removing the need to use `init_await` at the top of the stack)
      - To provide a boilerplate-free entry point into fiber code that should work for a majority of testing/benchmarking interactions with fiber manager.
      
      The diff implements two APIs:
      -addFiberFuture: wrapper around `fiberManager.addTaskFuture`. The differing name is to mainly avoid namespace collisions and avoid confusion with `coro::Task`
      - blockingWait: Fiber entry point helper
      
      Reviewed By: A5he
      
      Differential Revision: D22071005
      
      fbshipit-source-id: 24ceea005d32f6e2c84b4599042703207504bd0f
      7c81dc02
    • Shrikrishna Khare's avatar
      fbcode_builder: getdeps: Update OpenNSA to 6.5.19 · f8ca5b8f
      Shrikrishna Khare authored
      Summary: 6.5.19 is now available, switch OSS to pick that instead of old 6.5.17.
      
      Reviewed By: rsunkad
      
      Differential Revision: D22199286
      
      fbshipit-source-id: 231346df8d2f918d2226cfe17b01bde12c18a5a7
      f8ca5b8f
    • Lukas Piatkowski's avatar
      mononoke/configerator structs: change the OSS folder where configerator structs are saved · d0c01e87
      Lukas Piatkowski authored
      Summary:
      Due to Thrift design of "include" statements in fbcode the thrift structures has to be contained in folders that are identical to the folder layout inside fbcode.
      
      This diff changes the folder layout on Cargp.toml files and in fbcode_builder, there will be a next diff that changes this for ShipIt as well.
      
      Reviewed By: ikostia
      
      Differential Revision: D22208707
      
      fbshipit-source-id: 65f9cafed2f0fcc8398a3887dfa622de9e139f68
      d0c01e87
    • Andrii Grynenko's avatar
      Make sure global CPU executor is never joined on an application thread · 3b8891d6
      Andrii Grynenko authored
      Reviewed By: LeeHowes
      
      Differential Revision: D22181192
      
      fbshipit-source-id: 279c56398cd7e4c9274bc43c3564062588c9c81a
      3b8891d6
    • Lucian Grijincu's avatar
      Revert D18662578: Eliminate need for reading upper bound at construction. · 985fa6fa
      Lucian Grijincu authored
      Differential Revision:
      D18662578 (https://github.com/facebook/folly/commit/42d5bf14cd6feafa91beeb214d2441bf27ab03c7)
      
      Original commit changeset: e04a99208848
      
      fbshipit-source-id: 57a66a9c90955d67f942db4a3cad15910ee74178
      985fa6fa
  7. 23 Jun, 2020 7 commits
    • Matthew Laux's avatar
      Replace global AsyncSocketExceptions with lazy initialization functions · 1e2463c7
      Matthew Laux authored
      Summary: Avoid allocation during startup by creating the exception objects the first time getXXXX is called.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22128606
      
      fbshipit-source-id: b5ba662dcfac9f859dc9c972d1906fe1c29c42cc
      1e2463c7
    • Kirk Shoop's avatar
      MasterPtr -> PrimaryPtr · e559539b
      Kirk Shoop authored
      Summary: name change
      
      Reviewed By: LeeHowes
      
      Differential Revision: D22162997
      
      fbshipit-source-id: 8431a25fe46df2b5e4bfb162fc982b1c55bce7ce
      e559539b
    • Swaroop Manjunath's avatar
      Eliminate need for reading upper bound at construction. · 42d5bf14
      Swaroop Manjunath authored
      Summary:
      This diff introduces the following changes to the EliasFanoReader implementation.
      
      - `EliasFanoReader` no longer requires knowledge of the last value in the list at construction time. This removes the need to access the last byte of the encoded list.
      - Operations in `UpperBitsReader` are now responsible for ensuring validity.
      - Removes constraint that the last set bit in upperBits must be in the last byte of the encoded list.
      
      In addition, the diff also extends the unit-tests for Elias Fano coding to add arbitrary extensions to the upperBound at construction to ensure that additional 0-blocks at the end of the list do not affect the behavior of the reader.
      
      Reviewed By: ot
      
      Differential Revision: D18662578
      
      fbshipit-source-id: e04a9920884844abd5ffe6796b0062bb59a334ae
      42d5bf14
    • 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
  8. 22 Jun, 2020 1 commit
  9. 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
  10. 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
  11. 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
  12. 17 Jun, 2020 4 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