1. 21 Apr, 2018 4 commits
  2. 20 Apr, 2018 4 commits
    • Matthew Tolton's avatar
      Add nesting to folly::RequestContext · df8e2f74
      Matthew Tolton authored
      Differential Revision: D7663240
      
      fbshipit-source-id: d7025eb220ff3f87b05988090297573377ca009a
      df8e2f74
    • Andrii Grynenko's avatar
      Implement eager subscription in subcribeVia · a1c15014
      Andrii Grynenko authored
      Summary: Life-time of executor passed to subscribeVia can be tied to the previous stream. We have to eagerly subscribe to it to process onError/onComplete events and make sure we stop using that executor for any subsequent calls.
      
      Reviewed By: phoad
      
      Differential Revision: D7651264
      
      fbshipit-source-id: c50090ff58a4835b439df2080e083a9302c40152
      a1c15014
    • Nathan Bronson's avatar
      fix MemoryIdler constant for 64-bit windows · 6f809dcd
      Nathan Bronson authored
      Summary:
      long is 32-bit on 64-bit windows, unlike Linux, so 64-bit
      integer constants should use the ULL suffix.
      
      Reviewed By: mjhostet
      
      Differential Revision: D7690572
      
      fbshipit-source-id: a4d57555add63a4a88aceda1b02531eb8c5e1f0f
      6f809dcd
    • Orvid King's avatar
      Fix build with vcpkg · 98a91856
      Orvid King authored
      Summary:
      When building with MSVC and vcpkg, dependencies come in both debug and release versions. Fix the searching logic to search for both names and handle them appropriately.
      
      Also silence a few warnings under MSVC 2015 Update 3.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7683367
      
      fbshipit-source-id: 662fcc7170b260f129610ed47b6afedbe20933b7
      98a91856
  3. 19 Apr, 2018 8 commits
    • Dave Watson's avatar
      BlockingQueue returns bool for add · 8202eccd
      Dave Watson authored
      Summary:
      Add a return value to BlockingQueue interface - add() returns true if
      we were able to successfully handoff this work item to an existing thread.
      
      Implementation is straightforward in LifoSem.
      
      Reviewed By: magedm
      
      Differential Revision: D7477279
      
      fbshipit-source-id: 56ea17672a97ad722fd190baf0433ac68c440750
      8202eccd
    • David Lai's avatar
      convert string compare to use equality operators · 42506a07
      David Lai authored
      Summary:
      The changes in this diff changes string comparisons using the compare method to
      using equality operators.
      
      Motivation:
      - readability, simplifies code
      - compare method is intended for sorting functions
      
      This is clang check used: [Link Here](https://clang.llvm.org/extra/clang-tidy/checks/readability-string-compare.html)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7675353
      
      fbshipit-source-id: dbe2ac120ac9513db489b4d18824f9d47e5b4eac
      42506a07
    • Dave Watson's avatar
      notification queue deque->intrusive linked list · 0676ae62
      Dave Watson authored
      Summary:
      This diff moves memory allocation & a bunch of std::moves and some shared_ptr
      stuff outside the spinlock, resulting in much improved concurrency.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7674026
      
      fbshipit-source-id: 37accb31e4dcd78330bcda587e16595512d4c5f8
      0676ae62
    • Nathan Bronson's avatar
      check for insane stack size in MemoryIdler · 026f58c8
      Nathan Bronson authored
      Summary:
      In code that accidentally sets an impossibly huge stack size
      (RLIMIT_SIZE=-1, for example), MemoryIdler can unmap pages beyond the
      stack that are still in use.  This diff causes that case to assert in
      debug builds and disable memory idling in production.
      
      Reviewed By: edwinsmith
      
      Differential Revision: D7688511
      
      fbshipit-source-id: 7ef4261aaa3273ac7edf9edf596c2ea504e35877
      026f58c8
    • Dave Watson's avatar
      Iterative prepare() locking · 30aacd4b
      Dave Watson authored
      Summary:
      prepare() blocks mostly just lock locks, but we don't know what order to lock - so similar
      to std::lock, just iterate using try_lock until success.
      
      Reviewed By: ot
      
      Differential Revision: D7676738
      
      fbshipit-source-id: 2e0d28e4829a3a21d361a5801383c1aad0d66757
      30aacd4b
    • Tushar Maheshwari's avatar
      Improve modern CMake usage · 6b3aaa2b
      Tushar Maheshwari authored
      Summary:
      Summary of the changes
       ---
      - Fix broken MSVC build:
        - Compiling `GenerateFingerprintTables.cpp` complained about missing header file `glog/logging.h`.
        - Targets `GenerateFingerprintTables` and `folly_fingerprint` don't specify `FOLLY_INCLUDE_DIRECTORIES` in its include directories.
      
      * Introduce a "shiny" target `folly_deps` for managing folly's dependencies and interface specification.
        * `folly_deps` is an [INTERFACE library target](https://cmake.org/cmake/help/v3.0/command/add_library.html).
        * It encapsulates the interface dependencies (compile definitions, include directories, link libraries, etc.) for other targets.
        * The usage of the new target is clean and simple:
          `target_link_libraries(<target_name> (PUBLIC|PRIVATE) folly_deps)`
          (except for OBJECT library targets, like `folly_base` - included in the change).
      
      Possible modifications
       ---
      The name `folly_deps` could be replaced with a better one.
      The target can be extended to include the PUBLIC compile options set on individual targets.
      Reviews and suggestions welcome.
      Closes https://github.com/facebook/folly/pull/818
      
      Reviewed By: simpkins
      
      Differential Revision: D7642870
      
      Pulled By: Orvid
      
      fbshipit-source-id: c1c5fdae67f5a677c82f05757217af6b6de9db02
      6b3aaa2b
    • Subodh Iyengar's avatar
      Make method virtual · 69957e94
      Subodh Iyengar authored
      Summary:
      Turns out we needed this method to be virtual to mock it out in tests because it makes
      a bunch of syscalls.
      
      Reviewed By: yangchi
      
      Differential Revision: D7665938
      
      fbshipit-source-id: 1ae5768ade2c927929f5cb1f9e1ad62dad1ba237
      69957e94
    • Giuseppe Ottaviano's avatar
      Remove unnecessary includes in Synchronized · 6c7eaddb
      Giuseppe Ottaviano authored
      Reviewed By: aary
      
      Differential Revision: D7680645
      
      fbshipit-source-id: 6a3742c215a6924ec5c1c5b8bc1d2bff315355e7
      6c7eaddb
  4. 18 Apr, 2018 5 commits
    • Aaryaman Sagar's avatar
      Add tryWLock, tryRLock, tryULock, tryWLock to folly::Synchronized · 35ab212c
      Aaryaman Sagar authored
      Summary:
      Add `try_lock` methods to `folly::Synchronized` and add the corresponding
      extensions to `LockTraits`.  These return `LockedPtr`s that are valid and
      convert to true when the lock operation was successful, null otherwise
      
      override-unit-failure
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D7651765
      
      fbshipit-source-id: eb85987a2e4476cd916747dfc2ae69d124690ee6
      35ab212c
    • Marc Celani's avatar
      DigestBuilder for buffering writes to TDigest · 9e63a755
      Marc Celani authored
      Summary: TDigest is designed to process a stream of data in batches. DigestBuilder is a fast, thread safe approach for buffering those writes and building a digest.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D7582745
      
      fbshipit-source-id: 528ad9b21685746887b3a602d433662221fb875a
      9e63a755
    • Dave Watson's avatar
      use refcount · 51946874
      Dave Watson authored
      Summary:
      Use new refcount hazptr feature.
      
      This prevents many roundtrips through release()->retire()->~Node()->release()->retire() etc, and instead can call delete immediately through most of the chain
      
      See D6142066
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6290004
      
      fbshipit-source-id: d8cfb2aa41260918a7f201765febc31d558742bb
      51946874
    • Dan Melnic's avatar
      Revert "Use unbounded queue in NotificationQueue" · 5a12d8f1
      Dan Melnic authored
      Summary: Revert "Use unbounded queue in NotificationQueue"
      
      Reviewed By: magedm
      
      Differential Revision: D7669679
      
      fbshipit-source-id: 269139fc8238896640fc60ed36c83e728ed489b4
      5a12d8f1
    • Marc Celani's avatar
      Add sum, mean, and count to TDigest · 21352de3
      Marc Celani authored
      Summary: This diff adds reads for sum, mean, and count on TDigest. The results are calculated at merge time, to make reads O(1).
      
      Reviewed By: anakryiko
      
      Differential Revision: D7639133
      
      fbshipit-source-id: bb8f203ec0ed3197f090d2ce9223a2e9d1bca752
      21352de3
  5. 17 Apr, 2018 9 commits
    • Subodh Iyengar's avatar
      Allow unsetting errmsgcallback · 87694f24
      Subodh Iyengar authored
      Summary:
      Unset the error message callbacks when err
      message so that we dont deliver errors when
      not needed
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7661052
      
      fbshipit-source-id: 5a2330b2cd11f844649d56343307e2c75b626bdc
      87694f24
    • Dave Watson's avatar
      Add missing std::move · 7c6f1f55
      Dave Watson authored
      Summary: blame D7477268.  Some callsites use UnboundedBlockingQueue with non-copyable CPUTasks, must also have std::move here.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7655710
      
      fbshipit-source-id: cf8dba1df0c1703ffea1c0c0445c7d14deaf1d61
      7c6f1f55
    • Nathan Bronson's avatar
      fix markdown in F14.md · 12b9f49e
      Nathan Bronson authored
      Summary: Add missing markdown notation
      
      Reviewed By: shixiao
      
      Differential Revision: D7655769
      
      fbshipit-source-id: a0db34846e48afd845b8878de84764d30330b096
      12b9f49e
    • Dave Watson's avatar
      Add try_take_for to BlockingQueue · 5a7b4437
      Dave Watson authored
      Summary:
      add try_take_for to BlockingQueue, utilizing new LifoSem::try_wait_for method.
      To be used to kill threads after an idle period in CPUThreadPoolExecutor.
      
      Reviewed By: magedm
      
      Differential Revision: D7477268
      
      fbshipit-source-id: 76ea7fa1fc3b4b5f7a7529ce1424a91eef2ac7b1
      5a7b4437
    • Dave Watson's avatar
      parking lot perf improvements · 59e6e586
      Dave Watson authored
      Summary:
      Linux's futex checks the waiter count atomically before grabbing the lock.  This results in much better perf if there are no waiters and you call futexWake().
      Add the same improvement to ParkingLot.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6639337
      
      fbshipit-source-id: 6e03eff07e4c9ce327bc66d0aabd8cec051a5b19
      59e6e586
    • Nikita Lutsenko's avatar
      folly | Fix folly::setThreadName, folly::getThreadName on iOS/watchOS/tvOS. · 8a6f12e1
      Nikita Lutsenko authored
      Summary:
      According to headers, `pthread_getname_np` and `pthread_setname_np` are available since iOS 3.2 and macOS 10.6.
      However, guarding just on min macOS version isn't going to work for iOS/watchOS/tvOS, because it's very rarely defined.
      So add another case for when `__IPHONE_OS_VERSION_MIN_REQUIRED` is defined and is above iOS 3.2, which will also make watchOS and tvOS work.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7648204
      
      fbshipit-source-id: 1e608cdad3f39242eff79fbb6da8e560eeee720a
      8a6f12e1
    • Jeffrey Shen's avatar
      Fix stack overflow in folly::window · 98174e06
      Jeffrey Shen authored
      Summary:
      If the default inline executor is used for folly::window, and all the futures generated by the callback are also inline, then all spawn function calls (and their associated Futures) are added to the call stack and can overflow. This fixes that issue by using QueuedImmediateExecutor, which will put the executor callback into a thread-local queue, allowing the current function to exit and destruct all objects in its stack frame. Then, only the first call to QueuedImmediateExecutor in a thread is responsible for running each subsequent callback and will do so sequentially.
      
      This will end up allocating dynamic queues that reach a max size of two. It is possible to avoid a dynamic queue by writing a new Executor that only stores a single function, if that is too much of a performance cost.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7597731
      
      fbshipit-source-id: cd8899e6c086ecff812050f7241e80f39c546706
      98174e06
    • Dan Melnic's avatar
      Avoid creating a loop in the ThreadEntryList in onThreadExit · 7c08a582
      Dan Melnic authored
      Summary: Avoid creating a loop in the ThreadEntryList in onThreadExit
      
      Reviewed By: djwatson
      
      Differential Revision: D7632840
      
      fbshipit-source-id: 409358aae16a8aed4ae654ebfeca994385b43a9e
      7c08a582
    • Giuseppe Ottaviano's avatar
      Implement partial loadUnaligned · 1c609e4e
      Giuseppe Ottaviano authored
      Summary:
      Neither GCC or Clang are able to optimize a `memcpy` where
      the length is known to be smaller than a word: a library call is
      generated. This is a simple implementation of a subword
      `loadUnaligned` to be used to read the tail of a buffer when reading
      one word at a time.
      
      Reviewed By: luciang
      
      Differential Revision: D7631978
      
      fbshipit-source-id: d5719580e6bef82aa8e3fbdce8f873b569527a3a
      1c609e4e
  6. 16 Apr, 2018 9 commits
    • Adam Simpkins's avatar
      remove utils.push_dir · 1bd232cd
      Adam Simpkins authored
      Summary: This function is no longer used anywhere.
      
      Reviewed By: Orvid
      
      Differential Revision: D7597741
      
      fbshipit-source-id: 296acfceb59293bbafc6f6bf9c67d951cf41f7be
      1bd232cd
    • Adam Simpkins's avatar
      minor tweaks to utils.py · d5de689d
      Adam Simpkins authored
      Summary:
      Update `make_temp_dir()` to use `shutil.rmtree()` to clean up rather than just
      `os.rmdir()`.  If the function using this context manager throws it may leave
      behind files inside the temporary directory, and it is useful to always clean
      those up.
      
      Also update `read_fbcode_builder_config()` to work regardless of the current
      working directory.  Previously this function only worked if the current working
      directory was the directory containing the configuration file.  This makes sure
      that `read_fbcode_builder_config()` calls are always treated as relative to the
      directory containing the configuration file being read.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7597743
      
      fbshipit-source-id: 817063104081336fcc0a9f825beb74d7d4377499
      d5de689d
    • Marc Celani's avatar
      Create a new SlidingWindow data structure · 59791afd
      Marc Celani authored
      Summary: Creates a new SlidingWindow data structure for general purpose use in stats code.
      
      Reviewed By: anakryiko
      
      Differential Revision: D7597047
      
      fbshipit-source-id: 227438055029c2bacb5edf2943ebc9cc66fdfe36
      59791afd
    • Dan Melnic's avatar
      Use unbounded queue in NotificationQueue · d25334fb
      Dan Melnic authored
      Summary: Use unbounded queue in NotificationQueue (prev changes: D7164130, D7251343, D7278275, D7359322, D7471153, D7606076)
      
      Reviewed By: djwatson
      
      Differential Revision: D7408628
      
      fbshipit-source-id: 04ae235d9b3de603e28115e11fe98fe7e9aa1f8c
      d25334fb
    • Stephan's avatar
      Fix for #819 (lang/Ordering.h is not installed via "make install") · e752dcd0
      Stephan authored
      Summary:
      fixes #819.
      Closes https://github.com/facebook/folly/pull/820
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7642932
      
      Pulled By: Orvid
      
      fbshipit-source-id: c49168ddf111c851d0218b74fbbdf405e9a68fc3
      e752dcd0
    • Kevin Doherty's avatar
      add eraseInto api to F14Set · 7153cc6b
      Kevin Doherty authored
      Summary:
      - Expose an API to erase an item from `F14Set` and do something with it before it is destroyed
      - This includes (but is not limited to) being able to `std::move` it to another container while avoiding a copy
      - Change erase implementations to forward to `eraseInto(...args, emptyCallback)`
      
      Reviewed By: shixiao
      
      Differential Revision: D7588928
      
      fbshipit-source-id: 5e9c2bda216c5c219c333282daadd2170e6a1eba
      7153cc6b
    • Subodh Iyengar's avatar
      Add errmsg callback to udp · 2584b1f2
      Subodh Iyengar authored
      Summary:
      Adds the ability for UDP sockets to optionally
      listen to errors that happen on the socket,
      for example ICMP errors.
      
      In this iteration, we explicitly do not register for
      read events if an error callback is set. So even
      if you set an error callback to get error events
      you must register a read callback.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7632877
      
      fbshipit-source-id: 43c922d0145e1da97b993f5bf4058c20d3469deb
      2584b1f2
    • Subodh Iyengar's avatar
      Clang format AsyncUDPSocket · 6ee198b0
      Subodh Iyengar authored
      Summary:
      Clang format files related to AsyncUDPSocket.
      This helps keep changes consistent.
      
      Reviewed By: yfeldblum, lnicco
      
      Differential Revision: D7632865
      
      fbshipit-source-id: 0761f0cfd06417334e680ca0880280d65480fe7e
      6ee198b0
    • Yedidya Feldblum's avatar
      Tweak SharedPromise and FutureSplitter docs · ba208d71
      Yedidya Feldblum authored
      Summary: [Folly] Tweak `SharedPromise` and `FutureSplitter` docs, in particular to reflection recent changes to execution semantics.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D7630725
      
      fbshipit-source-id: 68da70cd86d131aa09c1909d90a793868039e84f
      ba208d71
  7. 14 Apr, 2018 1 commit
    • Yedidya Feldblum's avatar
      All comparison predicates for IOBuf · f35c91c0
      Yedidya Feldblum authored
      Summary: [Folly] All comparison predicates for `IOBuf`, not just `EqualTo`.
      
      Reviewed By: djwatson, stevegury
      
      Differential Revision: D7596700
      
      fbshipit-source-id: 2d5cef2797dc75d4fb76c2d13e4a938f738da163
      f35c91c0