1. 18 Oct, 2017 1 commit
    • Yedidya Feldblum's avatar
      Simplify impl of setThreadName · bf58d50a
      Yedidya Feldblum authored
      Summary: [Folly] Simplify impl of `setThreadName`.
      
      Reviewed By: Orvid, ot
      
      Differential Revision: D6075179
      
      fbshipit-source-id: 720f29cc688f97b936813898238b8eb26b8a6141
      bf58d50a
  2. 17 Oct, 2017 7 commits
    • Dan Melnic's avatar
      Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer ! isManaged() · 68d54bdd
      Dan Melnic authored
      Summary: Do not set WriteFlags::WRITE_MSG_ZEROCOPY if the buffer isShared()
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6068711
      
      fbshipit-source-id: fff14dcd4fcb20c9dbb60794420845042518922c
      68d54bdd
    • Yedidya Feldblum's avatar
      Un-templatize Range::str · 899d83f0
      Yedidya Feldblum authored
      Summary: [Folly] Un-templatize `Range::str`.
      
      Reviewed By: ot
      
      Differential Revision: D6075642
      
      fbshipit-source-id: 08fc399c43750d34463de7634be4fe386b5db97c
      899d83f0
    • Yedidya Feldblum's avatar
      Refactor ShutdownSocketSet atomic state machine · a25c5a91
      Yedidya Feldblum authored
      Summary:
      [Folly] Refactor `ShutdownSocketSet` atomic state machine.
      
      * Format.
      * Use `while` over `goto`.
      * Avoid `memory_order_acq_rel` as the single-argument memory order; some platforms fail to build that.
      * Use `memory_order_relaxed` for all atomic operations because stronger memory orders are not actually required: the atomic state never serves as a barrier for synchronizing loads and stores of associated data because there is no associated data.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D6058292
      
      fbshipit-source-id: d45d7fcfa472e6e393a5f980e75ad9ea3358bab3
      a25c5a91
    • Yedidya Feldblum's avatar
      An InlineExecutor singleton · 9917cdab
      Yedidya Feldblum authored
      Summary:
      [Folly] An `InlineExecutor` singleton.
      
      Using the Leaky Meyers Singleton pattern, so that it is always available whenever required.
      
      Differential Revision: D6074534
      
      fbshipit-source-id: bd4c9cd6a1e60c80de5d2eef1cb6a1e7f16b4e50
      9917cdab
    • Andrew Krieger's avatar
      Don't make copies of std::string or fbstring when converting. · f82f2b0d
      Andrew Krieger authored
      Summary:
      This overload of estimateSpaceNeeded was taking a Src by
      value, but Src is constrained by IsSomeString which only returns
      true for std::string or fbstring, so this was inducing a copy
      in any situation where folly::to<> is used with varargs which
      contain fb/string arguments.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6059517
      
      fbshipit-source-id: adc239f9049e161fc4b750bae0e3de5dbdcd1bfc
      f82f2b0d
    • Yedidya Feldblum's avatar
      Make Range.h and FBString.h mutually independent · 1d4de585
      Yedidya Feldblum authored
      Summary:
      [Folly] Make `Range.h` and `FBString.h` mutually independent.
      
      This means that `Range` cannot directly know about `fbstring`, so any interactions between the two types must be indirected through templates.
      
      Motivation: `FBString.h` is a relatively heaviweight `#include` for things that need `Range.h` but which do not use `fbstring`.
      
      Reviewed By: ericniebler
      
      Differential Revision: D6062434
      
      fbshipit-source-id: e2f21c33f482eadffd0a8679eff4ece59bab53e9
      1d4de585
    • Yedidya Feldblum's avatar
      Shrink integral hasher specialization implementations · d201571c
      Yedidya Feldblum authored
      Summary:
      [Folly] Shrink integral `hasher` specialization implementations.
      
      Instead of giving them bodies, just use inheritance.
      
      Reviewed By: luciang
      
      Differential Revision: D6067757
      
      fbshipit-source-id: f71bd36132e1b66002493474825894b03754b34f
      d201571c
  3. 16 Oct, 2017 5 commits
    • Chad Austin's avatar
      fix typo in invalid log level error message · b83985c4
      Chad Austin authored
      Reviewed By: simpkins
      
      Differential Revision: D6068742
      
      fbshipit-source-id: a3b3b7fe4a6da8f250e5b9593f66b9f8a9345136
      b83985c4
    • qiao hai-jun's avatar
      fix typo · 0918ae11
      qiao hai-jun authored
      Summary: Closes https://github.com/facebook/folly/pull/692
      
      Differential Revision: D6066294
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: a533527058b8b5bc71fb6f40bad31a50e8c3f585
      0918ae11
    • Yedidya Feldblum's avatar
      4-way overloads for SemiFuture::value · 943408f5
      Yedidya Feldblum authored
      Summary:
      [Folly] 4-way overloads for `SemiFuture::value`.
      
      Overload on the receiver reference category and `const`-qualification, deriving the return type reference category and `const`-qualification. Like `Optional`, `Try`, etc.
      
      Differential Revision: D6062006
      
      fbshipit-source-id: d7396cd4d4bb62e99445d5f61cb360898fa1c3f3
      943408f5
    • Ognjen Dragoljevic's avatar
      Fix hash overloads for integral types · 4e2b0bb9
      Ognjen Dragoljevic authored
      Summary:
      `folly/Hash.h:379:12: error: implicit instantiation of undefined template 'folly::hasher<unsigned long, void>'`
      So, folly is unable to hash the very type it returns: `size_t`. Namely, folly has overloads for `uint32_t` and `uint64_t` which on my Mac map to `int` and `long long` respectively. `size_t` on the other hand maps to `long` which is neither.
      Rather than overloading library types (which are just typedefs), we should overload all the built-in types: `char`, `short`, `int`, `long`, `long long`, `signed` and `unsigned` variants (with special treatment of `char`).
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D6051600
      
      fbshipit-source-id: d59569dab963cbe0329aa589ff321cfb22308193
      4e2b0bb9
    • Andrew Krieger's avatar
      constexpr estimateSpaceNeeded for string literals. · b02d4348
      Andrew Krieger authored
      Summary:
      Partially inspired by WillerZ's investigation into faster compiling
      StringPiece work, I thought this would be an easy drop in that short
      circuits some compilation logic (or possibly is strictly better, since the
      StringPiece conversion method isn't constexpr).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6059537
      
      fbshipit-source-id: 072f56e58aa47db10b54825cac8a05dc035b295c
      b02d4348
  4. 15 Oct, 2017 1 commit
    • Marc Celani's avatar
      Move retrying method to separate header in folly/futures · 24a9e5fd
      Marc Celani authored
      Summary: folly/futures depends on folly/Random.h, which in turn depends on <random>, which is a fairly large header. Most users of folly::futures do not use retrying, so separate it into a separate header.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6028468
      
      fbshipit-source-id: d8155fe2ddff1a65c265a18f040ee6f1be3f3f0a
      24a9e5fd
  5. 13 Oct, 2017 5 commits
    • Yedidya Feldblum's avatar
      Style fixes for folly/experimental/gdb/README.md · 371636e9
      Yedidya Feldblum authored
      Summary:
      [Folly] Style fixes for `folly/experimental/gdb/README.md`.
      
      Should have no effect on Github rendering, but should affect PHabricator rendering.
      
      Reviewed By: Orvid, kennyyu
      
      Differential Revision: D6055017
      
      fbshipit-source-id: 54204a2b77beeb884cdc486207809f78ac80afe2
      371636e9
    • Neel Goyal's avatar
      Add AsyncSocketException.cpp to build sources · 80acc620
      Neel Goyal authored
      Summary: Add AsyncSocketException.cpp to the list of files to build in Makefile.am
      
      Reviewed By: knekritz
      
      Differential Revision: D6051989
      
      fbshipit-source-id: 72083a609fc994770eca078bfef5a0ed04322bfc
      80acc620
    • Vitaly Berov's avatar
      Replace ShutdownSocketSet to singleton · 4abb5a3a
      Vitaly Berov authored
      Summary:
      We recently found out that ShutdownSocketSet consumes 150+MB for our service, which uses duplex channels. The problem is that we create ~1000 of ThriftServers, and each of the creates its own ShutdownSocketSet.
      In reality, ShutdownSocketSet is only needed to kill all socket's FD in emergency before crash dump is taken, so they don't hand around waiting for crash dump to complete. There is no need to keep a SSS per ThriftServer, singleton should work just fine.
      There is a problem here, though. Currently a ThriftServer has 'immediateShutdown' method, which kills all sockets from SSS. So, if SSS becomes a singleton, and we have more than one ThriftServer, calling 'immediateShutdown' on one will kill sockets from the other one. First, it's a quite surprising behavior, and second, it complicates unit tests, which emulate thrift servers running in different processes.
      
      As a result,
      1. ShutdownSocketSet is created as a singleton, but each ThriftServer still keeps weak ptr to it (mostly for unit tests support).
      2. replaceShutdownSocketSet method is added to ThriftServer.h, so unit tests could set different SSS for different ThriftServers.
      3. method immediateShutdown is removed from ThriftServer, because its behavior would be 'surprising'.
      
      There still may be unexpected consequences of this change for the tests because of Singleton, but let's see.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6015576
      
      fbshipit-source-id: dab70dbf82d01bcc71bbe063f983e862911ceb24
      4abb5a3a
    • Lucian Grijincu's avatar
      folly: AsyncSocketException: move implementation to .cpp, refactor · 69d97159
      Lucian Grijincu authored
      Reviewed By: yfeldblum
      
      Differential Revision: D6042832
      
      fbshipit-source-id: c716ee672c4acfa39cab9f10f3b3f88ca770cd20
      69d97159
    • Yedidya Feldblum's avatar
      Move folly/Checksum.h into folly/hash/ · d31633e6
      Yedidya Feldblum authored
      Summary: [Folly] Move `folly/Checksum.h` into `folly/hash/`.
      
      Reviewed By: Orvid
      
      Differential Revision: D6045825
      
      fbshipit-source-id: 02d3e6a49e2c0fc115cfee09e1186be7a13525ba
      d31633e6
  6. 11 Oct, 2017 1 commit
    • Miroslav Crnic's avatar
      Add support for clang intrinsic constexpr · 42a989fa
      Miroslav Crnic authored
      Summary: Newer versions of clang >=3.4 support intrinsic constexpr
      
      Reviewed By: Orvid
      
      Differential Revision: D6008856
      
      fbshipit-source-id: 4e40a7032464216d181d76a854cafb2ab4be1be0
      42a989fa
  7. 10 Oct, 2017 1 commit
    • Cameron Pickett's avatar
      Handle nullptr from getTimekeeperSingleton · d1c5974b
      Cameron Pickett authored
      Summary:
      According to folly::Singleton::try_get(), https://fburl.com/23wqby9i, the caller is responsible for handling a nullptr return. In this case, we handle it poorly, via a crash both in production and debug code.
      
      This diff opts for handling the nullptr more gracefully, via a future loaded with an exception.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6006864
      
      fbshipit-source-id: e8fde57ed161b33fa1f157ce663ed85e69640c25
      d1c5974b
  8. 09 Oct, 2017 1 commit
    • Dan Melnic's avatar
      Add SO_ZEROCOPY support · fbc4c238
      Dan Melnic authored
      Summary: Add SO_ZEROCOPY support
      
      Reviewed By: djwatson
      
      Differential Revision: D5851637
      
      fbshipit-source-id: 5378b7e44ce9d888ae08527506218998974d4309
      fbc4c238
  9. 07 Oct, 2017 1 commit
    • Yedidya Feldblum's avatar
      Let EventBase::runInEventBaseThreadAndWait consume its argument · 662b86a9
      Yedidya Feldblum authored
      Summary:
      [Folly] Let `EventBase::runInEventBaseThreadAndWait` consume its argument.
      
      Likewise `EventBase::runImmediatelyOrRunInEventBaseThreadAndWait`.
      
      And enforce that the function is destructed before returning, so that, in the case of a wrapped lambda, all captured objects' destructors run before returning from the function.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D5994106
      
      fbshipit-source-id: 816c9431a85a3d41e4fda321065614f4c18f0697
      662b86a9
  10. 06 Oct, 2017 5 commits
    • Stiopa Koltsov's avatar
      future.then() is identical to future.unit() · 05ced584
      Stiopa Koltsov authored
      Summary:
      Document that `future.then()` is identical to `future.unit()`.
      
      Put functions next to each other to make it clear, and use identical
      wording.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5955451
      
      fbshipit-source-id: 1b55d5785dc0995d4d9364f48241e98ad01b31f4
      05ced584
    • Yedidya Feldblum's avatar
      Remove Executor::addPtr · 6a1cf45e
      Yedidya Feldblum authored
      Summary:
      [Folly] Remove `Executor::addPtr`.
      
      It was there to support passing non-copyable callable objects wrapped as `std::shared_ptr`. It is no longer useful since we have `Function`, which is a non-copyable version of `std::function` which can support capturing non-copyable objects, and it is generally unused.
      
      Reviewed By: spacedentist
      
      Differential Revision: D5983801
      
      fbshipit-source-id: b49a86f8dd7e5250a097b0e714a1bdf9ac362916
      6a1cf45e
    • Jun Qu's avatar
      Workaround for a gcc crash · 76ca3798
      Jun Qu authored
      Summary: I recently got a gcc crash when using `ConcurrentHashMap`
      
      Reviewed By: djwatson
      
      Differential Revision: D5994587
      
      fbshipit-source-id: 412d48aa6da12c428bb9ab5ed7a317d89c9580b9
      76ca3798
    • Valeriy Khromov's avatar
      add static makeFromPath to construct SocketAddress from a unix domain socket path · f09b0411
      Valeriy Khromov authored
      Summary:
      Add `SocketAddress::makeFromPath(StringPiece)` static member function to
      constructor `SocketAddress` from a path to Unix domain socket.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5974523
      
      fbshipit-source-id: b5c1537e67d07d1ef401fea75e35753392eeaf6b
      f09b0411
    • Yedidya Feldblum's avatar
      Use fewer keep-alives in VirtualEventBase::keepAliveRelease · 71d0dd7f
      Yedidya Feldblum authored
      Summary:
      [Folly] Use fewer keep-alives in `VirtualEventBase::keepAliveRelease`.
      
      {D5982132} mistakenly used `VirtualEventBase::add`, which holds a keep-alive on the master `EventBase`, instead of calling `EventBase::add` directly.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D5992403
      
      fbshipit-source-id: f427025c06f01e6a93d6eae8a051c3553f58be20
      71d0dd7f
  11. 05 Oct, 2017 4 commits
    • Yedidya Feldblum's avatar
      Make keepAliveRelease consistent between EventBase and VirtualEventBase · 25ddbd7f
      Yedidya Feldblum authored
      Summary: [Folly] Make `keepAliveRelease` consistent between `EventBase` and `VirtualEventBase`.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D5982132
      
      fbshipit-source-id: 536d48e5672567e78786691bfb283c34d1f31960
      25ddbd7f
    • Yedidya Feldblum's avatar
      Move GlobalThreadPoolList.h into folly/concurrency/ · 74570190
      Yedidya Feldblum authored
      Summary:
      [Folly] Move `GlobalThreadPoolList.h` into `folly/concurrency/`.
      
      This seems like a better place than the top-level. It seems reasonable because this has *something* to do with concurrency. This is used by executors, but is not itself an executor, so it was not clear that it should go to `folly/executors/`, although that also seems like quite the reasonable choice.
      
      Reviewed By: Orvid
      
      Differential Revision: D5985142
      
      fbshipit-source-id: 6117d133757af74023d6cffb838741da83d173bd
      74570190
    • Andre Pinto's avatar
      Add an overload to use backlashify with StringPiece · ff17894b
      Andre Pinto authored
      Summary: Allows calling backlashify on a StringPiece.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5930015
      
      fbshipit-source-id: ca14c78d9a90c45781da7229eb5d2f437792b2d1
      ff17894b
    • Lee Howes's avatar
      Add SemiFuture class. · a95a6976
      Lee Howes authored
      Summary:
      Offer a clean separation between future as a vocabulary type for crossing
      library interfaces, and future as a type to manage continuations.
      
      The principle is that if we want an API with clean separation of execution it
      should both return and receive SemiFutures. The returned SemiFuture would
      only be awaitable, but not continuable. If the caller wants to enqueue a
      continuation then it is efficiently convertable into a folly::Future by
      calling .via.
      
      This means that an API a) Does not have to take an executor to ensure it
      returns a valid future. That can be deferred to the caller or the caller's
      caller/target for true separation. b) The API can ensure that its own executor
      is not exposed to the caller, while still having a clean API.
      
      Obviously if some API wants to allow returning of a continuable future, then it
      can also provide an executor-taking API.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5769284
      
      fbshipit-source-id: 46241d1274bf7b1698a7d28a47cff2a65a983740
      a95a6976
  12. 04 Oct, 2017 4 commits
    • Eric Niebler's avatar
      give folly future's exceptions default visibility · eab6da6a
      Eric Niebler authored
      Summary: Exception types should have default visibility, otherwise RTTI doesn't work right.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D5976415
      
      fbshipit-source-id: 45dcfe3476b513aa49a6f78352318f31d381ada7
      eab6da6a
    • Yedidya Feldblum's avatar
      Move keepalive-acquire code into Executor::keepAliveAcquire overrides · b6861c02
      Yedidya Feldblum authored
      Summary:
      [Folly] Move keepalive-acquire code into `Executor::keepAliveAcquire` overrides.
      
      This makes the API more symmetric and allows for more flexibility. Also serves as preparation for generalizing the keepalive-token interface.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D5974080
      
      fbshipit-source-id: 26209e49a0f5834ba229d4bbfc9272c2e4ffb3fd
      b6861c02
    • Tom Jackson's avatar
      Benchmark comparison · f20581a4
      Tom Jackson authored
      Summary:
      I couldn't find anything that consumes `--json` output, so I made this. It prints out benchmark results from two runs, comparing each benchmark to its corresponding baseline. This should help with benchmarking changes across revisions.
      
      Along the way:
      - Two small transparent `struct`s replaces the use of `tuple`s everywhere.
      - New output JSON format (additive), formatted as array of arrays so order is preserved.
      - New comparison binary in `folly/tools/benchmark_compare`
      
      Sample output:
      
      {P58307694}
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5908017
      
      fbshipit-source-id: d7411e22b459db16bd897f656e48ea4e896cb1bf
      f20581a4
    • Yedidya Feldblum's avatar
      Let keep-alive tokens from VirtualEventBase be destroyed from any thread · b2d64a0a
      Yedidya Feldblum authored
      Summary:
      [Folly] Let keep-alive tokens from `VirtualEventBase` be destroyed from any thread.
      
      This case was missed in {D5951397} (facebook/folly@6f3b7616f3402355441c62ca60a36159435aa818).
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D5970670
      
      fbshipit-source-id: 19e2b00134516e68113234acd6111e21c3e23e8d
      b2d64a0a
  13. 03 Oct, 2017 3 commits
    • Maged Michael's avatar
      Dynamic MPMCQueue: Backout of last change as it may deadlock · 1292801d
      Maged Michael authored
      Summary: The previous change can lead to deadlock. Backing out.
      
      Reviewed By: djwatson
      
      Differential Revision: D5957084
      
      fbshipit-source-id: 72ea1cb6236367912b4b087da7e4d57f8a2daed0
      1292801d
    • Maged Michael's avatar
      Fixes: prevent compiler reporting UB, hazptr_array move operator, empty array test · 36b8f9c6
      Maged Michael authored
      Summary:
      Three fixes:
      (1) The compiler reports UB in line 432 for the case M > HAZPTR_TC_SIZE even though it is executed only if M <= HAZPTR_TC_SIZE. Added a condition M <= HAZPTR_TC_SIZE to help the compiler determine that line 432 is not executed in that case.
      (2) Added missing management of empty state in hazptr_array move operator
      (3) Added nullptr argument to empty hazptr_array in Array test
      
      Reviewed By: djwatson
      
      Differential Revision: D5951283
      
      fbshipit-source-id: cb8e61421ab06c7733f67bf2d2274d3311260ac4
      36b8f9c6
    • Yedidya Feldblum's avatar
      Let keep-alive tokens be destroyed from any thread · 6f3b7616
      Yedidya Feldblum authored
      Summary: [Folly] Let keep-alive tokens be destroyed from any thread.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D5951397
      
      fbshipit-source-id: 91e72588de4ef33a730ebef5770e77635d4e93ba
      6f3b7616
  14. 02 Oct, 2017 1 commit
    • Igor Sugak's avatar
      fix -Wvexing-parse · d6fe55fe
      Igor Sugak authored
      Summary:
      ```lang=cpp
      folly/test/stl_tests/StlVectorTest.cpp:1975:11: error: parentheses were disambiguated as redundant parentheses around declaration of variable named 'm' [-Werror,-Wvexing-parse]
          Vector(m);
                ^~~
      folly/test/stl_tests/StlVectorTest.cpp:1975:11: note: add a variable name to declare a 'Vector' initialized with 'm'
          Vector(m);
                ^
                 varname
      folly/test/stl_tests/StlVectorTest.cpp:1975:5: note: add enclosing parentheses to perform a function-style cast
          Vector(m);
          ^
          (        )
      folly/test/stl_tests/StlVectorTest.cpp:1975:11: note: remove parentheses to silence this warning
          Vector(m);
                ^ ~
      
      1 error generated.
      ```
      
      Reviewed By: Gownta
      
      Differential Revision: D5955613
      
      fbshipit-source-id: 3015570ce111603b3561914d07b55365a221c686
      d6fe55fe