1. 11 May, 2018 2 commits
    • Petr Lapukhov's avatar
      Properly disable TTLS with TFO · 0fc4facd
      Petr Lapukhov authored
      Summary: socketConnect() is not invoked if we have TFO enabled. Need to explicitly disable it once new socket is created, and noTransparentTls flag is set.
      
      Reviewed By: djwatson
      
      Differential Revision: D7945457
      
      fbshipit-source-id: 739b7ae5bc146b50255254e644fba2618147c4f4
      0fc4facd
    • Marshall Cline's avatar
      tighten control on Core creation/deletion · 46905dd2
      Marshall Cline authored
      Summary:
      Enforce two aspects of folly::futures::Core<T>:
      
      - that it is heap-constructed (prevent clients from constructing it other than via `new`)
      - that it cannot be deleted early (prevent clients from explicitly deleting it)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7900761
      
      fbshipit-source-id: c1c5a149e3d96c4cea04c17909c2ffd42383973e
      46905dd2
  2. 10 May, 2018 7 commits
    • Orvid King's avatar
      Make an implicit conversion from int to unsigned int in hazptr explicit · 903be023
      Orvid King authored
      Summary: It was spamming the MSVC build log with warnings.
      
      Reviewed By: magedm
      
      Differential Revision: D7954677
      
      fbshipit-source-id: 1f2d1163483518382543aacb7e8fbc17e291e650
      903be023
    • Andrew Krieger's avatar
      clang-on-windows compatibility nits · d460a7dc
      Andrew Krieger authored
      Summary:
      clang whines about these to varying degrees. They seem like
      braindead fixes.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7918701
      
      fbshipit-source-id: a5aae179c2df89ef52148a500e95cd1cd25a1f0b
      d460a7dc
    • Dave Watson's avatar
      Fix dynamic thread destruction race · baef20f9
      Dave Watson authored
      Summary:
      There is a subtle race between thread destruction and task addition (ensureActiveThreads).
      
      For an executor with a single thread, the race would be:
      threadid
      1 cpu thread returns from try_take_for by timing out.
      2 someone from a different thread calls add()
      2 add() finds lifosem empty, calls ensureActiveThreads
      2 ensureActiveThreads grabs the lock, finds active=1, total=1, returns doing nothing, assuming thread is still running.
      1 cpu thread decrements activeThreads_ to 0 in taskShouldStop.
      
      There are now *no* threads running until the next call to add(), and one task waiting.
      
      Fix: Grab lock in taskShouldStop (like the documentation says we should be doing).  Also double check that there are no currently pending tasks.
      
      This probably only affects pools with size of 1, otherwise we would have added a second thread and there may temporarily be one fewer threads running.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D7943241
      
      fbshipit-source-id: 502e5809ccf4ecca85205c14c4d97b508897de9b
      baef20f9
    • Sven Over's avatar
      remove unnecessary memory allocation in SerialExecutor · f6db2cea
      Sven Over authored
      Summary:
      SerialExecutor used to have public constructors and could be
      constructed on the heap or on the stack. In order to be able
      to reference the shared stater later from the parent executor,
      the task queue was implemented in a separate class, of which
      the SerialExecutor would create one, managed by a `shared_ptr`.
      
      With the recent move towards `folly::Executor::KeepAlive`, the
      SerialExecutor itself always has to be constructed on the heap
      (hence no public constructor anymore but factory functions).
      However, that means that we can embed the task queue implementation
      in SerialExecutor, using `KeepAlive` objects to access it from
      the parent executor.
      
      This change simplifies the implementation of SerialExecutor and
      reduces the number of heap objects and thus memory allocations.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7927260
      
      fbshipit-source-id: d3b6a2376bfdf512a946f2f45c730ed68176a441
      f6db2cea
    • Marc Celani's avatar
      Get rid of unnecessary base class · f185ea84
      Marc Celani authored
      Summary: This turned out to only be useful in tests. Clean up the tests and get rid of it
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7907221
      
      fbshipit-source-id: f5e0263c1426e1af97c190e6b2bd47d7db37d403
      f185ea84
    • Lee Howes's avatar
      deferError was not r-value qualified but should have been. · 346d9d76
      Lee Howes authored
      Summary: When cleaning up the interface with r-value qualification for SemiFuture it seems we missed deferError.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7942259
      
      fbshipit-source-id: c0cf05eb2b6357e6f6eb3fab6aef87ec6416caf7
      346d9d76
    • John Strizich's avatar
      add spec for re2 · a56c4e05
      John Strizich authored
      Reviewed By: saifhhasan
      
      Differential Revision: D7943135
      
      fbshipit-source-id: 6b66b7b2ea6343b99ec113febca991eb840b1860
      a56c4e05
  3. 09 May, 2018 5 commits
    • Adam Simpkins's avatar
      logging: fix build failures in the tests · 11492cae
      Adam Simpkins authored
      Summary: gcc-5.x does not allow brace elision in these std::array initializer lists.
      
      Reviewed By: yfeldblum, mnv104
      
      Differential Revision: D7923970
      
      fbshipit-source-id: 807f2e0d376c9ac4f4f6988fb811590531b6334d
      11492cae
    • Murali Vilayannur's avatar
      Fix for failing travis CI tests · e1fc1acd
      Murali Vilayannur authored
      Summary:
      Running the xlog test binary stand-alone revealed a bug that
      was otherwise masked when running with buck test. The bug was that
      2 tests ended up depending on the log-level associated with a default
      category and would thus fail since the tests did not clean up
      the log-level setting associated with those categories.
      Attached diff fixes the issue by restoring the category's log-level in
      a scope exit block.
      
      Reviewed By: simpkins
      
      Differential Revision: D7922086
      
      fbshipit-source-id: 9d8ed917633ae214dc81075fbd38275160e64376
      e1fc1acd
    • Yedidya Feldblum's avatar
      Simpler SFINAE in variadic F14BasicSet::emplaceItem · 5817bad2
      Yedidya Feldblum authored
      Summary: [Folly] Simpler SFINAE in variadic `F14BasicSet::emplaceItem`, without using `std::tuple_element_t` unsafely when `sizeof...(Args) == 0`.
      
      Reviewed By: shixiao
      
      Differential Revision: D7920929
      
      fbshipit-source-id: d74d5b36ac683f72e21d83294aa890f49194280d
      5817bad2
    • Adam Simpkins's avatar
      only use -Wno-inconsistent-missing-override if supported · 96d583b9
      Adam Simpkins authored
      Summary:
      Check if the compiler supports -Winconsistent-missing-override before trying to
      disable this warning.
      
      It looks like gcc wouldn't actually fail the build if
      `-Wno-inconsistent-missing-override` was specified but was not supported.
      However, if the build failed due to other compile errors the error messages
      about this flag would make it confusing to identify the actual build failure
      reason.
      
      Closes issue #836.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7920577
      
      fbshipit-source-id: 322444a9df3f4f36bb5420f0720c1e433c2856b7
      96d583b9
    • Yedidya Feldblum's avatar
      Fix ThreadPoolExecutor::getPendingTaskCount decl · bf237b57
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `ThreadPoolExecutor::getPendingTaskCount` decl return type to match defn.
      
      Fixes #843.
      
      Reviewed By: djwatson
      
      Differential Revision: D7914071
      
      fbshipit-source-id: a22658b1dd48a5e73fae3a0312f72007230e36c8
      bf237b57
  4. 08 May, 2018 5 commits
    • Dave Watson's avatar
      Change to folly::SharedMutex · 20665b48
      Dave Watson authored
      Summary:
      One (artificial) test case creates ~1000 threads, resulting in lots of spinning contending for this lock.
      
      Changing to folly::SharedMutex fixes the issue, allowing the actual working thread to finish.
      
      Reviewed By: magedm
      
      Differential Revision: D7847705
      
      fbshipit-source-id: b2a8c3acdb4c62f347ef4ec761acbe7681ced9f3
      20665b48
    • Murali Vilayannur's avatar
      Add a LOG_IF equivalent to folly's logging library · a478d52f
      Murali Vilayannur authored
      Summary: Allows for conditional logging of messages.
      
      Reviewed By: simpkins
      
      Differential Revision: D7888834
      
      fbshipit-source-id: d1fe47d82fe8889f6b597062f5542e7eb61ed9e6
      a478d52f
    • Marc Celani's avatar
      Be able to take now as input · df00b343
      Marc Celani authored
      Summary: Take now as input to improve performance when updating many buffered stats at once
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7906107
      
      fbshipit-source-id: cf09bc2c2673b0a336628b3e6b31ee2d55dbb10c
      df00b343
    • Yedidya Feldblum's avatar
      Fix race condition in collectN · daf3e6fc
      Yedidya Feldblum authored
      Summary: [Folly] Fix race condition in collectN where the future may be completed with too few values or by reading the values while they are in-process of being written.
      
      Reviewed By: djwatson
      
      Differential Revision: D7900639
      
      fbshipit-source-id: 3eafa821abda4f93232db3b8114de54c6faf798a
      daf3e6fc
    • Emy Sun's avatar
      Revert D7840699: [folly::futures] Future::get() - make postcond testable by callers · ddea466e
      Emy Sun authored
      Summary:
      This reverts commit 5102e9c3de026c021bf322b5109aafcc115207a2
      
      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:
      D7840699
      
      Original commit changeset: 5102e9c3de02
      
      fbshipit-source-id: 13e97d5497ac383c0eff18a4b947d5b3d82a19b7
      ddea466e
  5. 07 May, 2018 5 commits
    • Yedidya Feldblum's avatar
      Fix outdated mention of TSSLSocketFactory · 2c2452d0
      Yedidya Feldblum authored
      Summary: [Folly] Fix outdated mention of `TSSLSocketFactory`.
      
      Reviewed By: stevegury, knekritz
      
      Differential Revision: D7892382
      
      fbshipit-source-id: 7b267e5de857f9c5976b26d53d36b1545a46af2a
      2c2452d0
    • Yedidya Feldblum's avatar
      Use size_t for ThreadPoolExecutor::getPendingTaskCountImpl · a463b55e
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `size_t` for `ThreadPoolExecutor::getPendingTaskCountImpl`, as it is the canonical size type for counting the number of entries in in-memory data structures.
      
      Prevents confusion when using values returned from this function with other sizes, especially in contexts where the two types are required to match as might occur in calls to `std::min` without explicitly specifying the type.
      
      Fixes #843.
      
      Reviewed By: djwatson
      
      Differential Revision: D7898443
      
      fbshipit-source-id: eec789f661351d09545bc7118f2e4b3587fd7302
      a463b55e
    • Dan Melnic's avatar
      Add thread local destroy benchmark · 82a8271d
      Dan Melnic authored
      Summary: Add thread local destroy benchmark
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7892479
      
      fbshipit-source-id: f16462820354a6cf27d9348a76b28be027cef20c
      82a8271d
    • Marshall Cline's avatar
      Future::get() - make postcond testable by callers · 7c9d20fd
      Marshall Cline authored
      Summary:
      SemiFuture::get() & Future::get() both render the `this` object in a consumed / moved-out state. However Future::get()'s postcondition was untestable by callers - it consumed the value within the core but left `this->valid()` true.
      
      Goal: make Future::get():
      - function like SemiFuture::get()
      - testable by callers (see `valid()`)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7840699
      
      fbshipit-source-id: 5102e9c3de026c021bf322b5109aafcc115207a2
      7c9d20fd
    • Marshall Cline's avatar
      add valid() to Future, SemiFuture, Promise · afb57872
      Marshall Cline authored
      Summary:
      Lets callers determine whether a Future/SemiFuture/Promise has a shared-state.
      `x.valid()` (where `x` is a Future, SemiFuture, or Promise) is is true if/only if the object has a shared state.
      
      The `valid()` method will also be key in a near-term diff that will use it to clarify the contracts/rules.
      
      Note: the concept of validity already shows up in the doc-blocks; this gives callers a conceptual oppty to check it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7839038
      
      fbshipit-source-id: f8390b3d1a8c3d5d89356ae48937e03c424d1174
      afb57872
  6. 06 May, 2018 1 commit
    • Léonard Gérard's avatar
      Remove implied POSITION_INDEPENDENT_CODE property · 7897c65f
      Léonard Gérard authored
      Summary:
      PIC is implied by BUILD_SHARED_LIBS in CMake, so the test is confusing.
      Note that if one wants to build static and use it to create a shared library with it, he will need to compile either shared
      or static with CMake option -DCMAKE_POSITION_INDEPENDENT_CODE
      Closes https://github.com/facebook/folly/pull/833
      
      Reviewed By: Orvid
      
      Differential Revision: D7890111
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: e3996cb83d30ae368dc5fdd4f55b721f7f89d0a0
      7897c65f
  7. 05 May, 2018 1 commit
    • Alex Yarmula's avatar
      add a repeat-n-times overload to folly::window · 54ee5225
      Alex Yarmula authored
      Summary:
      Add the ability to use folly::window without providing a vector ahead of time.
      This allows window to scale to a large number of iterations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7863481
      
      fbshipit-source-id: 86c6b7926e9c3b7510233fac20a50c1fb38f5b57
      54ee5225
  8. 04 May, 2018 5 commits
    • Andrii Grynenko's avatar
      Fix casting operators in Executor::KeepAlive · 8b829f52
      Andrii Grynenko authored
      Summary:
      Pointer value may change when casting.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: lbrandy
      
      Differential Revision: D7884048
      
      fbshipit-source-id: aa55e1b3530bc28f7d2ffd356761d962d6029832
      8b829f52
    • Matthieu Martin's avatar
      Implement KeepAlive in AsyncioLoopController · 64b6d1b6
      Matthieu Martin authored
      Summary:
      I'm continue to try keeping the implementation simple, instead of copy-pasting EventBase/EventBaseLoopController code.
      My understanding is that AsyncioExecutor/AsyncioLoopController will always be single threaded because they are tied to a unique asyncio event_loop, so I don't need an atomic counter.
      Then it should be cheap to just always aquire/release the counter in runLoop.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7875202
      
      fbshipit-source-id: 900a03e6870c5e4828521a99785cfa976baac54a
      64b6d1b6
    • Matthieu Martin's avatar
      Add FiberManager::Options parameter to folly::python::getFiberManager · 7672324a
      Matthieu Martin authored
      Summary:
      Copied the `const folly::fibers::FiberManager::Options& opts = {}` signature from main `getFiberManager`.
      Discussed with Andrii if I should key the FiberManager cache by options' address, but he voted to keep the behavior consistent with FiberManagerMap.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D7873868
      
      fbshipit-source-id: 0c7f6e6ef0ebe50d9658c2eee7ab1e098dd86ddd
      7672324a
    • Yedidya Feldblum's avatar
      Fix Build: folly/io/RecordIO.cpp under MSVC 2015u3 · 0a511014
      Yedidya Feldblum authored
      Summary: [Folly] Fix Build: `folly/io/RecordIO.cpp` under MSVC 2015u3, which inexplicably gives `error C2872: 'detail': ambiguous symbol`.
      
      Reviewed By: Orvid
      
      Differential Revision: D7875032
      
      fbshipit-source-id: 2ff5a60c941e20ef9a05cedb2e7d8224a9e83ed2
      0a511014
    • Andrii Grynenko's avatar
      Reduce KeepAlive object size to 1 pointer · 367d3cfa
      Andrii Grynenko authored
      Summary: Use a single pointer to store Executor pointer and dummy flag.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7857087
      
      fbshipit-source-id: 529fbfdc6ad14954f5bdd9bef3eb1e335b233ec9
      367d3cfa
  9. 03 May, 2018 9 commits
    • Orvid King's avatar
      Lower the number of samples in tdigest_test · 021f9853
      Orvid King authored
      Summary: It's timing out in open source test runs because each individual test was taking 10 seconds. They each now take 2.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7841938
      
      fbshipit-source-id: eb81c67cc26e98fb0b4b0c736bea747e985f2fcf
      021f9853
    • Marshall Cline's avatar
      future/semifuture poll() - use ?: · 06e7a0c4
      Marshall Cline authored
      Summary:
      `{Future,SemiFuture}::poll()`:
      - minor chg to impl from assignment to stateless ?:
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7840466
      
      fbshipit-source-id: 201dd7121b713324bb054b72c8ecdf6f4f163b97
      06e7a0c4
    • Andrii Grynenko's avatar
      Always manage lifetime of a SerialExecutor using KeepAlive tokens · f07d48a0
      Andrii Grynenko authored
      Summary: SerialExecutor is always wrapping another Executor, so we shouldn't force users to coordinate their lifetimes.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7856146
      
      fbshipit-source-id: ac7caaa0f181406dfb6b59d36ae4efe6d1343590
      f07d48a0
    • Andrii Grynenko's avatar
      Template KeepAlive with Executor type · d233e724
      Andrii Grynenko authored
      Summary:
      This allows using KeepAlive token as a pointer to an specific Executor sub-type (e.g. SequencedExecutor).
      getKeepAliveToken() has to be a free function to achieve this goal.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7847884
      
      fbshipit-source-id: 95dc62433d30212ceb9b9b2fc7d6b38cb5425311
      d233e724
    • Dave Watson's avatar
      dynamic CPUThreadPoolExecutor · 68a6b5b5
      Dave Watson authored
      Summary:
      This diff adds dynamic thread creation/destruction to ThreadPoolExecutor (mostly CPU).
      
      1) Threads are lazily created when the first task is add()ed (or getEventBase is called), applies to both IO and CPU
      
      and
      
      2) after a timeout in LifoSem, threads are joined in CPUThreadPoolExecutor.
      
      Most of the logic is in ThreadPoolExecutor.  A separate dynamic IOThreadPoolExecutor will be a follow on diff.
      
      To keep the previous behavior, users can set minthread == maxthreads, or gflags --dynamic_cputhreadpoolexecutor=false
      
      Reviewed By: magedm
      
      Differential Revision: D7477390
      
      fbshipit-source-id: 855a35380861111de33656e8fb1b681ae8cd2807
      68a6b5b5
    • Chad Austin's avatar
      formatting typos in Function.md · 484f75dd
      Chad Austin authored
      Summary: Fixes two tiny formatting issues with the folly::Function documentation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7856507
      
      fbshipit-source-id: dc82256a35f6c2b1eb66a868f419f2c800f1ddc5
      484f75dd
    • Yedidya Feldblum's avatar
      Avoid duplicating throw_exception instances taking string literal · 10f5670b
      Yedidya Feldblum authored
      Summary: [Folly] Avoid duplicating throw_exception instances taking string literal, which differ only in the length of the string literal.
      
      Reviewed By: marshallcline
      
      Differential Revision: D7853216
      
      fbshipit-source-id: a4648952cc10661322e5e23c6317ba4b75c268fb
      10f5670b
    • Nathan Bronson's avatar
      destructuring for F14*Set::emplace · 9a33b9b1
      Nathan Bronson authored
      Summary:
      This diff optimizes the operation of F14 set emplace when
      the argument list happens to be a single reference to a key_type.
      An intermediate key_type value is removed in that case, which avoids a
      move in all cases and avoids a copy when the emplace finds that the key
      is already present in the set.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7845720
      
      fbshipit-source-id: 16a639f53993d9843ffe265edd58c0d74de0c1f7
      9a33b9b1
    • Marc Celani's avatar
      shrink_to_fit TDigest after merge · ede7e6eb
      Marc Celani authored
      Summary:
      When used in a QuantileEstimator, some sliding window buckets can be sparse or all together empty. In this case, reserving memory in the constructor and in merge is wasteful. Don't reserve in the constructor (this is a complete waste) and call shrink_to_fit in merge.
      
      It's worth noting that the benchmarks *are* shrinking the digest, because the digests are only 85 or so items big, so it is exercising this path.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D7855242
      
      fbshipit-source-id: 61bcbaaf17dd46f8b98d171af43516ceb8d84510
      ede7e6eb