1. 23 Oct, 2018 1 commit
    • Nathan Bronson's avatar
      checkedMalloc/free substitutes that performs sized deallocation · 9ae803c7
      Nathan Bronson authored
      Summary:
      Sized deallocation makes it faster for jemalloc to locate an
      allocation's metadata.  Accessing this functionality via ::operator
      delete(void*,size_t) is both portable and a bit more direct than
      calling sdallocx after a dynamic jemalloc check.  This diff adds small
      functions allocateBytes and deallocateBytes that are replacements
      for folly::checkedMalloc and free (and should be paired), to localize
      the #ifdef.
      
      Reviewed By: marksantaniello
      
      Differential Revision: D10496934
      
      fbshipit-source-id: eb193e1c315ca88286126f5eb68c705301ad5177
      9ae803c7
  2. 22 Oct, 2018 5 commits
    • Maged Michael's avatar
      Remove obsolete version of hazard pointers under folly/experimental · aee5ab34
      Maged Michael authored
      Summary:
      Remove obsolete version of hazard pointers under folly/experimental.
      Current version is under folly/synchronization.
      
      Reviewed By: djwatson
      
      Differential Revision: D10441558
      
      fbshipit-source-id: 36ef42f83a857ce4bdfff8b64cf9dcc179e0c804
      aee5ab34
    • Adam Simpkins's avatar
      cmake: always include files from the source directory first · 3bd7d93d
      Adam Simpkins authored
      Summary:
      Add the current source and build directories to the very front of the include
      directory list.  This ensures that folly finds its own local headers first,
      even if the install directory already contains an older version of the folly
      headers.
      
      Even though the install directory was appended to the include list after the
      current source directory in this statement, it could have ended up already in
      the include list if other dependencies (e.g., glog or gmock) were found in
      that directory.
      
      Reviewed By: Orvid
      
      Differential Revision: D10448692
      
      fbshipit-source-id: 539613a055db41d6115f8d04c5f6fa90841a414f
      3bd7d93d
    • Kirk Shoop's avatar
      move pushmi into folly namespace · b5df374b
      Kirk Shoop authored
      Summary:
      put pushmi inside the folly namespace.
      
      NOTE: we discussed in the team and decided that we preferred to have a sub-namespace for pushmi
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10455165
      
      fbshipit-source-id: d0131d96172a14746971e2de7dbac7bb10604229
      b5df374b
    • Jeroen Vaelen's avatar
      fix typo in gen docs · eb20fbbe
      Jeroen Vaelen authored
      Reviewed By: ddrcoder
      
      Differential Revision: D10461414
      
      fbshipit-source-id: 75c6ddc7979ade91917cacb0b58038bbde51172a
      eb20fbbe
    • Jeroen Vaelen's avatar
      fix ifndef error path · c474a2d7
      Jeroen Vaelen authored
      Summary: The error was pointing to a file that does not exist.
      
      Reviewed By: ddrcoder, Orvid
      
      Differential Revision: D10461496
      
      fbshipit-source-id: 4a282db547ad0924da23ea1b7652cf702599acab
      c474a2d7
  3. 20 Oct, 2018 2 commits
  4. 19 Oct, 2018 9 commits
    • Doron Roberts-Kedes's avatar
      DeterministicSchedule: Make the data_ field of Deterministic Atomic come from... · 8cfc7d7f
      Doron Roberts-Kedes authored
      DeterministicSchedule: Make the data_ field of Deterministic Atomic come from a class template param.
      
      Summary: see title.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10467678
      
      fbshipit-source-id: b407cfa3c0cd1100b1f8f01ff8f2fee1f2a99ecb
      8cfc7d7f
    • Doron Roberts-Kedes's avatar
      DeterministicSchedule: Make data field of DeterministicAtomic private and rename to data_ · cda0ac8f
      Doron Roberts-Kedes authored
      Summary: See title.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10418223
      
      fbshipit-source-id: 262c92581ba6b36741f647e6cde624a4372436cf
      cda0ac8f
    • Kudo Chien's avatar
      Fix posix_memalign symbol not found with Android API 16 (#953) · c831d06b
      Kudo Chien authored
      Summary:
      According to this https://github.com/android-ndk/ndk/issues/647,
        posix_memalign may not exist on Android API 16.
        From Android NDK r17c, the API exists for Android API 17+.
      ```
          #if __ANDROID_API__ >= 17
          int posix_memalign(void** __memptr, size_t __alignment, size_t __size) __INTRODUCED_IN(17);
          #endif /* __ANDROID_API__ >= 17 */
      ```
        Change the code to use posix_memalign only after Android API 17+.
        This would also fix issue for OSS React Native to pack latest folly and building with clang.
        See: https://github.com/facebook/react-native/issues/20302 and https://github.com/facebook/react-native/issues/20342
      Pull Request resolved: https://github.com/facebook/folly/pull/953
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10469757
      
      Pulled By: Orvid
      
      fbshipit-source-id: c63838f3f6e723ef3de77187f39597a4063043db
      c831d06b
    • Gisle Dankel's avatar
      Fix memory usage issue · 4cabbe62
      Gisle Dankel authored
      Summary:
      I noticed during testing that jemalloc requests a lot more memory than is
      allocated by the application.
      This is particularly the case for allocations >4k. If the allocation is <2MB it
      asks for an extra 2MB region that is not used for allocated memory, and if the
      request is >2MB then an extra region of the same size is requested in the
      extent hook.
      Turns out the issue was that I didn't set *commit to true in the alloc hook,
      causing an interesting sequence of events to occur.
      Another issue is that when running out of space and falling back to the default
      hook, subsequent requests would increase in size forever. The solution here was
      to set the jemalloc retain grow limit.
      Finally, fixed a bug when reserving more than 4GB memory (size calculation was
      truncated to 32 bits).
      
      Reviewed By: interwq
      
      Differential Revision: D10316308
      
      fbshipit-source-id: af47438029e85c03bf51c8d132b88de551f493f1
      4cabbe62
    • Andrew Gallagher's avatar
      folly/memory/Malloc.h: include a few more JEMalloc macro definitions · 3c69262c
      Andrew Gallagher authored
      Summary:
      `folly/memory/Malloc.h` is generally used as a shim for the JEMalloc headers, providing
      weak declarations of JEMalloc functions so that they can be referenced in library code
      that may or may not be linked with JEMalloc at build/run time.
      
      This adds a few more macro definition stubs for when JEMalloc isn't available.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10395893
      
      fbshipit-source-id: 7b45714297acd85afd3b222687feeda491fcb46d
      3c69262c
    • Yedidya Feldblum's avatar
      Assignment for sorted-vector types from initializer-list · 03f51db9
      Yedidya Feldblum authored
      Summary: [Folly] Assignment operators for `sorted_vector_set` and `sorted_vector_map` from `std::initializer_list`.
      
      Reviewed By: nbronson
      
      Differential Revision: D10457311
      
      fbshipit-source-id: cd50963066ee89f2aa314b7cad089242fbc10d84
      03f51db9
    • Teng Qin's avatar
      Fix StaticTracepoint argument size type identification · dd8181f0
      Teng Qin authored
      Summary:
      We need to determine the size of the Tracepoint arguments in the Macro. The only exception that we can not simply take `sizeof` is arrays, where `sizeof` will return size of the array where we really want is size of a pointer. Before we specifically check this with `FOLLY_SDT_ISARRAY` which checks if `__builtin_classify_type` of the argument is 14. However in recent update of LLVM, some arrays will be reported with type 5 (pointer type). Originally we didn't add that because we thought if the type of the argument is already a pointer then just take a `sizeof` on it would still be correct. This Diff fixes the issue.
      
      LLVM change in question is https://reviews.llvm.org/rL333126
      
      Reviewed By: taewookoh
      
      Differential Revision: D10453657
      
      fbshipit-source-id: 154fdfc78fe6438cd66cf256203c8d174773c1a8
      dd8181f0
    • Yedidya Feldblum's avatar
      Tweak Futures Core ASCII art · 36bad07f
      Yedidya Feldblum authored
      Summary: (as title)
      
      Reviewed By: LeeHowes
      
      Differential Revision: D10453926
      
      fbshipit-source-id: f48d1fb672e3c65b7240c255c8ef7437a38a856c
      36bad07f
    • Yang Chi's avatar
      Support one more parameter in folly tracing macro · 7545a8f7
      Yang Chi authored
      Summary: support one more params into the folly tracing macro
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10451431
      
      fbshipit-source-id: 8ae7356b38b46c9c653a7d87c507048eba353414
      7545a8f7
  5. 18 Oct, 2018 12 commits
    • Darrin D'Mello's avatar
      Clean up AsyncSocketException interface to hide members that should be private · 2906dd94
      Darrin D'Mello authored
      Summary: Minor code cleanup.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10430502
      
      fbshipit-source-id: d4892baf695089458295550767b3eca1af20ca32
      2906dd94
    • Kirk Shoop's avatar
      change copyright headers and apply some clang format · 288e58f2
      Kirk Shoop authored
      Summary:
      changed the copyright headers to match folly
      ran clang format in places that it did not mess up too badly
      
      almost entirely whitespace changes
      
      Reviewed By: Orvid
      
      Differential Revision: D10450516
      
      fbshipit-source-id: dc00a3952ee63d9ceb218aacb8f5f55a7c171170
      288e58f2
    • Adam Simpkins's avatar
      fix the Windows build · a25bbf7c
      Adam Simpkins authored
      Summary:
      It looks like I also broke the Windows build of folly in D10435249, since
      FollyCompilerMSVC.cmake referenced the `folly_deps` target, which is now not
      defined yet when `FollyCompilerMSVC.cmake` is included.
      
      This changes the code so that `FollyCompilerMSVC.cmake` simply updates
      `${FOLLY_LINK_LIBRARIES}`, which is used in a `target_link_libraries()` call
      in `folly-deps.cmake`.  (I'm slightly surprised that CMake was happy before
      with multiple separate `target_link_libraries()` calls for the `folly_deps`
      target.)
      
      Reviewed By: Orvid
      
      Differential Revision: D10445483
      
      fbshipit-source-id: 5277785bec3fd8527d01a098e130c945077703ee
      a25bbf7c
    • Orvid King's avatar
      Split targets and move them into the right places · 18b002f6
      Orvid King authored
      Summary:
      They were bugging me so I brought out my tools and hit things with a stick until they were in the right place.
      I then proceeded to hit them with more sticks until autodeps worked, due to a few references to experimental headers which aren't in GCC 5.
      
      Reviewed By: kirkshoop
      
      Differential Revision: D10443067
      
      fbshipit-source-id: 81b4a895c5ca06d22c74ede6cd2a474457df22ab
      18b002f6
    • Lewis Baker's avatar
      Replace AwaitWraper with new co_viaIfAsync operator · dea4f330
      Lewis Baker authored
      Summary:
      Refactored the `AwaitWrapper` class to expose its functionality as a new `co_viaIfAsync()` operator that returns a `ViaIfAsyncAwaitable<Awaitable>` type.
      
      The `folly::coro::Task` promise_type now delegates wrapping the awaited operations to the new `co_viaIfAsync()` operator. This allows SemiAwaitable types to customise how they are awaited from within a folly::coro::Task coroutine by providing an overload for `co_viaIfAsync()` rather than intrusively modifying the `folly::coro::Task` implementation.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D9983074
      
      fbshipit-source-id: 87d80001879ac7aa3be473339ba259229dafc262
      dea4f330
    • Maged Michael's avatar
      Disable ParkinkLot.WaitableMutexTest under TSAN · cce0bb0a
      Maged Michael authored
      Summary: Disable ParkinkLot.WaitableMutexTest under TSAN for now. It currently fails under TSAN due to the possibility of a mutex being unlocked by a different thread.
      
      Reviewed By: djwatson
      
      Differential Revision: D10446986
      
      fbshipit-source-id: 21ec53e27fffd566956f4e8ef1d3084765138b75
      cce0bb0a
    • Nathan Bronson's avatar
      use sized deallocation for overaligned-memory helpers · 2bc39ca1
      Nathan Bronson authored
      Summary:
      This diff makes the overaligned memory helpers in folly/Memory.h
      use the sized operator delete when it is available.  These helpers
      perform memory allocation and deallocation for the F14 hash table.
      Sized deallocation is much more CPU efficient.
      
      This diff also refactors the logic of allocateOverAligned and
      deallocateOverAligned, removing duplication of the compile-time machinery
      and making the alloc/dealloc pairings more clear.
      
      Reviewed By: yfeldblum, marksantaniello
      
      Differential Revision: D10411913
      
      fbshipit-source-id: ddd306619c28c8317fdebce8b24b18695ff16f5d
      2bc39ca1
    • Francois Visconte's avatar
      Fix a few inconsistencies in folly benchmarks · dbcba7de
      Francois Visconte authored
      Summary:
      Avoid printing to standard output in benchmark which poison output when using
      `-json_output` flag.
      
      Make SynchronizedBenchmark run benchmark only (like any other benchmarks out
      there)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10405010
      
      fbshipit-source-id: b034123fcda9d8b8d6ba6967641305886cb12673
      dbcba7de
    • Adam Simpkins's avatar
      cmake: find threads before applying compiler settings · d949df1f
      Adam Simpkins authored
      Summary:
      In D10405960 I moved folly-deps.cmake to be processed after
      FollyCompilerMSVC.cmake.
      
      It turns out that this causes configuration to fail in confusing ways when
      compiling with clang.  CMake fails reporting that it cannot find pthread.h,
      but the real problem is just that clang does not like the `-std=gnu++14` flag
      that has been applied by FollyCompilerUnix.cmake.  CMake doesn't appear to
      have C++-only version of `CMAKE_REQUIRED_FLAGS`, so this `-std` flag was being
      used even when invoking clang in C-only mode.
      
      Moving the `find_package(Threads)` call avoids this issue.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10435249
      
      fbshipit-source-id: 214ec9bbef43679864f714dc39c1e4423081c09b
      d949df1f
    • Andrii Grynenko's avatar
      Implement tail call optimization · 7bcd14c5
      Andrii Grynenko authored
      Summary: This adds an optimization for cases where recursive .then() is used to implement a loop. Instead of creating a chain of Cores that fulfil each other, we steal a callback from previous core if possible.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10392101
      
      fbshipit-source-id: 008c644df7472f5e280b24a41c62ee7199954abc
      7bcd14c5
    • Kirk Shoop's avatar
      restructure pushmi for folly · 6fc4b643
      Kirk Shoop authored
      Summary:
      removed top level project matter
      removed old build structure
      removed single header
      removed nonious
      moved include files to root
      change include paths to work in folly
      add TARGETS files for tests and most examples
      commented out catch tests pending gtest migration
      added cpp libraries for core, executors and operators
      fixes for additional warnings that are enabled in folly
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10438543
      
      fbshipit-source-id: 73af41a2c70cba126e063c6a8cf4363dc7444fef
      6fc4b643
    • Yedidya Feldblum's avatar
      Cut DestructorGuard default ctor · e9ec6e17
      Yedidya Feldblum authored
      Summary:
      [Folly] Cut `DestructorGuard` default ctor. It does not actually need one, but its presence can hurt.
      
      ```lang=c++
      void callback() {
        // compiles, which can hurt:
        DestructorGuard(delayed);
      
        // intended:
        DestructorGuard guard(delayed);
      }
      ```
      
      Reviewed By: lbrandy
      
      Differential Revision: D10413329
      
      fbshipit-source-id: f84eb0de0290cb09f7ac358044c2ef2d71dd8cea
      e9ec6e17
  6. 17 Oct, 2018 11 commits
    • Eric Niebler's avatar
      exclude folly/experimental/pushmi from the OSS builds for now · 9d03fa29
      Eric Niebler authored
      Summary: folly/experimental/pushmi isn't ready to build in the OSS environment yet, so exclude it.
      
      Reviewed By: Orvid
      
      Differential Revision: D10428301
      
      fbshipit-source-id: d6f033894cc060b560697f6bfa1d1f78102568d3
      9d03fa29
    • Uddipta Maity's avatar
      Adding support for IOBuf coalesce with certain headroom and tailroom · b8860675
      Uddipta Maity authored
      Summary:
      We need this in wormhole, as the capacity of the IOBuf may be very large, but,
      the data length is much smaller. Current implementation of coalesce() allocates
      large amount of memory unnecessarily.
      Adding methods to be able to set headroom and tailroom during coalesce.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10386802
      
      fbshipit-source-id: a0d787f41ed195eef409b942aaad583fc22692a3
      b8860675
    • Teng Qin's avatar
      Ensure FOLLY_SDT's Semaphore is in an allocated section · afd02e08
      Teng Qin authored
      Summary:
      Currently `FOLLY_SDT`'s Semaphore is just an global variable at where it was defined. Since it's initialized to 0 it will be put into the `.bss` section. It works fine currently, especially for Executable binaries, because tools, in particular BCC, will be writing to the virtual address directly.
      
      However, recent patches to Linux Kernel supports handling Semaphore (reference counter) natively along with the uprobe event, and it requires the Semaphore address to be allocated in the binary file so Kernel can find correct VMA for the address, especially for Shared Object binaries.
      
      This Diff makes `FOLLY_SDT_DEFINE_SEMAPHORE` to put the Semaphore into a `PROGBITS` section `.probes` that is writeable and allocated. This is a practice compatible with SystemTap's USDT implementation, where the Semaphores also reside in the `.probes` section, as can be found in CPython, libc, MySQL, PostgresSQL, and many applications already.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10319732
      
      fbshipit-source-id: 67ac0e55cc10cf1425a754d88cae0165b89ee993
      afd02e08
    • Kirk Shoop's avatar
      update readme to reflect the refactoring (#55) · 1034be9b
      Kirk Shoop authored
      fbshipit-source-id: 40cb872c23288d4efc26e20df83dad975465a2c4
      1034be9b
    • Kirk Shoop's avatar
      add customizatinos for nullary function to be a receiver (#54) · 44febf20
      Kirk Shoop authored
      fbshipit-source-id: 113888cb7117615cb7c21ddaa6829805474fdd69
      44febf20
    • Kirk Shoop's avatar
      consolidate receivers (#53) · 8d2c3121
      Kirk Shoop authored
      fbshipit-source-id: cd20a757d9ff43d80b74c9b7eb63f485ff206f8b
      8d2c3121
    • Kirk Shoop's avatar
      refactoring time senders and executors (#51) · 9f236dcd
      Kirk Shoop authored
      fbshipit-source-id: 6df047bf7833fe622b6c9901912b8022e485a610
      9f236dcd
    • Kirk Shoop's avatar
      Update Readme.md · 5160a6b0
      Kirk Shoop authored
      fbshipit-source-id: ac613182e9960ebe3213041e8a0fcdbc7a33c0ef
      5160a6b0
    • Kirk Shoop's avatar
      adding executor() method (#50) · ebd46723
      Kirk Shoop authored
      fbshipit-source-id: 73368129775f17ebed8f74cb39688b2b6a9d73e4
      ebd46723
    • Kirk Shoop's avatar
      Update Readme.md · 82c0f564
      Kirk Shoop authored
      fbshipit-source-id: baeb1f8956092be8fc5f831171e15c383c74ae3b
      82c0f564
    • Kirk Shoop's avatar
      add flow many (#49) · 9f3e9a65
      Kirk Shoop authored
      fbshipit-source-id: 2d6d5588ef87baf85e41ea1ccdf874a8d4f6ee66
      9f3e9a65