1. 25 Jan, 2018 7 commits
    • Xiao Shi's avatar
      backport `std::make_from_tuple` from C++17 · 4f622004
      Xiao Shi authored
      Summary:
      `std::make_from_tuple` constructs an object of type T, using the elements of the
      tuple t as the arguments to the constructor. Backport.
      
      For the unit test, I referred to
      https://github.com/phalpern/uses-allocator/blob/711f6071a1230272de28c022400d678e7e9f0228/make_from_tuple.t.cpp
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6808665
      
      fbshipit-source-id: 257f27110c01da39b5415b02415d74f0b6062051
      4f622004
    • Yedidya Feldblum's avatar
      Cut extraneous dep on glog from Expected · ab97d44a
      Yedidya Feldblum authored
      Summary: [Folly] Cut extraneous dep on `glog` from `Expected`.
      
      Reviewed By: mzlee
      
      Differential Revision: D6768016
      
      fbshipit-source-id: 7b242797ccfe18ea7ccb3ef7a045ff55147dd2eb
      ab97d44a
    • Adam Simpkins's avatar
      cmake: run tests even without built-in gtest support · 58b26400
      Adam Simpkins authored
      Summary:
      When `gtest_add_tests()` is not available (CMake versions before 3.9) just use
      `add_test()` to add each test executable as a single test.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6805681
      
      fbshipit-source-id: a5fa95600dc29659498725cdc3cb1ae00188e1a3
      58b26400
    • Yedidya Feldblum's avatar
      Fix folly/synchronization/Tearable.h under gcc49 · 44634d57
      Yedidya Feldblum authored
      Summary: [Folly] Fix `folly/synchronization/Tearable.h` under `gcc49`, which version of `libstdc++` lacks `std::is_trivially_copyable`.
      
      Reviewed By: simpkins
      
      Differential Revision: D6805662
      
      fbshipit-source-id: 5f368cda58b860c7a7ee05addb325a655ab09830
      44634d57
    • Scott Franklin's avatar
      Fix a segfault in folly::window · 5ae1055c
      Scott Franklin authored
      Summary:
      If the callback passed to `window` throws an exception, the process will
      segfault.
      
      This happens because `Core::doCallback` will execute a callback that throws
      an exception twice. Once with the original arguments, and again with the wrapped
      exception: https://fburl.com/wdmztc4l
      
      In the case of `window`, the callback in question moves its `ctx` to the next
      iteration of `spawn`, and so the second call to the callback segfaults.
      
      This prevents the issue by wrapping the call to `func` in a future, which captures
      the exception and returns it to the caller, rather than allowing it to bubble out and
      break things.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6802396
      
      fbshipit-source-id: 3595c622e8e8f58209c7b20f553f7642bc49c089
      5ae1055c
    • Yedidya Feldblum's avatar
      Improve the SingletonThreadLocal fast path · 2d7a636e
      Yedidya Feldblum authored
      Summary:
      [Folly] Improve the `SingletonThreadLocal` fast path.
      
      Principally, by having the thread-local cache checked checked before the static-local guard variable is checked, rather than after.
      
      This change measurably improves the `EventBase` benchmark:
      
      ```name=branch
      ============================================================================
      folly/io/async/test/EventBaseBenchmark.cpp      relative  time/iter  iters/s
      ============================================================================
      timeMeasurementsOn                                           1.02us  980.21K
      timeMeasurementsOff                              251.64%   405.41ns    2.47M
      ============================================================================
      ```
      ```name=master
      ============================================================================
      folly/io/async/test/EventBaseBenchmark.cpp      relative  time/iter  iters/s
      ============================================================================
      timeMeasurementsOn                                           1.03us  969.51K
      timeMeasurementsOff                              247.08%   417.45ns    2.40M
      ============================================================================
      ```
      
      This change shortens the fast-path in `folly::RequestContext::getStaticContext()` (manually cleaned up):
      
      ```name=branch
      ---- fast path ----
      <+0>:     mov    rax,QWORD PTR fs:folly::SingletonThreadLocal<...>::get()::cache@tpoff
      <+9>:     test   rax,rax
      <+12>:    je     folly::RequestContext::getStaticContext()+16
      <+14>:    ret
      <+15>:    nop
      ---- slow path ----
      <+16>:    push   rbp
      <+17>:    mov    rbp,rsp
      <+20>:    call   folly::SingletonThreadLocal<...>::getWrapperOutline()
      <+25>:    mov    rdx,QWORD PTR fs:0x0
      <+34>:    mov    QWORD PTR fs:folly::SingletonThreadLocal<...>::get()::cache@tpoff,rax
      <+43>:    add    rdx,OFFSET FLAT:folly::SingletonThreadLocal<...>::get()::cache@tpoff
      <+50>:    mov    QWORD PTR [rax+0x10],rdx
      <+54>:    pop    rbp
      <+55>:    ret
      ```
      ```name=master
      ---- fast path ----
      <+0>:     push   rbp
      <+1>:     mov    rbp,rsp
      <+4>:     push   rbx
      <+5>:     sub    rsp,0x8
      <+9>:     cmp    BYTE PTR guard variable for folly::RequestContext::getStaticContext()::singleton[rip],0x0
      <+16>:    je     folly::RequestContext::getStaticContext()+48
      <+18>:    mov    rax,QWORD PTR fs:folly::SingletonThreadLocal<...>::get()::cache@tpoff
      <+27>:    test   rax,rax
      <+30>:    je     folly::RequestContext::getStaticContext()+96
      <+32>:    mov    rbx,QWORD PTR [rbp-0x8]
      <+36>:    leave
      <+37>:    ret
      <+38>:    nop    WORD PTR cs:[rax+rax*1+0x0]
      ---- slow path ----
      <+48>:    mov    edi,OFFSET FLAT:guard variable for folly::RequestContext::getStaticContext()::singleton
      <+53>:    call   __cxa_guard_acquire
      <+58>:    test   eax,eax
      <+60>:    je     folly::RequestContext::getStaticContext()+18
      <+62>:    sub    rsp,0x8
      <+66>:    mov    edi,OFFSET FLAT:folly::RequestContext::getStaticContext()::singleton
      <+71>:    push   0x0
      <+73>:    call   folly::SingletonThreadLocal<...>::SingletonThreadLocal({lambda()})
      <+78>:    pop    rax
      <+79>:    mov    edi,OFFSET FLAT:guard variable for folly::RequestContext::getStaticContext()::singleton
      <+84>:    pop    rdx
      <+85>:    call   __cxa_guard_release
      <+90>:    jmp    folly::RequestContext::getStaticContext()+18
      <+92>:    nop    DWORD PTR [rax+0x0]
      <+96>:    call   folly::SingletonThreadLocal<...>::getSlow()
      <+101>:   mov    rbx,QWORD PTR [rbp-0x8]
      <+105>:   mov    QWORD PTR fs:folly::SingletonThreadLocal<...>::get()::cache@tpoff,rax
      <+114>:   leave
      <+115>:   ret
      <+116>:   mov    rbx,rax
      <+119>:   mov    edi,OFFSET FLAT:guard variable for folly::RequestContext::getStaticContext()::singleton
      <+124>:   call   __cxa_guard_abort
      <+129>:   mov    rdi,rbx
      <+132>:   call   _Unwind_Resume
      ```
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D6763655
      
      fbshipit-source-id: 6f2d317ffd40a4e1f143b4bbbd087e85cc667b8c
      2d7a636e
    • Petr Lapukhov's avatar
      Add support for JSON merge diff generation · 58791d65
      Petr Lapukhov authored
      Summary: Add method to recursively compute RFC7386-compliant merge-diff between two folly::dynamic objects.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6794339
      
      fbshipit-source-id: f2b807404faa922d5a705f858825329a95fb0d38
      58791d65
  2. 24 Jan, 2018 12 commits
    • Yedidya Feldblum's avatar
      Fix autotools build to include GlobalShutdownSocketSet · 30a7a657
      Yedidya Feldblum authored
      Summary: [Folly] Fix autotools build to include `GlobalShutdownSocketSet`.
      
      Reviewed By: pixelb
      
      Differential Revision: D6801184
      
      fbshipit-source-id: f832b6b5b77872d1ced44295efee7a39529561aa
      30a7a657
    • Adam Simpkins's avatar
      cmake: explicitly include library files from io/async/test · b91e237a
      Adam Simpkins authored
      Summary:
      The top-level CMakeLists.txt explicitly includes any files inside "test"
      subdirectories.  However, the folly/io/async/test contains several library
      headers and sources that we do want to include in libfolly.  Explicitly
      re-include these files.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6794707
      
      fbshipit-source-id: 9df3157503f317c49e48252497b8a3d06e6161d5
      b91e237a
    • Yedidya Feldblum's avatar
      Split out the global ShutdownSocketSet singleton · f9511420
      Yedidya Feldblum authored
      Summary:
      [Folly] Split out the global `ShutdownSocketSet` singleton into its own library to keep the dependencies of `ShutdownSocketSet` lighter-weight.
      
      In general, globals should be an opt-in sort of thing anyway.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D6790009
      
      fbshipit-source-id: c68fa2bbaeaf3ff205e0c3b1c739d7561e940e64
      f9511420
    • Adam Simpkins's avatar
      cmake: update to work with recent upstream googletest build changes · a963e277
      Adam Simpkins authored
      Summary:
      Previously to use gmock you simply needed to link against libgmock_main.
      However, googletest pull request #1339 was recently merged into upstream
      googletest: https://github.com/google/googletest/pull/1339
      
      These changes now require explicitly linking against libgmock_main, libgmock,
      and libgtest.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6794709
      
      fbshipit-source-id: 03dcccec966e62240987ee0051dfa87be8614cca
      a963e277
    • Adam Simpkins's avatar
      cmake: split exception_tracer out into separate libraries · da420c9a
      Adam Simpkins authored
      Summary:
      The exception_tracer code changes program behavior when you link it in.
      Therefore it should not be included in the main libfolly library.
      
      This splits the exception_tracer code out into 3 separate libraries, which
      matches the behavior described in the exception_tracer README.md file.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6787807
      
      fbshipit-source-id: 51400c3ff464d359b4acc56679b5f584f3b586fd
      da420c9a
    • Adam Simpkins's avatar
      cmake: split Benchmark.cpp into a separate library · 5249f02a
      Adam Simpkins authored
      Summary:
      Move Benchmark.cpp out of the main libfolly library and into its own
      libfollybenchmark library.
      
      This more closely follows the build artifacts produced by the autoconf build,
      and will help avoid breaking downstream projects that depend on folly and
      expect to find libfollybenchmark.  The code in Benchmark.cpp is also normally
      only needed by test programs.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6793538
      
      fbshipit-source-id: fd273c11fc9f199a159b9e5d14badaf805480db0
      5249f02a
    • Lee Howes's avatar
      Add anonymous namespace for private function. · b36f00f6
      Lee Howes authored
      Summary: Exported symbol breaks under strict warnings on some mobile builds. Remove export by using anonymous namespace as it is not required.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6791282
      
      fbshipit-source-id: fd7f8294fdcdc2069cc6fea64c9e269bc094c9f8
      b36f00f6
    • Petr Lapukhov's avatar
      Add merge patch functionality from RFC7386 · 794ea3ee
      Petr Lapukhov authored
      Summary: Merge patch is simple method of editing JSON documents. This implementation uses the recursive version documented in the RFC.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6777104
      
      fbshipit-source-id: 554f801fe793a6fe004a8321ca41510b48225aa9
      794ea3ee
    • Aaryaman Sagar's avatar
      Add map typedefs to EvictingCacheMap · f3db6f96
      Aaryaman Sagar authored
      Summary: as title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6565911
      
      fbshipit-source-id: 5bed8f44520f6c1d7d6e685bf2a38cf97f734205
      f3db6f96
    • Lee Howes's avatar
      Rename variable to avoid shadowing warning. · 27e1f366
      Lee Howes authored
      Summary: Variable shadowing warning under specific compiler flags. This works around that by renaming.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6782706
      
      fbshipit-source-id: 60f379f301a88ab370b056469693a198439d1b11
      27e1f366
    • Lee Howes's avatar
      Modify default alignment for UnboundedQueue to work correctly on ARM builds. · dee041f9
      Lee Howes authored
      Summary: The original code provided an unsupported alignment for 32-bit ARM builds. This change makes use of hardware_destructive_interference_size, which represents exactly what the alignment field is used for.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6782366
      
      fbshipit-source-id: b8e2cdf6a0bafdba96d40d729535646b1f6660df
      dee041f9
    • Yedidya Feldblum's avatar
      An unsorted tag · e4bc13ee
      Yedidya Feldblum authored
      Summary:
      [Folly] An `unsorted` tag.
      
      For contexts in which it is desired explicitly to allow, as an optimization, the passing of unsorted containers, where such would ordinarily be assumed to be a pessimization or assumed to be incorrect.
      
      Reviewed By: igorsugak
      
      Differential Revision: D6782860
      
      fbshipit-source-id: 0bc7002306497e8bb0a62c4589d4f243da062ff8
      e4bc13ee
  3. 23 Jan, 2018 9 commits
    • Adam Simpkins's avatar
      cmake: use -std=gnu++14 when performing configure checks · c8d7b138
      Adam Simpkins authored
      Summary:
      Always use the `-std=gnu++14` compiler flag when performing configure-time
      checks on Unix-based platforms.
      
      On older versions of gcc (e.g. 5.x) some of the configuration checks
      incorrectly fail without this option.
      
      Reviewed By: meyering
      
      Differential Revision: D6788847
      
      fbshipit-source-id: 6e182ff9930a42b01c23f9a0cceda0108052224b
      c8d7b138
    • Adam Simpkins's avatar
      cmake: use -Wshadow-compatible-local if supported · f49dd821
      Adam Simpkins authored
      Summary:
      Use the `use -Wshadow-compatible-local` flag if the compiler supports it.
      
      This also required marking the gmock include directory as a system include
      directory, to prevent the compiler from warning about existing name shadowing
      in gmock's header files.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6787806
      
      fbshipit-source-id: f0e5f6de543a47b19a09440c58ee2961dab23054
      f49dd821
    • Adam Simpkins's avatar
      cmake: only use -faligned-new and -Wno-noexcept-type if supported · 51da0727
      Adam Simpkins authored
      Summary:
      On unix platforms, check to see if the compiler supports the `-faligned-new`
      and `-Wno-noexcept-type` flags before adding them to the compiler command line
      flags.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6787808
      
      fbshipit-source-id: d34af5ae4251ad3639fdaa1a8d5cb2df4b10e986
      51da0727
    • Michael Lee's avatar
      Fix various shadowing warnings within tests · 507ab831
      Michael Lee authored
      Summary: A lot of shadowed variables in tests. Simple renaming should suffice.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6786138
      
      fbshipit-source-id: 22c1c4d7cac13b367ed534a3f1d20714150b39f9
      507ab831
    • Pádraig Brady's avatar
      folly: fix make_optional compliation issue with gnu++17 · 90866787
      Pádraig Brady authored
      Summary:
      This clashes with std::make_optional with -std=gnu++17 giving:
        call of overloaded 'make_optional(std::__cxx11::basic_string<char>)' is ambiguous
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6780579
      
      fbshipit-source-id: fea8c76869e4d9b744fc3182379328a91879b1d2
      90866787
    • Nick Terrell's avatar
      Revert D6745720: [folly][compression] Log (de)compression bytes · 59cb2ab0
      Nick Terrell authored
      Summary:
      This reverts commit 1249d203df610cb29c16e03f7a06ea90aea80418
      
      bypass-lint
      
      An infra SEV is better than not reverting this diff.
      If you copy this password, see you in SEV Review!
      cause_a_sev_many_files
      
      Differential Revision: D6745720
      
      fbshipit-source-id: b357d0d8c42388d6f322cbb8f6d8958f7f02df54
      59cb2ab0
    • Nick Terrell's avatar
      Log (de)compression bytes · 0c20289b
      Nick Terrell authored
      Summary:
      Log bytes before/after (de)compression to the logging backend. Use the codec name in the key, and for lz4/zstd also include the library version and compression level.
      
      I chose the keys such that each individual piece as <= 15 characters, to be inlined. However, I chose readability of the keys over trying to squeeze the entire key in 15 characters.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6745720
      
      fbshipit-source-id: 1249d203df610cb29c16e03f7a06ea90aea80418
      0c20289b
    • Nick Terrell's avatar
      Add counters interface · b35b5a98
      Nick Terrell authored
      Summary: Adds an open source counters interface.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6609118
      
      fbshipit-source-id: cc326443339b88acdd11e4184eb0c82d786732c2
      b35b5a98
    • Pádraig Brady's avatar
      support folly::chrono::coarse_steady_clock with c++17 · 37129826
      Pádraig Brady authored
      Summary:
      Move the coarse_steady_clock definition outside
      the c++ < 17 specific defines, as otherwise it's not
      defined when using -std=gnu++17.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6780601
      
      fbshipit-source-id: 35cc5aa10db7d890e17bf03cc5e80803a9356d7a
      37129826
  4. 20 Jan, 2018 2 commits
    • Maged Michael's avatar
      Fix integer sign consistency. · 73fbda10
      Maged Michael authored
      Summary: Keeping all variables that interact with hazptr_domain::rcount_ signed int to avoid conversion errors.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6754593
      
      fbshipit-source-id: e283f127a112a529a0e98eb82b6061b44aa9d2ca
      73fbda10
    • Yedidya Feldblum's avatar
      Remove unsafe tag and add presorted tag · e52b2964
      Yedidya Feldblum authored
      Summary:
      [Folly] Remove `unsafe` tag and add `presorted` tag.
      
      There are varieties of unsafety, so let us be more explicit about which variety of unsafety is invoked in each case.
      
      Differential Revision: D6758520
      
      fbshipit-source-id: d198a3c7601971460f91acc7787c9da02ae283c0
      e52b2964
  5. 19 Jan, 2018 10 commits
    • Adam Simpkins's avatar
      remove unused include in Demangle.cpp · f3585b22
      Adam Simpkins authored
      Summary: folly/memory/Malloc.h was included but not needed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6757598
      
      fbshipit-source-id: 241b939724b21a94739e14335ddfaadfcd00dda3
      f3585b22
    • Nathan Bronson's avatar
      remove closure from assert · e3d4b1ba
      Nathan Bronson authored
      Summary:
      Somebody reported compilation issues with the closure in post()'s
      assert, resulting in "error: lambda-expression in unevaluated context".
      While I haven't been able to reproduce the problem locally, it is easy
      enough to work around in this case.
      
      Reviewed By: djwatson, mcallahan
      
      Differential Revision: D6759739
      
      fbshipit-source-id: 9f8082a1e20cd9ddf626cb176542e4e861a7e702
      e3d4b1ba
    • Yedidya Feldblum's avatar
      Use MemoryIdler in SaturatingSemaphore · 729928e7
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `MemoryIdler` in `SaturatingSemaphore`.
      
      As is used in `Baton`.
      
      And merge the two invocations of `futexWait` and `futexWaitUntil` - `futexWaitUntil` also tests for the max-deadline internally.
      
      Reviewed By: djwatson
      
      Differential Revision: D6720045
      
      fbshipit-source-id: a48187a6c866dbf99bb5c7283e0288b939bef2e5
      729928e7
    • Yedidya Feldblum's avatar
      Handle max deadlines in Futex · 9938799b
      Yedidya Feldblum authored
      Summary:
      [Folly] Handle max deadlines in `Futex`.
      
      Some of the synchronization code internally treats deadlines which are equivalent to `time_point::max()` for the same clock as a sentinel value indicating a deadline at infinity, or equivalently the lack of a deadline.
      
      Care must be taken when converting between clocks to translate a deadline at infinity for one clock to the deadline at infinity for the other clock.
      
      Reviewed By: nbronson
      
      Differential Revision: D6720021
      
      fbshipit-source-id: cfc230dd2d8db55297385a4afcb6d87ae4221840
      9938799b
    • Lee Howes's avatar
      Add TimedDrivableExecutor to folly. · 20808864
      Lee Howes authored
      Summary: Adds a TimedDrivableExecutor implementation of DrivableExecutor that adds a driveUntil method. driveUntil is as drive, except that it takes a timepoint and will stop driving after that time to allow callers to time out more easily.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6658320
      
      fbshipit-source-id: a75145748e78497ce107ae152f25729547883835
      20808864
    • Yedidya Feldblum's avatar
      Fix copyright line in folly/synchronization/test/ParkingLotBenchmark.cpp · f57db697
      Yedidya Feldblum authored
      Summary: [Folly] Fix copyright line in `folly/synchronization/test/ParkingLotBenchmark.cpp`.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D6758502
      
      fbshipit-source-id: cae2a79940c7c9cc58c29977141199ab1e902081
      f57db697
    • Adam Simpkins's avatar
      cmake: remove the check preventing cmake on non-Windows platforms · 0eca7c9f
      Adam Simpkins authored
      Summary:
      I believe the CMake build scripts have a similar level of functionality to the
      autoconf-based build scripts even on Linux these days.  This lets users use
      CMake on Linux and Mac, rather than directing them to autoconf instead.
      
      Reviewed By: meyering
      
      Differential Revision: D6745366
      
      fbshipit-source-id: 0361eecead55ee06269192eee8d2e7286eb182b8
      0eca7c9f
    • Adam Simpkins's avatar
      cmake: mark the compression tests as slow · 2e5089d5
      Adam Simpkins authored
      Summary:
      The compression test code has a large number of parameterized tests that run
      with a large number of parameter combinations.  These tests take many minutes
      to run.
      
      Reviewed By: meyering
      
      Differential Revision: D6745364
      
      fbshipit-source-id: dac5d5eb4a786da7be453742fac5f92a9740e468
      2e5089d5
    • Adam Simpkins's avatar
      cmake: enable running the tests · 5a477268
      Adam Simpkins authored
      Summary:
      CMake 3.9+ includes built-in support for gtest.  This updates the CMake build
      scripts to make use of this if the GoogleTest module is available.
      
      Reviewed By: meyering
      
      Differential Revision: D6745369
      
      fbshipit-source-id: 1ef978874b9a0ef2cc5f48ab1c7a0b55d0f1155e
      5a477268
    • Adam Simpkins's avatar
      cmake: build as many source files as possible · b50a3dd8
      Adam Simpkins authored
      Summary:
      The CMakeLists.txt file finds the sources and headers for the main folly
      library by finding all *.cpp and *.h files, and then excluding specific ones.
      
      The CMakeLists.txt file was originally written for Windows builds, and it was
      hard-coded to exclude a number of files that do not build on Windows.   This
      updates the file to properly check for the dependencies, and build these files
      if their required third-party dependencies are available.
      
      Reviewed By: meyering
      
      Differential Revision: D6745368
      
      fbshipit-source-id: 3ee04d54147a68c482aab50d30bc9fe2a4134eef
      b50a3dd8