1. 31 Aug, 2021 2 commits
    • Jolene Tan's avatar
      Remove vformat and svformat from folly/Format.md · a782676b
      Jolene Tan authored
      Summary: Part of folly vformat and svformat deprecation
      
      Reviewed By: vitaut
      
      Differential Revision: D30656958
      
      fbshipit-source-id: 0cccb7b2294fada3c61e36cd527af2ef05bb5a0a
      a782676b
    • Maged Michael's avatar
      ConcurrentHashMap: Fix cloning of non-copyable items · b765365d
      Maged Michael authored
      Summary:
      Fix an algorithm bug that occurs when the Key or Value types are not nothrow copy constructible.
      - Nodes (the entities protectable by iterators) may be cloned as a result of rehashing.
      - Key-value item objects are unique (because they are not copyable).
      - Multiple nodes may point to the same key-value item.
      - In the incorrect algorithm, each node has a bool member that indicates if it owns the key-value item or not (i.e., if it is responsible for deleting it).
      - When a node is cloned, its bool member is cleared.
      - The problem is that if the key is erased and the clone (or  descendant clone) may be reclaimed (because it is unprotected by iterators) then the key value item will be reclaimed, even if a cloned-from node is still protected by iterators.
      - The failure happens when an iterator holder to a cloned-from node tries to access the already-reclaimed key-value, expecting it (correctly) to be still protected.
      
      The fix:
      - Eliminate the bool owned member in the node structure.
      - Add a link counter to the key-value item structure.
      - Increment (atomically) the link counter when the (latest) node to the key-value item is cloned.
      - Decrement (atomically) the link counter when a node pointing to the item is reclaimed.
      - Reclaim the item only when its last link is released.
      - Note that atomic increments  and decrements are used only if the node pointing to an item is cloned.
      
      Added a test to detect the incorrect behavior.
      This change fixes only the regular (non-SIMD) version.
      Currently, the SIMD version fails the added test, therefore (for now) the test is enabled only for the regular version.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D30371519
      
      fbshipit-source-id: 29e143712afb3ef794f9f6f4d99919d5b4688416
      b765365d
  2. 26 Aug, 2021 2 commits
  3. 25 Aug, 2021 1 commit
    • Erich Graham's avatar
      Fix Folly issues with -Wcovered-switch-default compiler flag · 02a4b200
      Erich Graham authored
      Summary:
      When compiled with `-Wcovered-switch-default`, Folly fails to build because it adds `default` to switches which are already exhaustive. For C++ safety, these switches are intentionally including a default, so wrap them in a pragma block to indicate that and locally disable the warning.
      
      Causes -fmodules import issues for upstream library in D30379442.
      
      Still remaining issues with C++ definition: P445339268
      
      Reviewed By: ispeters
      
      Differential Revision: D30397871
      
      fbshipit-source-id: adead9e01d0ba3b21c2e1446150cc6fed0f58602
      02a4b200
  4. 24 Aug, 2021 1 commit
  5. 20 Aug, 2021 1 commit
    • Maged Michael's avatar
      ConcurrentHashMapSIMD: Return iterator to new inserted item · 2c7411fe
      Maged Michael authored
      Summary:
      Fix SIMD version to return iterator to new item in insertion operations.
      
      Added a test to detect the incorrect behavior.
      
      Changed existing tests that di not test the SIMD version to do so. Three of these tests fail without the fix.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D30435627
      
      fbshipit-source-id: 20ba400be9213fa138fda06e0e7bd84cf9d8cf12
      2c7411fe
  6. 19 Aug, 2021 3 commits
    • Brett Chik's avatar
      Fix a typo. · dc843dad
      Brett Chik authored
      Summary: I noticed two mispellings while reading through the code.  This fixes them.
      
      Reviewed By: Orvid
      
      Differential Revision: D30429734
      
      fbshipit-source-id: b976cc4ae4534a9f065b8a7e6fee5a39d7241a28
      dc843dad
    • Jason Fried's avatar
      expose make_optional to cython · 2906e83c
      Jason Fried authored
      Summary: This definition is the same cython uses for make_shared and make_unique
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30232407
      
      fbshipit-source-id: 6a0cf4637721bc9d5e5f7f87f3c0f2b031810a5f
      2906e83c
    • Felix Handte's avatar
      Back out "Change Context Pool Stripes from 4 to 128" · 23133cdb
      Felix Handte authored
      Summary:
      Original commit changeset: 7b10cb9dd2c4
      
      `configerator_proxy2` reports a big memory regression. Reverting until we understand what's going on and have a plan to address it.
      
      (Note: this ignores all push blocking failures!)
      
      Differential Revision: D30401909
      
      fbshipit-source-id: 28443ba08b75c634021965319fead2f8a36b7235
      23133cdb
  7. 18 Aug, 2021 1 commit
  8. 16 Aug, 2021 2 commits
    • Cristian Lumezanu's avatar
      Add a AsyncSocket::LifecycleObserver->connectError() callback · e460690d
      Cristian Lumezanu authored
      Summary:
      The LifecycleObserver already tracks connect() but does not notify on
      connectError().  Follow the same pattern.
      
      Note that we intentionally added this to AsyncSocket's LifecycleObserver
      rather than AsyncTransport b/c AsyncTransport is not supposed to have
      a concept of a 'connection'.  This is counter to the 'connect()' callback
      that already exists in AsyncTransport::LifecycleObserver so marked a quick
      TODO to remember to move that.
      
      Reviewed By: bschlinker
      
      Differential Revision: D28612132
      
      fbshipit-source-id: cefa650bd007d48e38f9cb67bc9a82d322036d4c
      e460690d
    • Mahesh Balakrishnan's avatar
      Setting up basic build for delos_core · 0d7f79c2
      Mahesh Balakrishnan authored
      Summary: This diff adds the manifest file for delos_core so we can build using getdeps.
      
      Reviewed By: hanm
      
      Differential Revision: D26011286
      
      fbshipit-source-id: becb1a665a95f0d593072885c3ddfcf5c4403f51
      0d7f79c2
  9. 14 Aug, 2021 1 commit
    • Nikita Lutsenko's avatar
      folly | CppAttributes | Add portable version of FOLLY_ATTR_MAY_ALIAS, to allow... · 6ce98b52
      Nikita Lutsenko authored
      folly | CppAttributes | Add portable version of FOLLY_ATTR_MAY_ALIAS, to allow for usage across compilers.
      
      Summary: This attribute is GCC/Clang specific, allow portable usage, well, via portability header and custom define.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30296807
      
      fbshipit-source-id: bf496574139f42b07a11d582dedf6bac733318ec
      6ce98b52
  10. 13 Aug, 2021 3 commits
  11. 12 Aug, 2021 2 commits
    • Cristian Lumezanu's avatar
      Move fd_ to the initializer list in AsyncSocket constructor · d365f9e4
      Cristian Lumezanu authored
      Summary: When constructing a new AsyncSocket, we can use an already connected file descriptor, which we assign to the `fd_` member variable. We move this assignment from the constructor body to the constructor initializer list to avoid a situation where an observer is unaware of an attached fd because `fd_` was assigned after the observer was created.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30261699
      
      fbshipit-source-id: 5adbc744715355fba08f5430a77c9094e246899d
      d365f9e4
    • Igor Sugak's avatar
      add copy assignment operator to BasicDynamicTokenBucket · 2e2e7af8
      Igor Sugak authored
      Summary: `BasicDynamicTokenBucket` declares a copy constructor, but not copy assignment operator.
      
      Differential Revision: D30258099
      
      fbshipit-source-id: c993177e11023d13d01884e5060269c4d5813088
      2e2e7af8
  12. 11 Aug, 2021 1 commit
    • Maged Michael's avatar
      hazard pointers: Fix flaky test · 559c679d
      Maged Michael authored
      Summary:
      Fix flaky test. Without this fix it is possible for the background asynchronous reclamation thread to be too slow in pushing p1 into the cohorts safe list before the main thread checks for p1's reclamation.
      
      This fix lets the main thread wait for p1 to be reclaimed before checking that p2 was not reclaimed. Since p1 is considered for reclamation before p2, it is possible that this check would pass even if p2 was about to be reclaimed in error. So the test then retires p3 and waits for it to be reclaimed before checking again that p2 was not reclaimed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30248673
      
      fbshipit-source-id: 268edb299681ab4b7256dac591d8cacbb960a7cc
      559c679d
  13. 10 Aug, 2021 6 commits
    • Igor Sugak's avatar
      fix nullptr-with-nonzero-offset in folly/io/IOBuf.cpp · 00c5c00f
      Igor Sugak authored
      Reviewed By: yfeldblum
      
      Differential Revision: D30232471
      
      fbshipit-source-id: 1137e306fca34f687c99c7f2155a03515926da45
      00c5c00f
    • Shai Szulanski's avatar
      Add warning when using TaskWithExecutor + InlineLikeExecutor · 7e6bdbbd
      Shai Szulanski authored
      Summary: This is unsafe and leads to all kinds of bugs. It is unfortunately too late to ban it, but we can at least print a warning to help debugging and maybe discourage new uses.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D29972469
      
      fbshipit-source-id: 1534bcc69eaf8f105998d65c0a6503740924cffa
      7e6bdbbd
    • Maged Michael's avatar
      hazptr_obj_cohort: Fix reclamation of safe list · cda1e77c
      Maged Michael authored
      Summary:
      Fix a bug in hazptr_obj_cohort handling of children of reclaimed nodes during reclamation of the safe list. When the cohort is active, the children nodes should be pushed to the domain (to be checked against hazard pointers) and not reclaimed immediately because it is possible that a child node is protected by hazard pointers.
      
      Added test that catches the bug.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30170939
      
      fbshipit-source-id: e5bfe46b6fa5d4e5ce5cef02a3934ced424138f0
      cda1e77c
    • Cristian Lumezanu's avatar
      Update TcpInfo namespaces · ae4ddebe
      Cristian Lumezanu authored
      Summary: We update the TcpInfo namespace to `folly` (previosuly `folly::tcpinfo`) to avoid introducing unnecessary namespaces and to make it slightly easier to refer to. We also move the structs in the `TcpInfoTypes.h` file to the `folly::detail` namespace and move `LookupOptions` to the `TcpInfo` class, following comments in D22134355 (https://github.com/facebook/folly/commit/68a78d99d10743b54d38a550b2f0ebdc5c872f76).
      
      Reviewed By: bschlinker
      
      Differential Revision: D30159429
      
      fbshipit-source-id: 7260fc80c2e76b3439c539b65cc188b2e5517b24
      ae4ddebe
    • Srivatsan Ramesh's avatar
      Add TerminateCancellationToken utility · 416d85c5
      Srivatsan Ramesh authored
      Summary: `getTerminateCancellationToken()` is the public API that can be used to get a cancellation token that'll be cancelled when any of the registered signal (SIGTERM or SIGINT) is received.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D29883069
      
      fbshipit-source-id: 4270c42316b80afb2c75f54de7e720dcb7a083ca
      416d85c5
    • Johan Schuijt-Li's avatar
      move to common shared directory · 957741d5
      Johan Schuijt-Li authored
      Summary: Allow this to be used by more utilities.
      
      Reviewed By: DurhamG
      
      Differential Revision: D29958512
      
      fbshipit-source-id: b6a1a7017102a4ff4ad252246d3252903bbb793f
      957741d5
  14. 09 Aug, 2021 4 commits
    • Yedidya Feldblum's avatar
      let FOLLY_TYPE_INFO_OF always use its arg · 4f9b8292
      Yedidya Feldblum authored
      Summary: Even when RTTI is disabled, to avoid unused-arg warnings. Then use `FOLLY_TYPE_INFO_OF` to simplify the conditional compilation in `UniqueInstance`.
      
      Reviewed By: praihan
      
      Differential Revision: D30183405
      
      fbshipit-source-id: 040d90751822dedb8faca561a89dcf35da25119b
      4f9b8292
    • Ruslan Sayfutdinov's avatar
      include <optional> in Channel-fwd.h · bf6d3e57
      Ruslan Sayfutdinov authored
      Reviewed By: yfeldblum
      
      Differential Revision: D30191509
      
      fbshipit-source-id: 00e782bf381bd5cb126fd7b18ee3454c6b9d13a7
      bf6d3e57
    • Cristian Lumezanu's avatar
      add fdAttach callback · 2360b227
      Cristian Lumezanu authored
      Summary: The fdAttach callback notifies all AsyncSocketLifecycleObservers attached to the socket that a file descriptor has just been associated with the socket. In AsyncSocket, the file descriptor is created when connect() is **called**, not when it succeeds. This callback lets observers know about the fd immediately; otherwise, observers would have to wait until the connect succeeds to learn about the file descriptor attached event.
      
      Reviewed By: bschlinker
      
      Differential Revision: D29910574
      
      fbshipit-source-id: c452f1091c657a7d118b1e06546555aa04a34bf1
      2360b227
    • Dave Kurtzberg's avatar
      Add a parameterized ctor and m2 getter · 15ffb9b0
      Dave Kurtzberg authored
      Summary: Allows us to serialized and unserialize StreamingStats.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30108179
      
      fbshipit-source-id: 7a920acfa10e6c16613e9059049b8550478e81f0
      15ffb9b0
  15. 08 Aug, 2021 1 commit
  16. 07 Aug, 2021 1 commit
  17. 06 Aug, 2021 3 commits
    • Yiding Jia's avatar
      Reapply with more fixes: "[folly] Fix concurrency issues in ConcurrentSkipList."" · 379e39cc
      Yiding Jia authored
      Summary:
      Original diff D29248955 (https://github.com/facebook/folly/commit/6f4811eff3b7472347cc34c0ac9876ddd96287fc) had a bug that was causing a memory leak and was reverted.
      
      This diff reapplies it but with an extra fix.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30082935
      
      fbshipit-source-id: 0f119189fe631fc363dffe5c515a8bfa9a054cf6
      379e39cc
    • Amlan Nayak's avatar
      Record OS thread IDs for threads used in CPUThreadPoolExecutor · 21f9cf7d
      Amlan Nayak authored
      Summary:
      In order to collect backtraces of all threads consuming from the executor's
      queue(s), we need to record their actual thread IDs. We can keep track of the IDs
      in a list owned by the executor. Each thread in the pool will add its own
      thread ID to the tracking list by calling `folly::getOSThreadID()` and is also
      responsible for removing it from the list as it exits.
      
      Reviewed By: yfeldblum, mshneer
      
      Differential Revision: D30103988
      
      fbshipit-source-id: c59a1c31811684974fdb238433bd4796d0bbf2c8
      21f9cf7d
    • Andrew Smith's avatar
      Add FanoutSender abstraction to channels framework · 7f69cb31
      Andrew Smith authored
      Summary:
      The existing FanoutChannel construct takes in an input receiver, allows the creation of output receivers, and broadcasts all received values to the output receivers. It is good for the scenario where you already have an input receiver that you want to forward to multiple output receivers.
      
      However, for the scenario for which there is no existing input receiver, it is a bit heavy weight. To use it in this scenario, you have to create a separate channel, pass its receiver as the input receiver to the FanoutChannel, and write values to the sender.
      
      In addition to having to create a separate input channel that is otherwise unnecessary, it is not optimized for the case where there is a single output receiver. In many cases, there is typically only one output receiver. It would be ideal to have a construct that uses the same amount of memory as a simple channel, in the case where there is only one output receiver.
      
      FanoutSender solves both of these problems. FanoutSender does not require an input channel, and instead allows one to directly write values to all output receivers. In addition, in the case where there is only one output receiver, it uses exactly the same amount of memory as a simple channel.
      
      Reviewed By: aary
      
      Differential Revision: D29896797
      
      fbshipit-source-id: 18178f42364d53e84fb07424ed3e8cc0497e21e1
      7f69cb31
  18. 05 Aug, 2021 5 commits
    • Amlan Nayak's avatar
      Add WorkersProvider interface to QueueObserver · b817015d
      Amlan Nayak authored
      Summary:
      In order to colect backtraces from all threads consuming from a
      task queue, we need the ability to expose their correpsonding thread IDs.
      Here we introduce a new interface `WorkerProvider` which can be used to
      collect the thread IDs. The implementations of this interface will come
      later in the stack.
      
      Reviewed By: mshneer
      
      Differential Revision: D30101184
      
      fbshipit-source-id: 24aaaeeba1983e3917c0224e94fc741b66a4f6a4
      b817015d
    • Yedidya Feldblum's avatar
      cut unused config FOLLY_SUPPLY_MISSING_INT128_TRAITS · 3eb9e985
      Yedidya Feldblum authored
      Reviewed By: luciang
      
      Differential Revision: D30115064
      
      fbshipit-source-id: 53e29b7e3d1a9ea319e7e7f4a636a66c04d2bf24
      3eb9e985
    • Rodolfo Granata's avatar
      Add gdb printer for folly::ConcurrentHashMap. · 49255a75
      Rodolfo Granata authored
      Summary: Add a folly::ConcurrentHashMap GBD iterator and printer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30118862
      
      fbshipit-source-id: 4cda41bc36b4ffce10e133de4c377774fece1574
      49255a75
    • Yedidya Feldblum's avatar
      move queue-observer · 6e320985
      Yedidya Feldblum authored
      Summary: It's used for executor queues.
      
      Reviewed By: amlannayak
      
      Differential Revision: D30033262
      
      fbshipit-source-id: 9c01e560890373a11b869a8e26ccec2c35267c3c
      6e320985
    • Nikita Lutsenko's avatar
      folly | Fix hard-coded assumption in folly/Portability that MSVC builds always have SSE4.2. · f55bad22
      Nikita Lutsenko authored
      Summary:
      Windows is always supporting SSE4_2, right? What could go wrong?
      Well, we want to support UWP targeting ARM, meaning that well, we don't have SSE4.2, which causes all different sort of fun things.
      One of them - boost screaming in agony about both NEON SIMD and SSE instructions available.
      Fix it, by ensuring that we only ever declare that we support SSE, if we are not arm.
      
      Reviewed By: rudybear
      
      Differential Revision: D30095193
      
      fbshipit-source-id: e303f90348116cd3b5ea618dc737a647d7aa2cd6
      f55bad22