1. 20 Dec, 2020 3 commits
    • Orvid King's avatar
      Use portability/GTest.h · 2d871f2f
      Orvid King authored
      Summary: Don't use gtest/gtest.h directly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25659806
      
      fbshipit-source-id: a8dd0da814465a787ab7904bdd0256f22b6e3ed8
      2d871f2f
    • Orvid King's avatar
      Match DoubleRadixSort test name to file name · e4eb39f3
      Orvid King authored
      Summary: As per title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25636982
      
      fbshipit-source-id: a59c2325558175e122941000ab645c8735a3a425
      e4eb39f3
    • Yedidya Feldblum's avatar
      use throw_exception in Arena · bc8c42bb
      Yedidya Feldblum authored
      Summary: Use `throw_exception` consistently in `Arena` for consistency.
      
      Differential Revision: D25637401
      
      fbshipit-source-id: 92cda5acc09b871fed78044fa3f3fa2c41b01609
      bc8c42bb
  2. 19 Dec, 2020 6 commits
    • Yedidya Feldblum's avatar
      asan_region_is_poisoned · e6955f4d
      Yedidya Feldblum authored
      Summary: [folly] `asan_region_is_poisoned` to wrap Address Sanitizer's `__asan_region_is_poisoned`.
      
      Reviewed By: ot, luciang, markisaa
      
      Differential Revision: D25651040
      
      fbshipit-source-id: 0c8f1d0203ada43746b5e2e71c1bd8b883248f68
      e6955f4d
    • Alfred Fuller's avatar
      Fix include order and grouping in folly - 7/13 · 59fe375d
      Alfred Fuller authored
      Summary: All changes were automated
      
      Reviewed By: Orvid
      
      Differential Revision: D25507555
      
      fbshipit-source-id: c0be9a04b8a5f502f4753ce6e163a78c428bfad6
      59fe375d
    • Dan Melnic's avatar
      Fix QUIC OSS build · 4cc7f892
      Dan Melnic authored
      Summary:
      Fix QUIC OSS build
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: danobi
      
      Differential Revision: D25645282
      
      fbshipit-source-id: fcb71d4e930d7ac3802f31d71599338fb346eb80
      4cc7f892
    • Orvid King's avatar
      Include portability/SysTypes.h for ssize_t · e01b9f04
      Orvid King authored
      Summary: Required for Windows with the more strict include order via upcoming formatting diffs.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25636437
      
      fbshipit-source-id: 0a5fd400f63220400f89affb11b66e9692e9b352
      e01b9f04
    • Orvid King's avatar
      Remove dependence on common for a test · 47de1a56
      Orvid King authored
      Summary: Because folly can't depend on common.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25636772
      
      fbshipit-source-id: d7b049330c9ca68eb4013fde5ca6de9413433823
      47de1a56
    • Misha Shneerson's avatar
      Fix race conditions on shutdown of MeteredExecutor · d7c40bc1
      Misha Shneerson authored
      Summary: Allow scheduling a "poison" task to indicate shutdown
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D25609015
      
      fbshipit-source-id: 8a42b99b402d78db7cfa3bd194730bb6948567c6
      d7c40bc1
  3. 18 Dec, 2020 7 commits
    • Andrew Huang's avatar
      Add opt-out switch for TLS 1.3 in SSLContext · ed4b5a77
      Andrew Huang authored
      Summary: Currently doesn't do anything since TLS 1.3 is not yet enabled by default. Once it is, calling disableTLS13() on a context will set the max TLS version to TLS 1.2.
      
      Reviewed By: mingtaoy
      
      Differential Revision: D25642589
      
      fbshipit-source-id: 0e580916b929111ed9721ca142b59eab0ea187df
      ed4b5a77
    • Shai Szulanski's avatar
      Template get_optional on Optional type · 20f47e6c
      Shai Szulanski authored
      Summary: Allows use with std::optional when available
      
      Reviewed By: WillerZ
      
      Differential Revision: D25618828
      
      fbshipit-source-id: 3e039406ff1e885fd1767148b907635b23f7a88b
      20f47e6c
    • Yedidya Feldblum's avatar
      use comparison expectations in Arena test · 2a41f3f0
      Yedidya Feldblum authored
      Summary: Use comparison expectations like `EXPECT_GE` in `Arena` test as v.s. `EXPECT_TRUE` with the comparison inside.
      
      Reviewed By: markisaa
      
      Differential Revision: D25631097
      
      fbshipit-source-id: 4fb430f34d7683e3b82dd3fbb4408360f8990353
      2a41f3f0
    • Alfred Fuller's avatar
      Fix include order and grouping in folly - 10/13 · 376557bb
      Alfred Fuller authored
      Summary: All changes were automated
      
      Reviewed By: Orvid
      
      Differential Revision: D25507575
      
      fbshipit-source-id: cbddef5a79008d9bf8b6e0234e6433084e5d8df9
      376557bb
    • Orvid King's avatar
      Remove vim edit modes from the 4 files that have them · 5a51004b
      Orvid King authored
      Summary: These are the only files out of hundreds in folly that have them, so just remove them entirely.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25612198
      
      fbshipit-source-id: 88d4f5c2ffa08d45d0a901c9ef874cddc2730291
      5a51004b
    • Maged Michael's avatar
      hazptr: Reduce noisy logging · f8dbfec6
      Maged Michael authored
      Summary: Eliminate noisy log message and provide the intended deadlock clue in a function name.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25627130
      
      fbshipit-source-id: 8d92007d4fa7eff1efb5857f7f49bebde2d59b70
      f8dbfec6
    • Orvid King's avatar
      Rename a couple of tests for consistency · 8b6ee86f
      Orvid King authored
      Summary: Specifically, ending in Test, singular, and reflecting the file being tested in full.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25612187
      
      fbshipit-source-id: 514477e08b9e231d8574cae19640717b689b7d56
      8b6ee86f
  4. 17 Dec, 2020 5 commits
  5. 16 Dec, 2020 3 commits
    • Misha Shneerson's avatar
      metered scheduling executor adapter · 2b32e9c1
      Misha Shneerson authored
      Summary:
      Motivation: we sometimes need to add concept of lower priorities on top of executors which provide custom scheduling via custom APIs such `EDFThreadPoolExecutor`.
      
      This adapter wraps an arbitrary executor, and adds an additional queue. Tasks from this queue will be fetched and placed on the wrapped executor's queue in a metered fashion - in particular we only allow up to "maxReadAtOnce" tasks to be placed onto the main executors queue.
      
      Once work is added to metered queue, the adapter schedules callback into the wrapped executor. When callback is executed it:
      1) fetches head task from the queue
      2) fetches up to maxReadAtOnce - 1, and reschedules those onto the main executor.
      3) reschedules itself onto the main executor
      4) executes the task fetched at stage 1.
      
      While in theory this algorithm does not provide strong priority guarantees, in practice lower priority tasks are almost always yielding to the higher priority tasks.
      
      This primitive also allows interesting compositions to be built:
      1. multiple priorities scheduling can be achieved by chaining metered adapters.
      2. Fair queue scheduling (e.g. round robin consumption from N queues) can be achieved by creating N metered adapters wrapping the same executor.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: prshreshtha
      
      Differential Revision: D24983861
      
      fbshipit-source-id: 1a4ce61fc7cc706889da9724de71822bfaab440b
      2b32e9c1
    • Nanshu Chen's avatar
      make IOBuf.__iter__ yield Python builtin memoryview · 90f04fa1
      Nanshu Chen authored
      Summary:
      So it may be easier to use in Python code.
      
      A lot of Python code will check the type with this:
      ```
      if isinstance(obj, (bytes, memoryview)):
        ...
      ```
      
      Currently, the `IOBuf.__iter__` returns a `cython.view.memoryview` c-type (which can be only "cimport" in cython but not able to "import), and to make it useable in scenarios like above, we have to explicitly cast it to builtin `memoryview`.
      
      With this change, the use of the iterator is more natural.
      
      Reviewed By: fried
      
      Differential Revision: D25577842
      
      fbshipit-source-id: 6b22028d06bba639fca32f7de3a063e1fb1baa15
      90f04fa1
    • Nikita Lutsenko's avatar
      folly | benchmark | Add support to run benchmarks and get a list of results for custom printing. · b1433701
      Nikita Lutsenko authored
      Summary:
      Benchmarks are great, but are missing parts that allows them to be run outside of raw binary, like in mobile context, where we generally want to showcase the list of results, instead of pretty printing them to stdout.
      To allow for that - adding a new public API, and restructuring few things, to code dedupe and still maintain the same functionality.
      
      Reviewed By: Orvid
      
      Differential Revision: D25552087
      
      fbshipit-source-id: 946a9fbcac3faff0a69f3d86d20f3621649c7e5a
      b1433701
  6. 15 Dec, 2020 4 commits
    • Andrew Huang's avatar
      Replace old AsyncSSLSocket session API with V2 · ffc3227f
      Andrew Huang authored
      Summary:
      This new API has a few benefits:
      1. It allows `getSSLSession` to support TLS 1.3 session resumption by returning a mutable session wrapper as opposed to the immutable `SSL_SESSION*` object.
      2. OpenSSL `SSL_SESSION*` objects require the caller to keep accurate reference counts. Failure to do so can result in memory leaks or use-after-free errors.
      3. This design abstracts away OpenSSL internals, which are unnecessary for the caller to perform session resumption.
      
      Reviewed By: mingtaoy
      
      Differential Revision: D24239802
      
      fbshipit-source-id: cd3e90217717394f32dc6a2281e7a40c805990b2
      ffc3227f
    • Pranjal Raihan's avatar
      Expose folly::observer::waitForAllUpdates as public API · 0cb5aa0f
      Pranjal Raihan authored
      Summary:
      In most cases, `folly::observer::waitForAllUpdates` should not be needed. However, the asynchronous nature of observers break some basic assumptions that most users expect. Such as:
      ```
      thing.set(value);
      EXPECT_EQ(thing.get(), value);
      ```
      If `thing` is using `folly::observer` underneath the hood, the asynchrony is passed on to the user which is very easy to overlook, leading to bugs. The API of `thing` might want to enforce that when `thing.set` returns, all observed values will have been updated.
      Blocking is a perfectly okay solution in cases we don't expect an observer to be updated frequently.
      
      Differential Revision: D25542376
      
      fbshipit-source-id: c83909807fbf36e0311a45b667da94c43751a1da
      0cb5aa0f
    • Shai Szulanski's avatar
      Add co_result support to AsyncGenerator · e8aa07ff
      Shai Szulanski authored
      Summary: Mirrors Task. One behavioral difference is that yielding an empty Try from a Task converts into a UsingUninitializedTry exception, while for AsyncGenerator it converts into a return. This is for consistency with Thrift's ClientBufferedStream to avoid confusing users, but there is also an argument for converting to UsingUninitializedTry instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25379361
      
      fbshipit-source-id: 2a2878185696566b29345c99fee7ba74bef4ae8a
      e8aa07ff
    • Pranav Thulasiram Bhat's avatar
      Python error handling · 41f4344c
      Pranav Thulasiram Bhat authored
      Summary:
      This diff introduces a generic abstraction to convert a python error (set by a C-API call) into an informative C++ exception.
      
      The main motivation for this is to improve the error handling behavior when dealing with failed cython api module imports.
      
      This diff adds one callsite to the new abstraction in fiber.cpp  to demonstrate its usage.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25469594
      
      fbshipit-source-id: e9f83c06460f35fa76030ceae9726297276db850
      41f4344c
  7. 14 Dec, 2020 1 commit
    • Daan De Meyer's avatar
      Extend AsyncPipe with SingleProducer template parameter. · ab42eb8f
      Daan De Meyer authored
      Summary:
      When SingleProducer is disabled, AsyncPipe's method becomes thread-safe
      and can be called by multiple threads simultaneously. This is useful
      in a use case where a long running operation is being executed by
      multiple threads that all want to post status updates to the same
      AsyncPipe instance.
      
      Reviewed By: iahs
      
      Differential Revision: D25494695
      
      fbshipit-source-id: 1d0a74ec69dc8f64c171e21be612d211919cda4b
      ab42eb8f
  8. 12 Dec, 2020 1 commit
  9. 11 Dec, 2020 7 commits
    • Yu Zhao's avatar
      Fix mutex lock issue at the end of tsan test · f0bada9d
      Yu Zhao authored
      Summary:
      During tsan test, sometimes annotationGuard() is called after kAnnotationMutexes is already destroyed which throws exception.
      This change fix the issue by uses Indestructible for kAnnotationMutexes, so that it is not destroyed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25443571
      
      fbshipit-source-id: 69411a7edc4f96ba8c7d08bd29f87ab7b2ff78ae
      f0bada9d
    • Zino Benaissa's avatar
      Make folly::small_vector friendly to compiler optimizations · 66d50da2
      Zino Benaissa authored
      Summary:
      This includes several enhancements to folly::small_vector:
      
      Eliminate overhead accessing vector elements by making heap_ points to element 0 of the vector.  To get start address only dispatch is required as shown below:
      
           value_type* data () {
             // Dispatch between heap_ or internalStorage,
             return isExtern() ? heap_ : &internalStorage_;
           }
      
      Reorganize the implementation by recording if capacity is stored internally or on the heap in "size". As a result the maximum vector size is half smaller. This is the only visible behavior change of this PR. Assuming size is 64 bits then
        - bit63 determines if vector elements are stored in internalStorage_ or externally in the heap
        - bit62 determines if vector capacity is stored internally or on the heap
        - bit61..bit0 contain the size of the vector.
      
      Reduce the overhead of updating size buy adding incrementSize functions.
      
      Tune emplace_back function and vector initialization.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24413105
      
      fbshipit-source-id: b447704832af9c734be51aa6d23b8cb4be69a8bf
      66d50da2
    • Pranjal Raihan's avatar
      Use SharedMutex instead of MicroLock in AtomicObserver · f1c0c3c1
      Pranjal Raihan authored
      Summary:
      The initialization of `folly::MicroLock` *looks* correct. MSAN instrumentation probably needs to be disabled in its implementation.
      
      Regardless, the main point of using `folly::MicroLock` was its low memory usage (1 byte). I'm now changing it to `folly::SharedMutex` (4 bytes) which will be the same size due to alignment. Although `folly::SharedMutex` is not ideal for write-only locks, we don't care too much about write performance here.
      
      Differential Revision: D25487925
      
      fbshipit-source-id: 4c30650cf22dafbdaa9fea0c2252d29caf477d54
      f1c0c3c1
    • Eric Niebler's avatar
      use folly::void_t instead of std::void_t · 5e2a41e9
      Eric Niebler authored
      Summary: folly/Traits.h defines a `void_t` alias in the `folly::` namespace. Just use that instead of specifying the one in `std::`.
      
      Reviewed By: ispeters
      
      Differential Revision: D25483712
      
      fbshipit-source-id: 6be0435dfec600690cc90bc15fd3d2af17826173
      5e2a41e9
    • Misha Shneerson's avatar
      Allow Consumer of AtomicNotificationQueue to manage folly::RequestContext · c5d7abd5
      Misha Shneerson authored
      Reviewed By: prshreshtha
      
      Differential Revision: D25387330
      
      fbshipit-source-id: 027e04024e01d1eab938d67a2d1dfc93c9322b15
      c5d7abd5
    • Pranav Thulasiram Bhat's avatar
      Simplify getFiberManager · ebb18e1e
      Pranav Thulasiram Bhat authored
      Summary: The call-once logic in getFiberManager was unnecessarily complex. getFiberManager should only be called on main context, so use a static var initialization to implement the call-once logic (using executor.cpp as an example).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25467655
      
      fbshipit-source-id: c880b1740edf28944e772c9310f3e45f5612396d
      ebb18e1e
    • Pranav Thulasiram Bhat's avatar
      Support multiple inputs to ShallowCopyScopeGuard · 33a42353
      Pranav Thulasiram Bhat authored
      Summary:
      With the current constructor setup, overwriting multiple request datas involves chaining together multiple ShallowCopyScopeGuard. This is quite inefficient as it involves copying the requests-data/callbacks maps multiple times.
      
      This diff introduces a new variadic constructor that accepts RequestDataItems (named pair of token and data)
      
      Reviewed By: A5he
      
      Differential Revision: D25317291
      
      fbshipit-source-id: 8a9cb00a615ecf802f22727189e4dc5a0c056c73
      33a42353
  10. 10 Dec, 2020 3 commits