1. 22 May, 2021 1 commit
    • Tushar Pankaj's avatar
      Add use-after-destruction error messages · 2b4649b4
      Tushar Pankaj authored
      Summary: `ConcurrentHashMap` has a `DCHECK` for use-after-destruction. One of these has a comment explaining what it's for, but `DCHECK` supports taking a message to show the user. Make it a message.
      
      Reviewed By: yfeldblum, magedm
      
      Differential Revision: D28609176
      
      fbshipit-source-id: ea6e57b7650ad597f45ea3efc2fa0fb62d5de40e
      2b4649b4
  2. 21 May, 2021 5 commits
    • Dan Melnic's avatar
      Add sendmsg/recmsg io_uring support · 51ae3ffb
      Dan Melnic authored
      Summary: Add sendmsg/recmsg io_uring support
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27148068
      
      fbshipit-source-id: efb9174fb40f5f5bf0d0318db12cb61075866381
      51ae3ffb
    • Rob Sherwood's avatar
      Add ConstructorCallback to AyncSocket · 653f9938
      Rob Sherwood authored
      Summary:
      Use the new ConstructorCallback class to allow exterior functions/classes
      to get a callback for each new AsyncSocket()
      
      Implications:
      This adds an optional and an atomic int to the size of each AsyncSocket so
      there is a very small increase in mem usage even if this is unused (which will
      be most code, at least initially).
      
      There is also a very small amount of additional CPU on constructing an
      AsyncSocket: checking the std::option to see if it's non-nullopt.
      
      Reviewed By: bschlinker
      
      Differential Revision: D27516379
      
      fbshipit-source-id: 56f4411afcd404dcf0092cce562230e5c0dcdf17
      653f9938
    • Junqi Wang's avatar
      Back out "exception_wrapper thrown variant via abi/runtime" · 44739203
      Junqi Wang authored
      Summary: Original commit changeset: ce083cec4c31
      
      Differential Revision: D28558687
      
      fbshipit-source-id: 5cf4ac838c80428902280f3f9ccdd1174410fbe6
      44739203
    • Philip Pronin's avatar
      expose ConcurrentSkipList::size · d7e90075
      Philip Pronin authored
      Summary:
      It is safe to expose `size()` without requirement to go through
      accessor (which adds reference tracking overhead).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28591686
      
      fbshipit-source-id: ea0be2a34df01488402e53fdfbe232ee710f03f7
      d7e90075
    • Andres Suarez's avatar
      Apply clang-format · f498404b
      Andres Suarez authored
      Reviewed By: igorsugak
      
      Differential Revision: D28582083
      
      fbshipit-source-id: 9beedfccfd1fc6b9dc4f7ff8ab0139282bd285ab
      f498404b
  3. 20 May, 2021 1 commit
  4. 19 May, 2021 6 commits
  5. 18 May, 2021 1 commit
    • Lee Howes's avatar
      Add executor pointer to guard and log that plus name · b648738e
      Lee Howes authored
      Summary: Add a separate tag to the blocking guards, derived by default from the names available in the executors. This allows more fine-grained information when reporting blocking operations on the executors.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28265296
      
      fbshipit-source-id: 98d877ab13dc73c0b0b06edbdf15ec0e06f4d74a
      b648738e
  6. 17 May, 2021 2 commits
    • Lee Howes's avatar
      Switch SerialExecutor to default to the immutable global executor · b9f3d9be
      Lee Howes authored
      Summary: Use the global immutable executor by default for SerialExecutor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D26916419
      
      fbshipit-source-id: c9b68c6b9facd11c8768199f8bae3d6c9276f4bd
      b9f3d9be
    • Shai Szulanski's avatar
      Fix folly::coro::timeout to work with AsyncGenerator · 5e0cf312
      Shai Szulanski authored
      Summary: The current signature results in an attempt to construct a `Try<semi_await_result_t<SemiAwaitable>>` from a `semi_await_try_result_t<SemiAwaitable>::element_type`. While the inner types match for Task, they don't for AsyncGenerator - the former is `AsyncGenerator<T>::NextResult`, which is not constructible from a T. (We could alternatively add that constructor, but that would result in timeout returning a `Task<AsyncGenerator<T>::NextResult>`, which is undesirably indirect).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28475605
      
      fbshipit-source-id: c30a60e3ec942f801653a08b020796d47d4ef763
      5e0cf312
  7. 16 May, 2021 1 commit
    • Yedidya Feldblum's avatar
      fix exception_ptr_get_type for libc++ < v10.0.0-rc2 · 2170bef0
      Yedidya Feldblum authored
      Summary:
      The function `folly::exception_ptr_get_type` under 32-bit arm-ehabi libc++ >= v5.0.1 and < v10.0.0-rc2, is broken because the `__cxa_exception` layout is changed in an incompatible way, with an extra 4 bytes padding incorrectly preceding the unwind field. Shift the `__cxa_exception` pointer before accessing fields through it.
      
      Major thanks to Crystal Jin <crystalj@fb.com> for help debugging the problem and testing the fix.
      
      Differential Revision: D28423734
      
      fbshipit-source-id: fdf67fa5c1056df921fad23f86ae965761603738
      2170bef0
  8. 14 May, 2021 1 commit
    • Andrii Grynenko's avatar
      Fix observer initialization on fiber · df9437f9
      Andrii Grynenko authored
      Summary: Observer initialization is blocking and is using thread-local state to detect cycles/track dependencies. When running on a fiber we have to make sure the fiber doesn't get suspended during observer initialization.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28306797
      
      fbshipit-source-id: 807a4553e89f9fa807e6c745a623041dbb0e47ce
      df9437f9
  9. 13 May, 2021 3 commits
    • Brandon Schlinker's avatar
      Extend MockAsyncSocket to include observer functions · 4c23632f
      Brandon Schlinker authored
      Summary: Adding `addLifecycleObserver` and `removeLifecycleObserver` to support tests.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27163395
      
      fbshipit-source-id: de749b2570c71a3f98cbbc8569c2990ce2c5be0c
      4c23632f
    • Brandon Schlinker's avatar
      Fix removeLifecycleObserver in AsyncSocket · c7a95dcb
      Brandon Schlinker authored
      Summary: When multiple observers attached and one is removed, removal code can end up calling `observerDetach` on the wrong observer. Simplified and fixed removal logic and added new tests.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27033014
      
      fbshipit-source-id: df84bf65207a00f3b76d8950ac2c29f477508da1
      c7a95dcb
    • Rob Sherwood's avatar
      Changed ConstructorCallback to work with -Wglobal-constructor · 99f856ae
      Rob Sherwood authored
      Summary:
      The initial implementation of ConstructorCallback used a global (pre-main)
      initialization which was deemed safe.  While likely still safe, it turns out
      that when trying to land diffs that used ConstructorCallback, many code bases
      compile with -Wglobal-constructor which explicitly denies this type of
      initialization (even if it is safe).
      
      Re-worked the code to prevent any non-zero initialization and still maintain
      the property that we don't lock unless someone is registering a callback.
      
      Reviewed By: bschlinker
      
      Differential Revision: D28395301
      
      fbshipit-source-id: 2cdd82189410b3ccea1c892560d0d0cb5b6abc34
      99f856ae
  10. 12 May, 2021 3 commits
    • Philip Pronin's avatar
      expose commutative accumulator as commutative_hash_128_to_64 · c464335f
      Philip Pronin authored
      Summary:
      So it can be used in cases where data is already hashed, and
      order-independent way to reduce the set of hashes is required.
      
      Reviewed By: ot
      
      Differential Revision: D28382187
      
      fbshipit-source-id: 4327ddd67b49a61d0172c4676090b2f96e84c065
      c464335f
    • Aleksandr Sasha Sergeev's avatar
      Add path to problematic element into json print_error · 83b07aec
      Aleksandr Sasha Sergeev authored
      Summary:
      To facilitate debugging.
      
      Privacy note: now `what()` message may contain part of JSON.
      
      parser_error `what()` message:
      
      - before the change:
      `folly::toJson: JSON object value was a NaN`
      
      - after the change:
      `folly::toJson: JSON object value was a NaN when serializing value at "outerKey"->"innerKey"`
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27623818
      
      fbshipit-source-id: 86e61a0fed500eddafbd3e3bb1b9ed363ba8fcae
      83b07aec
    • Andre Nash's avatar
      Provide a new optimized AVX memcpy with prefetch · 40233942
      Andre Nash authored
      Summary:
      This introduces `__folly_memcpy`, which is an implementation of `memcpy` that uses prefetch to speed up cold copies (data absent from L1) and uses overlapping copies to avoid as much branching as possible to speed up hot copies (data present in L1).
      
      A description of the core ideas for this memcpy is in the file comment at the top of folly_memcpy.S.
      
      `__folly_memcpy` *does* act as a `memmove`, although it isn't optimized for that purpose for copies of 257 or more bytes. This masks some undefined behavior bugs when code calls `memcpy` on an overlapping region of data. `perf` samples will show when `memmove` is called by `__folly_memcpy`, which will help identify these undefined behavior bugs for copies of 257 bytes or more.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23629205
      
      fbshipit-source-id: 61ed66122cc8edf33154ea6e8b87f4223c0ffcc0
      40233942
  11. 11 May, 2021 4 commits
    • Maged Michael's avatar
      ConcurrentHashMap: Fix bug in try_emplace · fef59129
      Maged Michael authored
      Summary:
      Add missing hazard pointer protection of the new node inserted by a successful try_emplace.
      
      Add test that breaks without this fix.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28361211
      
      fbshipit-source-id: 963527a9c6b24b0cb569d5b49da9ef9a0e8b58cd
      fef59129
    • Rob Sherwood's avatar
      [easy] Add comment to ConstructorCallback explaining non-race · 89b83873
      Rob Sherwood authored
      Summary:
      There are lint rules that should discourage code from doing non-trivial
      things as part of static initialization, e.g., calling a complex
      constructor.
      
      That said, probably someone somewhere in fbcode does that so I got
      wrapped around the axel trying to change this code to prevent such a
      race with ConstructorCallback.
      
      The concern was that if someone created a Foo()
      pre-main() there might be an initialization race for
      ConstructorCallback<Foo>::nConstructorCallbacks_ and if we lost that race,
      we would issue callbacks on garbage data.
      
      BUT - apparently the C++ standard initialization requires that all static
      zero values are initialized before more complex initilization, so this
      can't happen (assuming the compiler correctly implements the spec).
      So this code change is just to add a commment with the information so
      no one else goes chasing down this (false) rat hole...
      
      Differential Revision: D27969959
      
      fbshipit-source-id: c135d1bb235d652d11e0541cc09a10a1bad1ce87
      89b83873
    • Nathan Lanza's avatar
      Update folly::experimental::coro docs to account for getCPUExecutor deprecation · 956885e9
      Nathan Lanza authored
      Summary: title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28345979
      
      fbshipit-source-id: ea55db34e19d3881c65559172d4fc9df4808fdad
      956885e9
    • Chris Keeline's avatar
      Fix dev-tsan error · 96b30363
      Chris Keeline authored
      Summary:
      TSAN catches this as a data race, though it's fairly benign. In the
      assert we read non-atomic `state` without holding the lock. As a fix, acquire
      the lock in the assert. The assert is skipped anyway in opt builds.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28302491
      
      fbshipit-source-id: b92ca9f3d321d34301d96e59fab363d999bddb30
      96b30363
  12. 10 May, 2021 1 commit
  13. 08 May, 2021 3 commits
  14. 07 May, 2021 2 commits
    • Yedidya Feldblum's avatar
      a non-concurrent token-bucket variation · 97e3d72b
      Yedidya Feldblum authored
      Summary: Adds a policy around whether token-bucket is used only non-concurrently, in which case compare-exchanges can be optimized to stores.
      
      Differential Revision: D28230482
      
      fbshipit-source-id: 2c00797dc943e9ea8985737a8c7dda059a195cfe
      97e3d72b
    • Yedidya Feldblum's avatar
      exception_wrapper thrown variant via abi/runtime · aa7f74aa
      Yedidya Feldblum authored
      Summary:
      Reimplement `folly::exception_wrapper` thrown variant not to need to cache any pointers and rather to access the exception object and runtime type, and to perform runtime upcasting, via the platform runtime.
      
      This both simplifies and extends the capability of the thrown variant.
      
      Reviewed By: luciang
      
      Differential Revision: D26331579
      
      fbshipit-source-id: a6fe0f10434956efa5ba4b4bcd1bd3a1b48466a4
      aa7f74aa
  15. 06 May, 2021 6 commits
    • Igor Sugak's avatar
      fix clang-12 -Wdeprecated-copy · 808c2600
      Igor Sugak authored
      Summary:
      Starting with C++11, implicit generation of the copy constructor is declared as deprecated.
      > § D.2 Implicit declaration of copy functions [depr.impldec]
      > The implicit definition of a copy constructor as defaulted is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. The implicit definition of a copy assignment operator as defaulted is deprecated if the class has a user-declared copy constructor or a user-declared destructor (15.4, 15.8). In a future revision of this International Standard, these implicit definitions could become deleted (11.4).
      
      Clang-12 produces diagnostics for these cases, which is turned into errors for folly:
      ```
      folly/test/AtomicHashMapTest.cpp:330:12: error: definition of implicit copy constructor for 'Integer' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
        Integer& operator=(const Integer& a) {
                 ^
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28239770
      
      fbshipit-source-id: a28d19ec774264944b750aa267e93d4fa6d1744e
      808c2600
    • Yedidya Feldblum's avatar
      use relaxed memory order in TokenBucket · 72bbd4c1
      Yedidya Feldblum authored
      Summary: The atomic location is not used to order memory.
      
      Reviewed By: jbeshay
      
      Differential Revision: D28229348
      
      fbshipit-source-id: c6206d4b72025e1f7f68adc822e9ae4ed13bd8b4
      72bbd4c1
    • Yedidya Feldblum's avatar
      policy structure for TokenBucket · 3b0e443c
      Yedidya Feldblum authored
      Summary: Items which are subject to policy: align, atom, and clock.
      
      Differential Revision: D28229049
      
      fbshipit-source-id: e65512265abaa8b777f95cf3233d96a70df73c5f
      3b0e443c
    • Jaroslaw Kasperkiewicz's avatar
      Enabling support for folly::splitTo<std::string_view> · 6f38cd40
      Jaroslaw Kasperkiewicz authored
      Summary:
      Adding new `parseTo` overload for `std::string_view`, and related tests.
      
      Facilitates migration from `folly::StringPiece` to `std::string_view` by supporting:
      
      ```lang=c++
      splitTo<string_view>(...)
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27971000
      
      fbshipit-source-id: 732f968eb6797447ae12bdc70dbb82d5fc6a8a33
      6f38cd40
    • Yedidya Feldblum's avatar
      tweak size checks in to_ascii · ea1cdd1a
      Yedidya Feldblum authored
      Summary: If inlining and constant folding can determine that the buffer is larger than the `to_ascii_size_max` constant, then there is no need to call the `to_ascii_size` function an extra time.
      
      Differential Revision: D27986105
      
      fbshipit-source-id: d088001a7b3632dabb794c86dafdaa93dd0c1348
      ea1cdd1a
    • Yedidya Feldblum's avatar
      rename the redefined __cxa_exception · a8a754aa
      Yedidya Feldblum authored
      Summary: In case some `<cxxabi.h>` actually defines it rather than keeping it defined in some unincluded helper.
      
      Reviewed By: luciang
      
      Differential Revision: D28239978
      
      fbshipit-source-id: 4d824892966de4b9f8de775d947f5d7d749a02bb
      a8a754aa