1. 24 May, 2018 2 commits
    • Saif Hasan's avatar
      fix build · 509b213e
      Saif Hasan authored
      Summary:
      fbthrift generate errorneous code when cpp type IOBuf pointer is used. Let's use
      IOBuf object instead as it is cheap to copy construct and underlying buffer is
      anyway shared when objects are copied.
      
      Reviewed By: plapukhov
      
      Differential Revision: D8130040
      
      fbshipit-source-id: 3c109a85951054fed890707f56170b46cfefc917
      509b213e
    • Matthieu Martin's avatar
      Fix possible deadlock in GILAwareManualExecutor · 6616c8e8
      Matthieu Martin authored
      Summary:
      See code comment
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D8130722
      
      fbshipit-source-id: c2a3e4b0de1fe7d07e28c4a7558e4367a1591ac1
      6616c8e8
  2. 23 May, 2018 15 commits
    • Yedidya Feldblum's avatar
      Give Try constructors pedantic exception specifiers · 72cb9df4
      Yedidya Feldblum authored
      Summary: [Folly] Give Try constructors and assignment operators pedantic exception specifiers deriving from corresponding exception specifiers of element type.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8105158
      
      fbshipit-source-id: 3cc9aae022ddaeef3ef2b742dde8ba084bfca830
      72cb9df4
    • Yedidya Feldblum's avatar
      Make exception_wrapper be noexcept-copyable · be791fd5
      Yedidya Feldblum authored
      Summary:
      [Folly] Make `exception_wrapper` be `noexcept`-copyable.
      
      This works across the storage types:
      * InSitu - only store `noexcept`-copyable objects in-situ.
      * OnHeap - `std::shared_ptr` is `noexcept`-copyable.
      * Thrown - `std::exception_ptr` is in practice `noexcept`-copyable since it is a smart-ptr for thrown objects.
      
      Reviewed By: marshallcline
      
      Differential Revision: D8109991
      
      fbshipit-source-id: e637c72466b22ab3076f52b4654a7538dcb1d30f
      be791fd5
    • Andrii Grynenko's avatar
      Use Executor::KeepAlive to store Executor in Core · b3e7e89c
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D8022229
      
      fbshipit-source-id: 1ba1d777cbbeb1d1ad95dc3f4bae6b3d431b9440
      b3e7e89c
    • Dan Melnic's avatar
      Back out "Iterate only through the threads that have in use entries" · 360d0d32
      Dan Melnic authored
      Summary:
      Original commit changeset: 577063f920fb
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: djwatson
      
      Differential Revision: D8126439
      
      fbshipit-source-id: 30154738262274a688f432465119b0730d395df6
      360d0d32
    • Yedidya Feldblum's avatar
      Invoke Futures then-continuations with the same cvref as passed · 9a4f6fdc
      Yedidya Feldblum authored
      Summary:
      [Folly] Invoke Futures `then`-continuations with the same cvref as passed.
      
      for example, if passed as `const&&`, invoke as `const&&`, and if passed as `volatile&`, invoke as `volatile&`.
      
      This brings a little more consistency to the library.
      
      Reviewed By: LeeHowes, phoad
      
      Differential Revision: D8109784
      
      fbshipit-source-id: 8dd56c6197211091ed53eba94aeec9d604268d15
      9a4f6fdc
    • Yuchen Dai's avatar
      fix atomic::store bad usage · a07a458a
      Yuchen Dai authored
      Summary:
      Fix usage of atomic::store() where memory order is the only argument.
      
      It worked because of memory_order value is implicit casted to correct value luckily.
      
      Reviewed By: djwatson
      
      Differential Revision: D8108348
      
      fbshipit-source-id: 7c4050b8cb50ec3ab6977cd9adce45249130320c
      a07a458a
    • Orvid King's avatar
      Fix MSVC build · c9ecca96
      Orvid King authored
      Summary: I broke the build because MSVC versions prior to Visual Studio 2017 Update 7 failed to compile it :)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8107563
      
      fbshipit-source-id: 0c8f97325fd76a56d335ff71c9b969ad2bfaa5a1
      c9ecca96
    • Dan Melnic's avatar
      Iterate only through the threads that have in use entries · 211921c8
      Dan Melnic authored
      Summary: Iterate only through the threads that have in use entries
      
      Reviewed By: djwatson
      
      Differential Revision: D7931363
      
      fbshipit-source-id: 577063f920fb432e255a59e90faa32ab72107124
      211921c8
    • Yedidya Feldblum's avatar
      Minimize AtFork deps · 4bfa2a85
      Yedidya Feldblum authored
      Summary: [Folly] Minimize `AtFork` deps by using removing use of `checkPosixError`. The owning library is a bit heavyweight.
      
      Reviewed By: simpkins
      
      Differential Revision: D8109884
      
      fbshipit-source-id: a0a41ff64fd44b843970ae30f8fdb8ff4ff22acd
      4bfa2a85
    • Aaron Orenstein's avatar
      Mark non-linux unused parameters as unused · 3384af41
      Aaron Orenstein authored
      Summary: Mark non-linux unused parameters as unused
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D8103305
      
      fbshipit-source-id: dc67849177e95718d0d6d658d1e2af88e867d81f
      3384af41
    • Orvid King's avatar
      Don't truncate window size · 0cb0a734
      Orvid King authored
      Summary: As per title.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8103967
      
      fbshipit-source-id: 27fbc45df3ee1ec8934ea3c16aaa490fb06ef622
      0cb0a734
    • Orvid King's avatar
      Back out "[Folly] [MSVC] Workaround MSVC 15.7 bug" · 5ef66c9e
      Orvid King authored
      Summary: Visual Studio 2017 Update 7.2 is out, so this is no longer needed. This should fix GCC 4.9 as well :)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8104179
      
      fbshipit-source-id: e3b01c2f7f0fe69dc7286d2cfaa5c2c99d821b23
      5ef66c9e
    • Nick Terrell's avatar
      Add support for advanced zstd options · 660c0417
      Nick Terrell authored
      Summary:
      * Use the new advanced API.
      * Support all advanced compression options and decompression window size.
      * Dictionary support is easy to add later when needed.
      * Remove the one-pass optimizations since zstd supports them by default now.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7898697
      
      fbshipit-source-id: 42d84808a9bf2200ebfb8d2071b853960a19eb79
      660c0417
    • Matthieu Martin's avatar
      Introduce GILAwareExecutor · d0142327
      Matthieu Martin authored
      Summary: A simpler manual executor that can be executed by a python thread, and release the GIL while waiting.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D8087779
      
      fbshipit-source-id: a75ecbda3804a53f1b705aa04546b74368738b7b
      d0142327
    • Matthieu Martin's avatar
      Rename AsyncioLoopController to ExecutorLoopController (and move to fibers/) · 5981f1bb
      Matthieu Martin authored
      Summary:
      AsyncioLoopController is totally generic.
      We were able, after all, to put all the python specifics in the Executor, and keep it simple.
      I'm using it with ManualExecutor succesfully in my project.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D8085689
      
      fbshipit-source-id: 007f65a72e41aa98113b7ee4e188719d9bc20340
      5981f1bb
  3. 22 May, 2018 5 commits
  4. 21 May, 2018 1 commit
    • Yedidya Feldblum's avatar
      Introduce makePromiseContract · 57b57616
      Yedidya Feldblum authored
      Summary:
      [Folly] Introduce makePromiseContract, for producing a paired promise-and-semi-future or a paired promise-and-future, depending on which overload is invoked.
      
      It is not ideal that a future is gotten from a promise, but only once. Rather, it is ideal that they be created together.
      
      C++17 code may use structured bindings:
      ```lang=c++
      auto [p, f] = makePromiseContract(); // promise with semi-future
      auto [p, f] = makePromiseContract(&e); // promise with future, given executor e
      ```
      
      Reviewed By: LeeHowes
      
      Differential Revision: D7984050
      
      fbshipit-source-id: 52ee5624fde7c48aa0e81243564ad067c6c6919f
      57b57616
  5. 20 May, 2018 2 commits
    • Orvid King's avatar
      Add collectAllSemiFuture and implement collectAll in terms of it · 4d6d653e
      Orvid King authored
      Summary: This will allow incremental migration of `collectAll` to `collectAllSemiFuture`. Once everything is migrated to `collectAllSemiFuture`, `collectAll` will change to be the exact same as `collectAllSemiFuture`, then all uses will be moved back to `collectAll` and `collectAllSemiFuture` will be removed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8015664
      
      fbshipit-source-id: 07a154dc733fd7e1e003f4c103355e7b5d1ad1b5
      4d6d653e
    • Maged Michael's avatar
      hazptr: Optimize size and speed of hazptr_holder and hazptr_array · 62c3a982
      Maged Michael authored
      Summary:
      Add hazptr_domain* member to hazptr_rec that never changes.
      Remove hazptr_domain* member from hazptr_holder.
      
      The primary optimization is reducing the sizes of hazptr_holder and hazptr_array from two pointers to one pointer per owned hazard pointer.
      
      A secondary advantage is allowing swap of an individual holder in hazptr_array with a hazptr_holder object or an element of another hazptr_array under the conditions: both are either empty or nonempty and if nonempty both hazptrs belong to the same domain.
      
      Performance effects on hazptr_holder:
      + Half the steps for empty construction, move and swap.
      + One less step in typical construction.
      - Indirect instead of direct read of pointer to domain, but indirection is likely to be a cache hit if the hazptr was used recently.
      
      Measurements:
      - Faster construction/destruction of hazptr_array<3>. 7.5 ns. instead of 8.5 ns.
      - No regression in other microbenchmarks.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D8010395
      
      fbshipit-source-id: 01ffd26f675e57547b1506b777c79d18052ccc65
      62c3a982
  6. 19 May, 2018 6 commits
    • Maged Michael's avatar
      hazptr: Link counting. Protecting descendants of protected objects. Mutable... · e56afab1
      Maged Michael authored
      hazptr: Link counting. Protecting descendants of protected objects. Mutable and immutable links. Automatic retirement.
      
      Summary:
      The class hazptr_obj_linked includes all the reference counting and automatic retirement mechanisms. It supports:
      - Mutable and Immutable links.
      - Certain and uncertain removal. With certain removal users call retire. With uncertain users call unlink when an object is unlinked. The library determines automatically when to retire such object.
      - E.g., UnboundedQueue uses immutable links with certain removal.
      - E.g., ConcurrentHashMap uses mutable links with uncertain removal.
      
      Reviewed By: djwatson
      
      Differential Revision: D7674658
      
      fbshipit-source-id: 948f5c3690367deaa0e2023a2def3bed2c22b9f0
      e56afab1
    • Andrii Grynenko's avatar
      Move CPU/IOThreadPoolExecutor keep-alive logic into ThreadPoolExecutor · f8651741
      Andrii Grynenko authored
      Summary: This makes keep-alive join also happen if stop/join are called directly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8060479
      
      fbshipit-source-id: 1d1c0cdbcaac2e439aee9ad14f00fa7e4fda2339
      f8651741
    • Andrii Grynenko's avatar
      Implement loopIgnoreKeepAlive() · 109f7655
      Andrii Grynenko authored
      Summary:
      This is useful to fix legacy tests that use loop(), as keep-alive tokens are used more widely.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8065959
      
      fbshipit-source-id: 2e7a27f538ac9d36eeea7ba3a882633a193141d1
      109f7655
    • Yedidya Feldblum's avatar
      Split Futures exceptions by Promise vs Future · 09c8a80a
      Yedidya Feldblum authored
      Summary:
      [Folly] Split Futures exceptions by `Promise` vs `Future`.
      
      * Move `Promise` exceptions into the `Promise` header.
      * Move `Future` exceptions into the `Future` header.
      * Split `NoState` into `PromiseInvalid` and `FutureInvalid`.
      * Remove the newly-empty exceptions header.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7966499
      
      fbshipit-source-id: 2dc6d2a941493979ebf47b3e70e5cf6a6fbd33cf
      09c8a80a
    • Murali Vilayannur's avatar
      Expose the dynamic cpu thread pool executor gflag define in header file · f5063ec7
      Murali Vilayannur authored
      Summary: Trivial change to allow different services to turn this flag off at runtime
      
      Reviewed By: djwatson
      
      Differential Revision: D8060492
      
      fbshipit-source-id: 8a62065ee1913fc67b6ae6983d03625849e139b3
      f5063ec7
    • Yedidya Feldblum's avatar
      like, like_t, forward_like · 38bda487
      Yedidya Feldblum authored
      Summary:
      [Folly] `like`, `like_t`, `forward_like`, as per p0847r0.
      
      See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0847r0.html.
      
      Reviewed By: nbronson
      
      Differential Revision: D8040722
      
      fbshipit-source-id: 4c8a64037ec7447c8afa7b086c36db0f836f66f2
      38bda487
  7. 18 May, 2018 8 commits
    • Dave Watson's avatar
      Make erase() return an iterator · 1fe37d89
      Dave Watson authored
      Summary: Make erase(iterator) return an iterator, like std containers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8047159
      
      fbshipit-source-id: 3cc94782a7afca0bf9fedefdc7296b9395ca9859
      1fe37d89
    • Maged Michael's avatar
      hazptr: Fix cleanup to wait for the concurrent reclamation of objects · bcdd651c
      Maged Michael authored
      Summary:
      This fix aims to prevent cases (pointed out by David Goldblatt) where cleanup returns while a concurrent slower bulk_reclaim has not completely reclaimed objects that are supposed to be reclaimed before the return from reclaim.
      
      This fix uses an atomic count of the number of ongoing  bulk_reclaim-s. Cleanup returns only if it observes that that count is zero.
      
      Reviewed By: djwatson
      
      Differential Revision: D7586325
      
      fbshipit-source-id: 341af641d20a7a07206c7238ea0356a9eabdbab5
      bcdd651c
    • Marshall Cline's avatar
      simplify Core state-space · 7026dbde
      Marshall Cline authored
      Summary:
      Remove Armed: it added an avoidable extra state transition, plus avoidable semantic complexity in the behavior/contract of setResult() & setCallback(), i.e., if either of those transitioned to Armed, that thread may or may not be the one that made the transition to Done with the possibly-synchronous call to the callback.
      
      After this change there is only one transition after Only* - to Done, and the new contract/behavior of setResult/setCallback is still asynchronous (the caller cannot know which thread will call the callback) but at least has only one asynchrony instead of two (the thread that transitions to Done is always the thread that calls doCallback()).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8049396
      
      fbshipit-source-id: 89a1e40ab8c09db4c8ab0ac3a1fd2cc5e092830d
      7026dbde
    • Maged Michael's avatar
      CoreCachedSharedPtr: Use synchronization/hazptr instead of experimental/hazptr · 140a17aa
      Maged Michael authored
      Summary: Use synchronization/hazptr instead of experimental/hazptr
      
      Reviewed By: djwatson
      
      Differential Revision: D7565384
      
      fbshipit-source-id: 26790eec80f344cb4b227672e6d51d97c9170dee
      140a17aa
    • Andre Pinto's avatar
      Fix typo · cf18e2d4
      Andre Pinto authored
      Reviewed By: Orvid
      
      Differential Revision: D8053447
      
      fbshipit-source-id: 4550e4fabffb7e6be7d7927292aed2b33c10dee5
      cf18e2d4
    • Orvid King's avatar
      Add a kerberos portability header · 99366f98
      Orvid King authored
      Summary: Kerberos has issues with include order on Windows, so give it it's own portability header to force the correct include order and undefine the mess it `#define`'s.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8050238
      
      fbshipit-source-id: 6c718f8f0db9f039734bead5f90cd289ea1dfd78
      99366f98
    • Andrii Grynenko's avatar
      Unit test fixes to enable use of Executor::KeepAlive<> in Futures (2/?) · 82b1f7c5
      Andrii Grynenko authored
      Summary:
      This is blocking D8022229
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8038878
      
      fbshipit-source-id: 4b5f085b86f065df0612a132ec26c3d4980edbd1
      82b1f7c5
    • Orvid King's avatar
      Include the Windows portability header in the fcntl portability header · 5a87e8ad
      Orvid King authored
      Summary:
      Because it defines `HANDLE_FLAG_INHERIT`
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D8050035
      
      fbshipit-source-id: a67d19aa7882f312273e0761123d6827fe07bd81
      5a87e8ad
  8. 17 May, 2018 1 commit
    • Marshall Cline's avatar
      faster(sometimes) interrupt-handler for Promise/Future · ee33c57f
      Marshall Cline authored
      Summary: Avoid overhead of std::function (virtual fn, possible malloc) when the interrupt msg reaches the core before the interrupt handler (the former in future.raise(), the latter in promise.setInterruptHandler()).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7994756
      
      fbshipit-source-id: 58827e7ac320b6585f1a1c3df08932bbe38f91ee
      ee33c57f