1. 11 Dec, 2018 6 commits
    • Andrii Grynenko's avatar
      addTaskEager/addTaskEagerFuture · a3085174
      Andrii Grynenko authored
      Summary: This allows avoiding extra executor/queueing operations if caller knows that task can be safely run inline.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13404703
      
      fbshipit-source-id: 4aa71e59b48572671e8031ee7ea4dcd4e3a6138b
      a3085174
    • Songqiao Su's avatar
      (folly/benchmark)(RFC) allow users to record customized counters during benckmark · 59b94083
      Songqiao Su authored
      Summary:
      There could be cases that user want to record some of their own metrics during benchmark. This diff add another kinds of macro BENCHMARK_COUNTERS to make it happen, see Test plan for an example.
      
      One problem is that it would be hard to output the result on the fly. As it needs to run all benchmarks first to know which customized counter are used, then it can output the proper column headers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D9874668
      
      fbshipit-source-id: 2004bb4484e54c1edd65763d1727486c6905d884
      59b94083
    • Andre Pinto's avatar
      Add getTotalBufferedBytes() method fo AsyncTransport · 399c4fa5
      Andre Pinto authored
      Summary:
      When BufferCallback::onEgressBuffered() is called, applications usually want to
      know how many bytes were buffered so that can take actions (such as avoiding
      that connection, failing fast, etc).
      This diff adds getTotalPendingBytes() to AsyncTransport to allow applications
      to easily query how many bytes were actually buffered.
      
      Reviewed By: spalamarchuk
      
      Differential Revision: D13252677
      
      fbshipit-source-id: 8ec203f6764e00f52d471321afb549376397eb84
      399c4fa5
    • Dylan Yudaken's avatar
      Fix potential buffer overflow in use of strncat · 2e5a8ccb
      Dylan Yudaken authored
      Summary: There is a bug in ElfFile using strncat which could cause buffer overflows when a previous file open failed. strncat only limits based on the src length, and so if strlen(dest) > 0 this could have overflowed.
      
      Reviewed By: anakryiko
      
      Differential Revision: D13398108
      
      fbshipit-source-id: 793c35884f1e639f36758f36046158858fd5976a
      2e5a8ccb
    • Nitin Garg's avatar
      Add APIs in DynamicTokenBucket to be able to return excess tokens and to borrow from future. · e919bad4
      Nitin Garg authored
      Summary:
      The common use case for token buckets to implement resource usage throttling/smoothing also implies that callers need to either implement their own backoff+retry mechanism. The simple exponential backoff approach is prone to starvation and over-throttling (under-utilized resource). Many cases will simply be okay with being told at what point in future their allocations can be met effectively doing the starvation free FIFO scheduling for them. Added a consumeWithBorrow API to enable this behavior.
      
      Added checks in existing API to account for the possibility of the internal clock of the bucket being 'in future' wrt to the 'now' argument passed in the call.
      
      Also added an API to be able to return previously allocated tokens effectively moving the clock back on the bucket. This is largely for completeness and there isn't an immediate use case in mind for this.
      
      Reviewed By: yfeldblum, usumeet
      
      Differential Revision: D13166472
      
      fbshipit-source-id: 4d6f93eedcc75eb07c1250026e57806c96974c96
      e919bad4
    • Yedidya Feldblum's avatar
      Prefer lift_unit_t in lift_unit call-sites · 97d612a3
      Yedidya Feldblum authored
      Summary:
      [Folly] Prefer `lift_unit_t<T>` in `lift_unit` call-sites over `typename lift_unit<T>::type`.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D13410680
      
      fbshipit-source-id: e51f16d31fc30bd2858f89a2b90271525f17706e
      97d612a3
  2. 10 Dec, 2018 6 commits
    • Doron Roberts-Kedes's avatar
      folly DeterministicSchedule: joinAll() as a workaround to thread local destructor issues · 2df6e3b0
      Doron Roberts-Kedes authored
      Summary:
      There was a problem with DeterministicSchedule when threads issued shared access stores/loads to atomics during thread local destructors. Thread local destructors run after a thread terminates, and therefore after all of the DSched cleanup work in beforeThreadExit() is already complete.
      
      The new DSched::joinAll() functions works around this problem by blocking the parent until all child threads are blocked at the end of beforeThreadExit(). The parent then lets each child thread proceed one at a time through the thread local destructor with a paired sem_post and .join().
      
      Reviewed By: djwatson
      
      Differential Revision: D13381250
      
      fbshipit-source-id: 80ab39b3f2f71ee69dfbaec9950dfc5908874353
      2df6e3b0
    • Doron Roberts-Kedes's avatar
      folly DeterministicSchedule: Add a new typedef BufferedDeterministicAtomic · 711c7a48
      Doron Roberts-Kedes authored
      Summary:
      There are too many corner cases at the moment to redefine
      DeterministicAtomic as using BufferedAtomic, so add a 2nd one to allow test to
      transition over to BufferedAtomic on a case by case basis.
      
      Reviewed By: djwatson
      
      Differential Revision: D13379877
      
      fbshipit-source-id: 76efdd4faedd6c5af13ab8507f41fb63b3e1c7f3
      711c7a48
    • Andrii Grynenko's avatar
      Avoid external thread event starvation · 5e56650c
      Andrii Grynenko authored
      Summary: Pick some events from the NotificationQueue on every EventBase loop iteration if NotificationQueue is registered as an internal event and there are no other active events.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13393839
      
      fbshipit-source-id: 9d281ac721db268f321860b1bf55d2afd79f9679
      5e56650c
    • Lee Howes's avatar
      Remove value-taking form of Future::then · 16f20f29
      Lee Howes authored
      Summary:
      Explicitly delete the value taking form of folly::Future::then.
      
      Redo of D13115198
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13396333
      
      fbshipit-source-id: 36df474cab95577b68584099109d94069903090e
      16f20f29
    • Yuntong Wang's avatar
      Revert D13115198: [folly] Remove value-taking form of Future::then · c5fe286b
      Yuntong Wang authored
      Differential Revision:
      D13115198
      
      Original commit changeset: a33246d23ccd
      
      fbshipit-source-id: 3bbd102ce166f5404f7181a1ca1c88c66d6b8ea6
      c5fe286b
    • Lee Howes's avatar
      Remove value-taking form of Future::then · 766f412a
      Lee Howes authored
      Summary: Explicitly delete the value taking form of folly::Future::then.
      
      Reviewed By: Orvid
      
      Differential Revision: D13115198
      
      fbshipit-source-id: a33246d23ccde8a14d4d70de4f6e0373c006de11
      766f412a
  3. 08 Dec, 2018 2 commits
    • Krishna Kondaka's avatar
      Fix folly::json perf issue · 6d2c9612
      Krishna Kondaka authored
      Summary: Original change to folly::json as part of D13038266/ was reverted due to performance regression in Android. This is modified version to keep track of lineNum while skipping white spaces.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13293197
      
      fbshipit-source-id: 96d07946ae7430a182ff98f6dfd6d32e3a923991
      6d2c9612
    • Dan Melnic's avatar
      Add support for EventBase::runInEventBaseThreadAlwaysEnqueue · 99cba475
      Dan Melnic authored
      Summary: Add support for EventBase::runInEventBaseThreadAlwaysEnqueue
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13366773
      
      fbshipit-source-id: 72eacdbe699509d771fcefe31ee4d742eaadd4d1
      99cba475
  4. 07 Dec, 2018 7 commits
    • Petr Lapukhov's avatar
      JSON patch application method · e572a62c
      Petr Lapukhov authored
      Summary:
      Mutate supplied object in place in accordance with patch instructions. If patch fails, object may be left in partially modified state.
      
      Notice that patch application is placed in json_patch as we rely on dynamic object to store the patch itself.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10427475
      
      fbshipit-source-id: 9ebc927c31fdf7434e69cb5c8df01c6979cab6e0
      e572a62c
    • Petr Lapukhov's avatar
      Introduce try_get_ptr() method to query elements by JSON pointer · 5824119b
      Petr Lapukhov authored
      Summary: Previously `get_ptr(json_pointer const&)` would return nullptr or throw. The new try_get_ptr version provides richer facilities: points which token caused resolution error, if any, and also provides pointer to last-known properly resolved element. This allows, for example, implementing append logic with pointers like "/foo/bar/-" if "bar" is an array. The error would return `dynamic*` for the array, allowing caller to immediately perform push operation. Consequently, the get_ptr() is now implemented in terms of `try_get_ptr`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10098092
      
      fbshipit-source-id: 620996a66823be661d64d39661837cedf3c24493
      5824119b
    • Petr Lapukhov's avatar
      add insert() method for dynamic::array · 1dcceaf5
      Petr Lapukhov authored
      Summary: We have insert() API for underlying object, but not the array. With array, insert() has same semantic as in std::vector, shifting elements to the right. To insert at arbitrary offset use something like `arr.insert(arr.begin() + 10, elem)`; This calls one of specializations of std::vector's insert() underneath.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10372068
      
      fbshipit-source-id: 54bb7ea80b36bf1b893d88b82a11afa08ad0c0e2
      1dcceaf5
    • Yedidya Feldblum's avatar
      Fix some violations of -Werror=class-memaccess under gcc8 · e840c2d4
      Yedidya Feldblum authored
      Summary: Pull Request resolved: https://github.com/facebook/folly/pull/981
      
      Reviewed By: Orvid
      
      Differential Revision: D13374621
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 00665529250cd03d9ca02f72f36efe505c280aa3
      e840c2d4
    • Alexander Zhavnerchik's avatar
      Add .value() method to folly settings objects · 1d2247b4
      Alexander Zhavnerchik authored
      Summary:
      This serves two purposes:
      * unify API to be similar to folly::Optional
      * allow to pass snapshot into the getter, so snapshoted value can be fetched
        for that setting.
      
      Reviewed By: alikhtarov
      
      Differential Revision: D13116589
      
      fbshipit-source-id: e46ac1a733d0d947f2a63f25e90deba31c03223b
      1d2247b4
    • Yedidya Feldblum's avatar
      Fix some violations of -Werror=shadow=compatible-local under gcc8 · 9f80fe26
      Yedidya Feldblum authored
      Summary: Pull Request resolved: https://github.com/facebook/folly/pull/979
      
      Reviewed By: Orvid
      
      Differential Revision: D13368681
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 56c18633ddd029ee499940ce5c8b8ad2cbef4ea7
      9f80fe26
    • Leo Andrade's avatar
      Fixing minor typo in comment for initlist_construct_t · b4372011
      Leo Andrade authored
      Summary: Fixing minor typo in comment for initlist_construct_t.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13356226
      
      fbshipit-source-id: b888c736877c57fa196bf98af87ec0473f6895f5
      b4372011
  5. 06 Dec, 2018 4 commits
  6. 05 Dec, 2018 4 commits
    • Yedidya Feldblum's avatar
      Allow StringPiece construction from string with custom allocator · f53901c9
      Yedidya Feldblum authored
      Summary: [Folly] Allow `StringPiece` construction from `string` with custom allocator.
      
      Reviewed By: nbronson
      
      Differential Revision: D9494207
      
      fbshipit-source-id: 22b6beb7e5718f69aa283431ad49dd36295e0825
      f53901c9
    • Yedidya Feldblum's avatar
      Let SingletonHolder impl be class member type · f2654daf
      Yedidya Feldblum authored
      Summary:
      [Folly] Let `SingletonHolder` impl be class member type v.s. function local type, which for arbitrary magical reasons improves rtti/debuginfo letting the debugger see the type exactly.
      
      Could also be done by extracting `SingletonHolderImpl` as a top-level type, but that would require an additional `friend` declaration and class member type works.
      
      Reviewed By: pixelb
      
      Differential Revision: D13333184
      
      fbshipit-source-id: 7de4f8c16706acb18c6869b5dcd0b9c6952efc46
      f2654daf
    • Yedidya Feldblum's avatar
      Fix ordering between FOLLY_HAS_EXCEPTIONS and kHasExceptions · 8d228ac4
      Yedidya Feldblum authored
      Summary: [Folly] Fix ordering between `FOLLY_HAS_EXCEPTIONS` and `kHasExceptions` definitions.
      
      Reviewed By: swolchok
      
      Differential Revision: D13338301
      
      fbshipit-source-id: 855dbf7ba42eb118f84ffb84d2520c7dfc49cf39
      8d228ac4
    • Phil Willoughby's avatar
      googletest's PrintTo for folly strings · d42a8052
      Phil Willoughby authored
      Summary:
      Prints StringPiece/FixedString/fbstring like a string and not like a vector of char when implicitly printed by googletest/googlemock.
      
      The order of printing precedence within googletest is:
      * ADL `PrintTo(T const&, ostream*)`
      * Gtest's container-printer for anything that looks like a container
      * ADL `ostream& operator<<(ostream&, T const&)`
      
      Unfortunately you need to include the <folly/test/TestUtils.h> header in every test to have this functionality. The googletest mechanism for overloading this means we can't do it in the main headers without introducing a dependency from them to googletest.
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D13306040
      
      fbshipit-source-id: 4e8252d377835dad04625d84a0cae7c0713ce8af
      d42a8052
  7. 04 Dec, 2018 5 commits
    • Dan Melnic's avatar
      Fix broken opt build due to unused var warning · 62080229
      Dan Melnic authored
      Summary: Fix broken opt build due to unused var warning
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13317777
      
      fbshipit-source-id: 9e4928558e0514bdb5ab21e78b026c5c1a44a380
      62080229
    • Nathan Bronson's avatar
      refactor F14Fast so it doesn't expose F14Vector-only features · a2abde96
      Nathan Bronson authored
      Summary:
      F14FastMap heuristically selects either F14ValueMap or
      F14VectorMap at compile time (same for F14FastSet).  F14VectorMap has
      stronger iteration guarantees than the other unordered associative
      containers, including providing a reverse iterator.  This diff refactors
      F14FastMap so that even when it uses the same policy as F14VectorMap it
      doesn't expose these additional guarantees.
      
      This is a precursor to extending FOLLY_F14_PERTURB_INSERTION_ORDER to
      all F14FastMap and F14FastSet.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13303823
      
      fbshipit-source-id: 5feea3d1f8cb809ceb2c4f79a7cc1bc7e447768f
      a2abde96
    • Andrii Grynenko's avatar
      Drop updates if value didn't change · 1cdb0342
      Andrii Grynenko authored
      Summary: If observer generator function returned the same shared_ptr it's safe to not propagate such an update.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13249675
      
      fbshipit-source-id: 334c33e791b664eaec3c2698009f138bef04f8a6
      1cdb0342
    • Greg McGary's avatar
      Support disabling x86 static tracepoints · 7625683a
      Greg McGary authored
      Summary: Support disabling x86 static tracepoints.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13293303
      
      fbshipit-source-id: e8578ee1d855aaf33eeacbc1e804608ab65449d5
      7625683a
    • Rachana Nandan's avatar
      add support to setReuseAddr in AsyncUDPServerSocket · e39e166b
      Rachana Nandan authored
      Summary: add an api in AsyncUDPServerSocket, to enable Address reuse
      
      Reviewed By: udippant
      
      Differential Revision: D13306371
      
      fbshipit-source-id: ac19a89af5694b181fcd7639a5d566684c2adc92
      e39e166b
  8. 03 Dec, 2018 5 commits
  9. 01 Dec, 2018 1 commit
    • Nathan Bronson's avatar
      temporarily disable FOLLY_F14_PERTURB_INSERTION_ORDER · 60895e07
      Nathan Bronson authored
      Summary: This diff defaults FOLLY_F14_PERTURB_INSERTION_ORDER to off even for debug builds. It will be reenabled soon.
      
      Reviewed By: markw65
      
      Differential Revision: D13289756
      
      fbshipit-source-id: 931f373e5633fa641360da7af51b5d6e64a5b39b
      60895e07