1. 24 May, 2019 1 commit
  2. 23 May, 2019 9 commits
    • Matt Glazar's avatar
      Reuse old build dir on Windows · 78ee6b85
      Matt Glazar authored
      Summary:
      getdeps.py's find_existing_win32_subst_for_path function tries to reuse an existing build directory alias. (On Windows, the build directory is aliased to a drive letter to shorten paths.) If this function does not find and existing build directory alias, getdeps.py invalidates many of its caches.
      
      On my Windows machine, find_existing_win32_subst_for_path always fails, so all of my builds are super slow. This happens because find_existing_win32_subst_for_path is given a path with a lower-case drive letter ("c:\users\..."), but the subst command returns paths with an upper-case drive letter ("C:\users\...").
      
      When comparing paths, use ntpath.normpath. This makes the comparison case-insensitive for drive letters. (It also makes the comparison case-insensitive for other path components.)
      
      On Linux and macOS, this diff should not change behavior.
      
      Reviewed By: wez
      
      Differential Revision: D15466096
      
      fbshipit-source-id: 1669aa0a6eaeb6012154f3a9e24eba3f835262c6
      78ee6b85
    • Yedidya Feldblum's avatar
      Fix returning reference to temporary in futures test · 33cdc598
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix returning reference to temporary in futures test.
      
      ```
      folly/futures/test/FutureTest.cpp: In instantiation of 'typename std::enable_if<(! isTry), R>::type folly::Try<NoThrowTestResult>::get() [with bool isTry = false; R = NoThrowTestResult&&; typename std::enable_if<(! isTry), R>::type = NoThrowTestResult&&]':
      folly/futures/Future-inl.h:95:30:   required from 'auto folly::futures::detail::wrapInvoke(folly::Try<T>&&, F&&) [with T = NoThrowTestResult; F = Future_NoThrow_Test::TestBody()::<lambda(NoThrowTestResult&&)>]'
      folly/futures/Future-inl.h:1209:39:   required from 'folly::Future<typename folly::futures::detail::valueCallableResult<T, F>::value_type> folly::Future<T>::thenValue(F&&) && [with F = Future_NoThrow_Test::TestBody()::<lambda(NoThrowTestResult&&)>; T = NoThrowTestResult; typename folly::futures::detail::valueCallableResult<T, F>::value_type = NoThrowTestResult]'
      folly/futures/test/FutureTest.cpp:1408:14:   required from here
      folly/futures/test/FutureTest.cpp:1392:33: warning: returning reference to temporary [-Wreturn-local-addr]
       1392 |     return std::forward<R>(value());
      ```
      
      Fixes #1130.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D15457369
      
      fbshipit-source-id: 045ae3321f957546a6218ee5e3118753e4c8ceb2
      33cdc598
    • Chris Keeline's avatar
      Allow calls to runInMainContext during exception handling · 6f2f3a1a
      Chris Keeline authored
      Summary:
      This should be ok to do. Main thing I'm not sure about is if it's ok
      to change these DCHECKs to CHECKs. We could probably also pass state into
      InlineFunctionRunner::run() to keep these as DCHECKS here and CHECK in our
      implementation.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D15463243
      
      fbshipit-source-id: c1de7198e8bf48d8af0e03361bed493642e6c173
      6f2f3a1a
    • Dan Melnic's avatar
      Add the ability to add multiple IOBuf free callbacks · 9cb3d6a3
      Dan Melnic authored
      Summary: Add the ability to add multiple IOBuf free callbacks
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15423850
      
      fbshipit-source-id: ad0352b345835b0472ec090b5ff07e30e14532d8
      9cb3d6a3
    • Jeroen Vaelen's avatar
      fix typo in ScopeGuard docs · f7986598
      Jeroen Vaelen authored
      Reviewed By: yfeldblum
      
      Differential Revision: D15452123
      
      fbshipit-source-id: 4ceec36f007e10284e8ac0482018099c7cea94d9
      f7986598
    • Adam Simpkins's avatar
      on non-Linux platforms allow 20ms of extra leeway on timeout checks · 16a7ef38
      Adam Simpkins authored
      Summary:
      In the folly/io/async tests, allow an extra 20ms of tolerance when performing
      timeout checks on non-Linux platforms.
      
      On Linux we can fairly reliably determine the amount of time that the test
      spent waiting to be scheduled on the CPU.  This allows the timeout tests to be
      relatively accurate even on overloaded systems.
      
      On non-Linux platforms we cannot determine the time spent waiting to be
      scheduled, and the `getSchedTimeWaiting()` implementation always returns 0.
      This causes the tests to fail pretty frequently on Mac OS.  Adding an extra
      20ms of tolerance should hopefully help reduce the test failure rate on Mac.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15464672
      
      fbshipit-source-id: 2c3096df6a15dcdc68bf14c947736e4731929c0f
      16a7ef38
    • Adam Simpkins's avatar
      fix some ASAN crashes in EventBaseTest · 818e09c0
      Adam Simpkins authored
      Summary:
      Since D3640289 the EventBase destructor has invoked currently scheduled
      LoopCallbacks.
      
      Some of the tests in `EventBaseTest` installed loop callbacks and checked that
      they were never run during the normal loop invocations.  Prior to D3640289
      these callbacks never ran.  However, post D3640289 these functions do run, and
      they attempt to update local stack variables that have already gone out of
      scope.
      
      This rearranges these functions to ensure the variables in question outlive
      the EventBase object.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15462319
      
      fbshipit-source-id: 8f490ddbb978fe45711eb7cbda4502dd6a0fb36b
      818e09c0
    • Adam Simpkins's avatar
      fix some of the EventBase timeout tests · d128502f
      Adam Simpkins authored
      Summary:
      A few of the EventBase timeout tests fail sometimes on the Travis CI
      infrastructure, reporting that timeouts fired sooner than expected.
      e.g.: https://api.travis-ci.org/v3/job/535980430/log.txt
      
      I believe these failures are due to the fact that the tests schedule the
      events/timeouts before capturing the start time point that they compare
      against.  This updates the tests to instead capture the start time point
      before scheduling events.
      
      Reviewed By: yfeldblum, chadaustin
      
      Differential Revision: D15462320
      
      fbshipit-source-id: dfc321d899768bc70ddaeaa0ef88b42ddd0b70ca
      d128502f
    • Adam Simpkins's avatar
      fix a bug in the EventBase tests · 86346823
      Adam Simpkins authored
      Summary:
      This test was accidentally updating `timestamp1` twice rather than updating
      `timestamp0`.
      
      The existing check for `timestamp0` only succeeded because `timestamp0` was
      never actually updated.  With the current EventBase behavior, even though we
      asked the function to be scheduled immediately, it actually ends up waiting
      for a full HHWheelTimer tick interval (10ms by default) before it runs.
      Update the check to take this into account.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15462318
      
      fbshipit-source-id: e1851c9c4f2e082ad73debf85343d99bbf244b23
      86346823
  3. 22 May, 2019 9 commits
    • Adam Simpkins's avatar
      logging: update XCHECK_EQ() to use objectToString() · 83989dbc
      Adam Simpkins authored
      Summary:
      Update the `XCHECK_EQ()` macros to use `folly::logging::objectToString()` to
      format the message on failure.
      
      This ensures that `XCHECK_EQ()` will successfully compile and work with any
      arguments.  Previously it would fail to compile if called with arguments that
      did not work with `folly::to<std::string>()`
      
      Reviewed By: chadaustin
      
      Differential Revision: D14545301
      
      fbshipit-source-id: 442657a1770f30cbf01462ad62d32301e60490e5
      83989dbc
    • Adam Simpkins's avatar
      logging: make objectToString() identical to toAppend() when available · cc3025b7
      Adam Simpkins authored
      Summary:
      If `toAppend(std::string*, const Object&)` is defined for a particular object
      type, make `objectToString()` simply return the exact output of `toAppend()`.
      
      Previously the code returned `(type_name: toAppendResult)`
      
      The new logic is based on the assumption that if `toAppend()` is implemented
      for an object, it should emit all relevant information about the object that
      may be needed by a developer.
      
      The old behavior of always including type information was potentially helpful
      in cases where `objectToString()` was called only in exceptional cases.
      (e.g., after an exception thrown by `folly::format()`).  However it made
      `objectToString()` too verbose in other non-exceptional situations where we
      want to format objects (e.g., in `XCHECK_EQ()`).  There doesn't really seem to
      be a strong need to keep the type information in the `folly::format()`
      exception case, so this just drops it rather than adding two separate versions
      of this function.
      
      Reviewed By: chadaustin
      
      Differential Revision: D14545303
      
      fbshipit-source-id: 29e2f12d65fd22112486ed11f989b63875980088
      cc3025b7
    • Adam Simpkins's avatar
      logging: improve objectToString() for objects with no toAppend() · d69e8653
      Adam Simpkins authored
      Summary:
      Update the `logging::objectToString()` and `appendToString)` functions when
      converting objects that do not have a `toAppend(std::string*, Object)`
      implementation.
      
      Previously the code simply emitted `<no_string_conversion>` after the object
      type name.  Now the code emits a hexdump of the object.  The emitted hexdump
      size is based compile-type visible type of the object.  For subclass instances
      the correct dynamic type name will be emitted (if RTTI is supported), but the
      hexdump will only include the portion of object known from the compile-time
      type.
      
      Reviewed By: yfeldblum, chadaustin
      
      Differential Revision: D14545305
      
      fbshipit-source-id: d1e3df001b7f7c40c7bcb0888e76bf775512e5d3
      d69e8653
    • Adam Simpkins's avatar
      logging: move object to string functions to their own header · 029911f0
      Adam Simpkins authored
      Summary:
      In LogStreamProcessor.h we previously had some `fallbackFormat()` functions
      that attempted to convert arbitrary objects to strings in case an exception
      was thrown when formatting them with `folly::format()`.
      
      These functions basically attempt to perform best-effort conversion that
      ideally should never fail (barring failure to append to the output string).
      These functions attempt to use `toAppend()` for the object, similar to how
      `folly::to<std::string>()` works.  However, if no `toAppend()` function is
      available, or if it throws an exception, they fall back to returning a generic
      string.
      
      This diff moves these functions to a separate header file to make it easier to
      re-use them in other parts of the code.  In particular I plan to update the
      `XCHECK_EQ()` and related macros to use these functions to format its
      arguments.
      
      Reviewed By: chadaustin
      
      Differential Revision: D14545304
      
      fbshipit-source-id: 053a504340ba4513abc9bec186a31ffaa03a943a
      029911f0
    • Andrii Grynenko's avatar
      Make timed_wait work for semi awaitables · 4924344d
      Andrii Grynenko authored
      Reviewed By: lewissbaker
      
      Differential Revision: D15363390
      
      fbshipit-source-id: 98c30928773992c5bb7f040e6f5afb8ee6fef713
      4924344d
    • Yedidya Feldblum's avatar
      Cut unnecessary template param default of futexWaitUntil · 62257ded
      Yedidya Feldblum authored
      Summary: [Folly] Cut unnecessary template param default of `futexWaitUntil`; the param is deduced from the arguments.
      
      Reviewed By: aary
      
      Differential Revision: D15448750
      
      fbshipit-source-id: ec81fc10efbf68ad328a1fb1b7d2fdb2e93551cd
      62257ded
    • Lee Howes's avatar
      Add runOnExecutor helper for then(executor, callback) · 3e5cdc05
      Lee Howes authored
      Summary: Helper function to wrap a nested dispatch. Returns a function object that launches the passed function onto the executor and returns a future representing the return value of the function.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D15300575
      
      fbshipit-source-id: eca4b4139c6405f216a9f1cbc87a8ec2ff437780
      3e5cdc05
    • Yedidya Feldblum's avatar
      Remove explicit throw/try/catch from IOBuf · f59c30e7
      Yedidya Feldblum authored
      Summary:
      [Folly] Remove explicit `throw`, `try`, and `catch` uses from `IOBuf`, preferring scope guards and `throw_exception`.
      
      (Note: this ignores all push blocking failures!)
      
      Differential Revision: D15442544
      
      fbshipit-source-id: 2f182256ff12f5aad6166a7b40ed018c1b32e923
      f59c30e7
    • Yedidya Feldblum's avatar
      Mark some more IOBuf members as noexcept · 7c86f5f6
      Yedidya Feldblum authored
      Summary:
      [Folly] Mark some more `IOBuf` members as `noexcept` and remove an explicit `abort` which is there to simulate `noexcept`.
      
      (Note: this ignores all push blocking failures!)
      
      Differential Revision: D15442545
      
      fbshipit-source-id: adaef4d1f6c2e551e9c19b151e3f08c6ba11f717
      7c86f5f6
  4. 21 May, 2019 5 commits
    • Joe Loser's avatar
      Fix pessimizing moves (#1131) · 2cb9738a
      Joe Loser authored
      Summary:
      - GCC 9.1 warns when moving a local object in a return statement
        prevents copy elision.
      - Remove the explicit `std::move` in those return statements.
      Pull Request resolved: https://github.com/facebook/folly/pull/1131
      
      Reviewed By: LeeHowes
      
      Differential Revision: D15391413
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: af29ea0f6f65957645fa2debce2f5303906a2507
      2cb9738a
    • Yedidya Feldblum's avatar
      Cut folly/LockTraitsBoost.h · 663d9c42
      Yedidya Feldblum authored
      Summary:
      [Folly] Cut `folly/LockTraitsBoost.h`. Also, discourage specializing `LockTraits`.
      
      For ODR sanity, the better mechanism is to wrap mutex types with non-standard interfaces in mutex wrapper types with standard interfaces.
      
      Reviewed By: Orvid
      
      Differential Revision: D15426235
      
      fbshipit-source-id: f54aee8c47951f6214f5b23fce7f8f6c29c8b5c2
      663d9c42
    • Jingyi Yang's avatar
      sigar + libzmq · 81f4e08f
      Jingyi Yang authored
      Summary: Add lizmq and sigar in prepare for fbzmq oss build migration.
      
      Reviewed By: wez
      
      Differential Revision: D15387435
      
      fbshipit-source-id: 1ec2057972bf801a1598af0a1ae87f958394d812
      81f4e08f
    • Wez Furlong's avatar
      watchman: fixup FB internal mac packaging · 13916440
      Wez Furlong authored
      Summary:
      with the reshuffling around getdeps.py, and changes in folly/thrift/wangle,
      our internal package stopped building.  This diff brings it back to life.  It is
      a little bit interwined:
      
      * Introduce a `--facebook-internal` switch to getdeps that causes `fb` in the
        build context to be set to `on` rather than `off`.  This allows specifying
        options in the manifest that are FB specific.
      * Introduce cmake options to control the WATCHMAN_STATE_DIR and whether cmake
        should attempt to create WATCHMAN_STATE_DIR when it is installed.
      * For FB specific builds on macOS, set the state dir to match our existing location
        and disable creation of WATCHMAN_STATE_DIR because that will ultimately be
        handling during package installation and we don't have privs for that on
        the machine generating the package.
      * Adjust Facebook CI scripts to use getdeps for building and testing watchman
      
      Reviewed By: simpkins
      
      Differential Revision: D15337970
      
      fbshipit-source-id: 8ab3c1f810decf5f0b16337dc1cbe6dc73d26426
      13916440
    • Maged Michael's avatar
      MPMCQueue: Add comment that Dynamic version is deprecated. · 25bd8416
      Maged Michael authored
      Summary: Add a comment that the Dynamic version of MPMCQueue is deprecated and that UnboundedQueue should be used instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15392160
      
      fbshipit-source-id: 5958b7602d3062878dd3e78907cb7091532ad4b8
      25bd8416
  5. 20 May, 2019 4 commits
    • Anton Likhtarov's avatar
      Fibers: allow more than one guard page per stack · 791b61f0
      Anton Likhtarov authored
      Summary: Guard pages are cheap (VM only + mapping state). More than one is occasionally useful (e.g. imagine a 10k object on stack that's not used, subsequent function calls will create a frame that jumps over a single 4K guard page and we get hard to debug memory corruption instead of a clean segfault).
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D15367640
      
      fbshipit-source-id: 8f1d42a71926653929dd847eeba172c680f98589
      791b61f0
    • Wez Furlong's avatar
      getdeps: allow tagging a build with its schedule type · 74588469
      Wez Furlong authored
      Summary:
      The schedule type is used to differentiate between a build run during
      code review (and thus runs code that isn't yet in the master branch),
      from continuous or other types of run that operate on landed code.
      
      This doesn't change any behavior yet; this diff just adds
      the plumbing to pass down an optional arbitrary schedule type string
      from the CI system.
      
      In the future, we'll use the schedule type to influence the behavior
      of running tests.
      
      Reviewed By: strager
      
      Differential Revision: D15300120
      
      fbshipit-source-id: 3b46afef2ff171b3fa095763dd5006a54ea328b8
      74588469
    • Nathan Bronson's avatar
      avoid -Wclass-memaccess warning on gcc 9.1 · 96f74144
      Nathan Bronson authored
      Summary:
      F14TestUtil's SwapTrackingAlloc's metadata accesses were
      triggering a -Wclass-memaccess warning in gcc 9.1 despite being safe. This
      diff changes the accesses to use explicit casting to avoid the warning.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15393963
      
      fbshipit-source-id: 088811354f00d623a58678c3f41a0e8effdb5ce3
      96f74144
    • Luca Niccolini's avatar
      enable CMake build (with HTTP/3) · 354223ec
      Luca Niccolini authored
      Reviewed By: udippant
      
      Differential Revision: D15368849
      
      fbshipit-source-id: 5e101fc38417b807a531fa456b38234d6dd08b7a
      354223ec
  6. 18 May, 2019 2 commits
  7. 17 May, 2019 4 commits
    • Anton Likhtarov's avatar
      Remove spinning for fibers::Baton when waiting from a thread · 43e27ca3
      Anton Likhtarov authored
      Summary: This is not a good default. We can build a dedicated SpinningBaton if needed
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D15387138
      
      fbshipit-source-id: 433ce2b1af7c661edd2c0e264dc618cc9c680aa3
      43e27ca3
    • Rui Zhang's avatar
      SharedMutex: use folly::kIsDebug instead of NDEBUG · 598b2103
      Rui Zhang authored
      Summary: This diff replaces all 2 occurrences of "NDEBUG" with "folly::kIsDebug" in folly/SharedMutex.h. Compared to NDEBUG, folly::kIsDebug has the equivalent functionally  but helps consolidate the conditional-compilation logic to a single place, namely folly/portability.
      
      Reviewed By: shixiao
      
      Differential Revision: D15379370
      
      fbshipit-source-id: 58c563624e58a4fd18b0cfbe4c0b9ba879f8eea9
      598b2103
    • Subodh Iyengar's avatar
      call the correct method when socket is connected · 73ffab43
      Subodh Iyengar authored
      Summary:
      When the udp socket is connected we shouldn't supply the peer's address. This changes it so that
      we can use write() methods in AsyncUDPSocket when the socket is connected.
      
      Differential Revision: D15384587
      
      fbshipit-source-id: ad26e2d04a7303c7ff9e25f32422d7c56e4283e5
      73ffab43
    • Anton Likhtarov's avatar
      FiberManager: numTasks() to query for total number of active fibers · d2005259
      Anton Likhtarov authored
      Reviewed By: andriigrynenko
      
      Differential Revision: D15366589
      
      fbshipit-source-id: e8d1c17e158437a3ca882f51f12071bf666c1a6e
      d2005259
  8. 16 May, 2019 4 commits
    • Wez Furlong's avatar
      getdeps: add support for using ccache in cmake builds · 5284c61b
      Wez Furlong authored
      Summary:
      if we find ccache in the path, then we instruct cmake to use
      it as the compiler launcher.
      
      Reviewed By: pkaush
      
      Differential Revision: D15375441
      
      fbshipit-source-id: 602fe54742a5ec07b0533bd2cf63cb905b051e85
      5284c61b
    • Lee Howes's avatar
      Add benchmark for inline continuations: · 0cb09568
      Lee Howes authored
      Summary:
      Adds a benchmark to show the benefit of running work inline.
      
      Dev:
      | fourThensOnThread | 2.15% | 245.01us | 4.08K |
      | fourThensOnThreadInline | 2.36% | 223.51us | 4.47K |
      | hundredThensOnThread | 0.67% | 783.54us | 1.28K |
      | hundredThensOnThreadInline | 0.88% |  595.24us | 1.68K |
      
      Opt:
      | fourThensOnThread                                |   0.18% |    70.37us  |  14.21K |
      | fourThensOnThreadInline                          |   0.26%  |   50.11us   | 19.96K |
      | hundredThensOnThread            | 0.18% | 72.54us | 13.79K |
      | hundredThensOnThreadInline | 0.21%  | 64.79us | 15.43K |
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15319231
      
      fbshipit-source-id: 978c26538d89de15e76eb69bf20c1129b210a442
      0cb09568
    • Wez Furlong's avatar
      getdeps: correctly handle the install_dir value · 9baf6c88
      Wez Furlong authored
      Summary:
      We were computing `SCRATCH/install` and hashing based on that value,
      but the build stuff was later computing `SCRATCH/installed` and passing that
      to the builders.
      
      Fixup the mismatch.
      
      Reviewed By: simpkins
      
      Differential Revision: D15337969
      
      fbshipit-source-id: 70288f2d9286aaacf4c1f6e0dac4680a55edac6d
      9baf6c88
    • Lee Howes's avatar
      Add inline forms of future continuation operations. · 73130f76
      Lee Howes authored
      Summary:
      Adds inline-supporting forms of thenValue and thenTry. Carries this information in the Core through a variant of the HasCallback state. Dispatches the continuation inline rather than on the executor if that state is set.
      
      Propagate completing executor through intermediate promise and make inline execution conditional on matching executors.
      
      Only continue inline if the executor of the completing task matches that of the task-to-be-enqueued, to ensure that calls to via always trigger reposting and that there are no surprises where work runs on the wrong executor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15292236
      
      fbshipit-source-id: 51ddd5cfd1196ea9e9f408e2b1337ff9d4fa5b9f
      73130f76
  9. 15 May, 2019 2 commits
    • Yedidya Feldblum's avatar
      Extract the unique-instance enforcer · 263ebaa1
      Yedidya Feldblum authored
      Summary: [Folly] Extract the unique-instance enforcer from `SingletonThreadLocal` into a standalone `UniqueInstance`.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14927839
      
      fbshipit-source-id: cfe98ef7a88746a557a64263f3165cd01caeec37
      263ebaa1
    • Yedidya Feldblum's avatar
      Cut presorted and unsorted tags · 9900b2a0
      Yedidya Feldblum authored
      Summary: [Folly] Cut `presorted` and `unsorted` tags; the `presorted` tag has  ambiguous meaning and is replaced by either `sorted_unique` or `sorted_equivalent`.
      
      Reviewed By: vitaut
      
      Differential Revision: D15196179
      
      fbshipit-source-id: a2cdaa06c7c5a55147db67a877b29c5944039e6d
      9900b2a0