1. 08 Jun, 2017 2 commits
    • Eric Niebler's avatar
      Extend the -Warray-bounds workaround in FixedString.h to gcc-5. · 16f34c7d
      Eric Niebler authored
      Summary: FixedString.h has a workaround for a gcc bug regarding erroneous -Werror=array-bounds errors. This commit extends the workaround to the gcc-5 series, which sadly is still broken. Life gets better with gcc-6.
      
      Reviewed By: luciang
      
      Differential Revision: D5210633
      
      fbshipit-source-id: 4fcf080d18ddc573636a3e58b61a97167a8c06ce
      16f34c7d
    • Qi Wang's avatar
      make extent_hooks static. · 7c9e64a0
      Qi Wang authored
      Summary:
      Make extent hooks static and avoid calling arena_destroy, in case there are
      alive allocations not freed yet.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5208102
      
      fbshipit-source-id: 612c772347cd90227fa303fd0b059edbaeb7d4e2
      7c9e64a0
  2. 07 Jun, 2017 12 commits
    • Christopher Dykes's avatar
      Implement __builtin_popcount under MSVC · 4929771e
      Christopher Dykes authored
      Summary:
      I thought I had already implemented this, but apparently I had only implemented the ll variable. Whoops.
      This implements the 32-bit version which fixes the build on Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5203680
      
      fbshipit-source-id: 02b133db59e232cac586944b0ffc0e8bbf5f533a
      4929771e
    • Christopher Dykes's avatar
      Exclude experimental/hazptr/bench from the globs used in the CMake build · 86c0ed4e
      Christopher Dykes authored
      Summary: The directory contains benchmarks and multiple `main`'s so shouldn't be included as part of the main folly library.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5204132
      
      fbshipit-source-id: 7289cb9c2ec292c13df39c9e7b48eca4166ca951
      86c0ed4e
    • Yedidya Feldblum's avatar
      Pass Try by rvalue ref in onError implementation · 4aa6bf94
      Yedidya Feldblum authored
      Summary:
      [Folly] Pass `Try` by rvalue ref in `onError` implementation.
      
      As is done in other overloads and in `thenImplementation`. For consistency.
      
      Reviewed By: spacedentist
      
      Differential Revision: D5199302
      
      fbshipit-source-id: c78db0c36fc7a0b846ca5e44fc237422c9203a24
      4aa6bf94
    • Sonia Mar's avatar
      Uri: switch to std::string over fbstring take 2 · 3d6d4933
      Sonia Mar authored
      Summary: Update tuple generated for hash/equal_to for `folly::Uri` to also use std::string
      
      Reviewed By: Orvid
      
      Differential Revision: D5199266
      
      fbshipit-source-id: bcd619dae01ffbf82fbb5c8987b0e87103572452
      3d6d4933
    • Kyle Nekritz's avatar
      Add OpenSSLCertUtils functions for DER encoding/decoding. · ba690cad
      Kyle Nekritz authored
      Reviewed By: anirudhvr
      
      Differential Revision: D5193205
      
      fbshipit-source-id: 5b427ee4f31008518078f5e54e85c0f0f2201da5
      ba690cad
    • Yedidya Feldblum's avatar
      Shrink the implementations of then and onError · 7dc11fbd
      Yedidya Feldblum authored
      Summary:
      [Folly] Shrink the implementations of `then` and `onError`.
      
      Just a small refactor.
      
      Reviewed By: spacedentist
      
      Differential Revision: D5180784
      
      fbshipit-source-id: a399d18500a2b4c5d8f24dee54891cca802b4461
      7dc11fbd
    • Yedidya Feldblum's avatar
      Try::tryGetExceptionObject · 717713f2
      Yedidya Feldblum authored
      Summary:
      [Folly] `Try::tryGetExceptionObject`.
      
      If the `Try` has a `std::exception` for the non-template overload or a `From` where `is_convertible<From*, Ex*>` for the template overload parameterized by `typename Ex`, returns a pointer to it. Otherwise returns `nullptr`.
      
      Reviewed By: spacedentist
      
      Differential Revision: D5180848
      
      fbshipit-source-id: b7593b7459259f9a1e1e78b36d548e55d086e722
      717713f2
    • Yedidya Feldblum's avatar
      Remove exception_wrapper::throwException · 3c7ee0d0
      Yedidya Feldblum authored
      Summary:
      [Folly] Remove `exception_wrapper::throwException`.
      
      It has been renamed to `throw_exception`.
      
      Reviewed By: Orvid
      
      Differential Revision: D5181005
      
      fbshipit-source-id: 442b3fd9bdaa8170db504a81651cbb085ea50624
      3c7ee0d0
    • Nick Terrell's avatar
      Add zlib/gzip streaming support · 641ad8da
      Nick Terrell authored
      Summary:
      Add streaming interface to the ZlibCodec.
      Implement ZlibStreamCodec::doCompress() and ZlibStreamCodec::doUncompress() using the streaming interface. fbgs CodecType::ZLIB and check that no caller requires thread-safety.
      I found one caller, but it was fixed in D5090855.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5169338
      
      fbshipit-source-id: 40478e162143623ad28fd8bc937d0195521f13fe
      641ad8da
    • Christopher Dykes's avatar
      Switch folly::Uri to use std::string rather than fbstring · 8dd0e3e9
      Christopher Dykes authored
      Summary: Using fbstring directly is not really worthwhile in the vast majority of cases, especially when most places just convert it into an `std::string` immediately.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5187835
      
      fbshipit-source-id: 6f7d71612d3765e8b501d2432cd6281369bfe0fa
      8dd0e3e9
    • Anirudh Ramachandran's avatar
      Add a version of async_test using openssl 1.1.0 · ae1594ea
      Anirudh Ramachandran authored
      Summary:
      Now that it's possible, let's add some 1.1.0 tests to avoid regressing
      1.1.0 support
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5167246
      
      fbshipit-source-id: ba12414504131697d4e0757c9c340a66f810acd4
      ae1594ea
    • Giuseppe Ottaviano's avatar
      Fix destruction order problem in getCoreAllocator · 55791684
      Giuseppe Ottaviano authored
      Summary: We cannot guarantee the correct destruction order of the Meyers singleton owning the allocator, and the objects allocated with it, so we just leak it using `Indestructible`.
      
      Reviewed By: djwatson
      
      Differential Revision: D5196227
      
      fbshipit-source-id: ec07ab1e21af7814194883b252d45aa36d2a04b1
      55791684
  3. 06 Jun, 2017 12 commits
    • Yedidya Feldblum's avatar
      Rename exception_wrapper::get_object to get_exception · 03c1142d
      Yedidya Feldblum authored
      Summary:
      [Folly] Rename `exception_wrapper::get_object` to `get_exception`.
      
      This will be a template overload of the existing non-template member `get_exception`, but it should just work.
      
      Reviewed By: spacedentist
      
      Differential Revision: D5180845
      
      fbshipit-source-id: 28e16e039ec6a7939b38f217b4ad5c6bc803f515
      03c1142d
    • Adam Simpkins's avatar
      additional minor cleanup to the TimeUtil code · 3396d608
      Adam Simpkins authored
      Summary:
      - Fix TimePoint to use steady_clock rather than system_clock
      - Use nanoseconds instead of milliseconds in most locations
      
      This code should probably also be moved into a folly::testing namespace or
      something.  This class is pretty specific to unit tests, and `folly::TimePoint`
      seems like too generic of a name for it.  However, just to keep things simple
      I'm not doing that as part of this diff yet.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5175630
      
      fbshipit-source-id: 26490fc7ff1b25fb86f09309e81108828cd0f091
      3396d608
    • Adam Simpkins's avatar
      update TimeUtil to use getOSThreadID() · c2bd7be5
      Adam Simpkins authored
      Summary:
      Use the newly introduced getOSThreadID() function to get a thread ID for
      determining thread scheduling information on Linux.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5173596
      
      fbshipit-source-id: 3e6fa352c3774986b0ac1f93bd6c7e4a29e08471
      c2bd7be5
    • Adam Simpkins's avatar
      fix timeWaiting computation in TimeUtil · 68f55ed0
      Adam Simpkins authored
      Summary:
      Some of the code in TimeUtil.cpp computes how long the current thread has spent
      waiting to be schedule on the CPU, so we can discount this time when testing
      timeout behavior.
      
      It appears that this code has been broken for a fairly long time.  Older Linux
      kernels reported values in /proc/<pid>/schedstat using jiffies.  However, it
      appears that this was changed in Linux 2.6.23 to report values using
      nanoseconds.  (It looks to me like this was changed in commit 425e0968a25f,
      which purports to simply be moving code from sched.c to sched_stats.h,
      but it appears to also have also changed this behavior.)
      
      This updates TimeUtil.cpp to compute the value correctly in modern Linux
      kernels.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5173598
      
      fbshipit-source-id: 98436d3a687400bf68661156ffce93eea7232632
      68f55ed0
    • Dave Watson's avatar
      Core-local allocator · 5ba3126f
      Dave Watson authored
      Summary:
      Adds a core-local allocator to CacheLocality.  Multiple objects using
      cache locality may share the same allocator, and allocate things less than
      cacheline sized, without incurring additional false-sharing overhead.
      
      Reviewed By: nbronson, ot
      
      Differential Revision: D5139886
      
      fbshipit-source-id: a9804662d6339829a12e0791f418dabd9678f1bf
      5ba3126f
    • Christopher Dykes's avatar
      Fix the build of MallctlHelperTest without JEMalloc · c797a08c
      Christopher Dykes authored
      Summary:
      `kDecayCmd` was guarded such that it wasn't being defined at all if JEMalloc wasn't available.
      
      Closes https://github.com/facebook/folly/issues/608
      
      Reviewed By: interwq
      
      Differential Revision: D5193721
      
      fbshipit-source-id: 1a2666de70e90eac1e9f2e130d0452b01b3239fa
      c797a08c
    • Victor Zverovich's avatar
      Add element construction/destruction hooks to IndexedMemPool · 1e6a1dce
      Victor Zverovich authored
      Summary: This diff adds a Traits template parameter to IndexedMemPool that allows more control over the lifetime management of individual elements, including mixes of lazy and eager recycle semantics (or colocation of different classes of data inside a single element). It also arranges that an index is not reported as isAllocated() until it has been passed to Traits::initialize and passed to Traits::onAllocate at least once, so code that is traversing valid indexes doesn't need to deal with the post-initialize but pre-onAllocate state (it must still deal with indexes that reported isAllocated() as true but have since been passed to onRecycle). The default behavior is unchanged.
      
      Reviewed By: nbronson
      
      Differential Revision: D5177462
      
      fbshipit-source-id: e7d22c860ab6bf25083977dfb5a63955641c9cfb
      1e6a1dce
    • Christopher Dykes's avatar
      Drop a dead include of FBString.h from MemoryMapping.h · 111b7bcc
      Christopher Dykes authored
      Summary: MemoryMapping doesn't use fbstring directly at all, so this include isn't needed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5188209
      
      fbshipit-source-id: d86b876a96343c830295bea1162580215a340815
      111b7bcc
    • Adam Simpkins's avatar
      add missing include to ThreadId.h · 14d85244
      Adam Simpkins authored
      Summary:
      The syscall() function is defined in <unistd.h>
      <sys/syscall.h> apparently only defines IDs to be used with syscall(), but does
      not define the syscall() function itself.
      
      This caused build failures for files that included ThreadId.h before unistd.h
      
      Reviewed By: Orvid
      
      Differential Revision: D5189658
      
      fbshipit-source-id: 2ec8ea1d58f3fc14cf458a53ecaa811978527398
      14d85244
    • Nathan Bronson's avatar
      UninitializedMemoryHacks · 7cf58370
      Nathan Bronson authored
      Summary:
      This diff adds helper functions that can resize std::string or std::vector
      without constructing or initializing new elements.  They are designed
      for retroactively optimizing code where touching every element twice
      (or touching never-used elements once) shows up in profiling, and where
      restructuring the code to use fixed-length arrays or IOBuf-s would
      be difficult.
      
      Implementations are provided for 5 string implementations (pre-c++11
      libstdc++, libstdc++ with SSO, libc++, std::basic_fbstring, and MSVC)
      and 3 vector implementations (libstdc++, libc++, and MSVC).  On an
      unsupported platform you will hopefully get a #warn if you include
      UninitializedMemoryHacks.h followed by a linker error if you actually
      use it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5102679
      
      fbshipit-source-id: 536c00eabae4cdb8a0affe3e919a372f4dc51ac5
      7cf58370
    • Qi Wang's avatar
      Update MallctlHelperTest with jemalloc 5 APIs. · cd201c86
      Qi Wang authored
      Summary: Update decay time API to be jemalloc 4 & 5 compatible.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5188574
      
      fbshipit-source-id: 8e3c26c8b6431efdd0ec7ff492a065bddb816b4b
      cd201c86
    • Adam Simpkins's avatar
      add getOSThreadID() · b611811b
      Adam Simpkins authored
      Summary:
      Add a getOSThreadID() call.  This is similar to getCurrentThreadID(), but
      returns the OS-level thread ID.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5173627
      
      fbshipit-source-id: 0e8695ecfc1e382d12526c1b7d1717be114c9f4a
      b611811b
  4. 05 Jun, 2017 6 commits
    • Christopher Dykes's avatar
      Switch Bits.h to just use the popcount builtins directly · f1eb3c50
      Christopher Dykes authored
      Summary:
      These builtins are available on all platforms under GCC, using the instruction directly when available and a fallback implementation otherwise.
      They are implemented in the builtins portability header for MSVC.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5185106
      
      fbshipit-source-id: a58305a6b99eb49bd165876a4a60c512a259b225
      f1eb3c50
    • Christopher Dykes's avatar
      Rename folly/detail/Malloc.h to folly/detail/MallocImpl.h · 43fde9f2
      Christopher Dykes authored
      Summary: This makes the name of the header match the source file.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5186193
      
      fbshipit-source-id: b1f9041fb730eacb91ad167e500c25df8f8ba947
      43fde9f2
    • Yedidya Feldblum's avatar
      Let map-related functions be templated over key types · 54800835
      Yedidya Feldblum authored
      Summary:
      [Folly] Let map-related functions be templated over key types.
      
      This supports the case where map members like `find` may be overloaded or templated on types other than the map's `key_type const&`.
      
      In C++14, standard library map types gain template overloads for `find` and for other members, permitting lookups without constructing `key_type` instances. This is useful primarily when `key_type` is expensive but another object type comparable with `key_type` is inexpensive. As a common example, a `key_type` of `std::string` is expensive in the general case because it allocates storage on the heap but `std::string_view` (C++17), when constructed with non-allocated `char const*, std::size_t`, would be inexpensive.
      
      Reviewed By: terrelln
      
      Differential Revision: D5145879
      
      fbshipit-source-id: 979b75bfe55661aab11d5302da1bcd7830abd5af
      54800835
    • Peter Goldsborough's avatar
      Fixed documentation in folly/Random.h · a6b10d84
      Peter Goldsborough authored
      Summary:
      The docs give `ThreadLocalPRNG rng = Random::threadLocalPRNG()` as an example
      of creating a thread local PRNG, but `Random::threadLocalPRNG()` does not/no longer
      exist. I think it's just `folly::ThreadLocalPRNG` right now.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5184992
      
      fbshipit-source-id: 63a9ef62b32fca42088abec419ae53531910cc82
      a6b10d84
    • Qi Wang's avatar
      Fix JemallocNodumpAllocator destructor w/ jemalloc 5.0. · 028e9512
      Qi Wang authored
      Summary: Destroy created arena which has extent_hooks linked.
      
      Reviewed By: jasone
      
      Differential Revision: D5177535
      
      fbshipit-source-id: 7d75f4276fc174c4d4ce1102dfb8ec8c27c1f56d
      028e9512
    • Phil Willoughby's avatar
      Make StringKeyed* more complete · 4ce8cc70
      Phil Willoughby authored
      Summary: Add `count()` and `swap()` methods. Ensure that `operator==` works.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5169393
      
      fbshipit-source-id: a8025f6fdf251e38b0d2f27733d18967a55c6a15
      4ce8cc70
  5. 04 Jun, 2017 3 commits
  6. 03 Jun, 2017 1 commit
    • Yedidya Feldblum's avatar
      Apply clang-format to folly/gen/ (partial: namespace) · bbc51806
      Yedidya Feldblum authored
      Summary:
      [Folly] Apply `clang-format` to `folly/gen/` (partial: namespace).
      
      With some manual rearrangement in the places where `clang-format` does awkward things, with the result that clang-format over `folly/gen/` becomes a no-op.
      
      Reviewed By: Orvid
      
      Differential Revision: D5177428
      
      fbshipit-source-id: 17f51d00454a7be7f29dcf1a2ff3d0eaf1de72ab
      bbc51806
  7. 02 Jun, 2017 4 commits
    • Yedidya Feldblum's avatar
      Apply clang-format to folly/portability/ · 1b67e9aa
      Yedidya Feldblum authored
      Summary:
      [Folly] Apply `clang-format` to `folly/portability/`.
      
      With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over `folly/portability/` becomes a no-op.
      
      Reviewed By: igorsugak
      
      Differential Revision: D5170107
      
      fbshipit-source-id: ceadd96740b4877cbae947846f0e738e6aaf5ed1
      1b67e9aa
    • Qi Wang's avatar
      Fix JemallocNodumpAllocator extent_hooks API. · 5fc76bd2
      Qi Wang authored
      Summary: Using extent_hooks mallctl to update hooks.
      
      Reviewed By: jasone
      
      Differential Revision: D5174623
      
      fbshipit-source-id: 9313ee9ae55c85d973736077727e54a5825f4c3d
      5fc76bd2
    • Maged Michael's avatar
      Hazard pointers: Optimize memory order, add bulk reclamation control, add... · 3c118217
      Maged Michael authored
      Hazard pointers: Optimize memory order, add bulk reclamation control, add stats, add implementation switches, add benchmarks.
      
      Summary: Make the implementation partially performant by optimizing memory order and using asymmetric memory barrier for full fences. Also added more control for bulk reclamation implementation, stats, and quality of implementation switches.
      
      Reviewed By: djwatson
      
      Differential Revision: D5129614
      
      fbshipit-source-id: c597edf711fdc8f16f80523bd8cae42c51fbe140
      3c118217
    • Qi Wang's avatar
      Update folly/JemallocNodumpAllocator to jemalloc 4 & 5 compatible. · a88d0d72
      Qi Wang authored
      Summary:
      jemalloc 5.0 comes replaced chunks with extents APIs. Make the API compatible
      with both jemalloc 4 and 5.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D5170925
      
      fbshipit-source-id: ce25723975729b0b63371f89a96842a1b2e3b3cc
      a88d0d72