1. 21 May, 2019 4 commits
    • 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
  2. 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
  3. 18 May, 2019 2 commits
  4. 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
  5. 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
  6. 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
  7. 14 May, 2019 2 commits
    • Matthieu Martin's avatar
      Allow an EventBase to own multiple FiberManager · f5a52d63
      Matthieu Martin authored
      Summary:
      See the test for a concrete example.
      We have a scenario where both a library, and a service using that library, are using fiber. Managing a separate similar-sized thread and event-base pool costs us complexity and performance. So this seems like a legit need.
      
      The overall solution is to hash the Options struct.
      But because that has some cost, I made it optional, by introducing a new FrozenOptions struct.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D15305274
      
      fbshipit-source-id: 5c53d8c4ed321ae88089c64de41af8229f877d36
      f5a52d63
    • Lewis Baker's avatar
      Make folly::coro::Baton safe to await concurrently by multiple coroutines · 97e9c15e
      Lewis Baker authored
      Summary:
      This modifies the Baton data-structure to store a linked list of awaiters rather than storing a single awaiter.
      
      When a coroutine awaits the Baton it now does a lock-free push onto a list of awaiters.
      
      When the Baton is posted it atomically dequeues all awaiters from the list and then resumes each of them in turn.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D15310137
      
      fbshipit-source-id: 895ebcf2b113fb270ad7abfedbaab68ea51de84c
      97e9c15e
  8. 13 May, 2019 3 commits
    • Yedidya Feldblum's avatar
      Switch from NDEBUG to kIsDebug in MPMCQueue · d8bd1ecf
      Yedidya Feldblum authored
      Summary: [Folly] Switch from `NDEBUG` to `kIsDebug` in `MPMCQueue`, preferring C++ over the preprocessor.
      
      Reviewed By: Orvid
      
      Differential Revision: D15303518
      
      fbshipit-source-id: d014cea3035527bd27854f58b1a74a48740efd20
      d8bd1ecf
    • Mike Starr's avatar
      Make folly::retrying exponential backoff time behavior more consistent · 585e9bc7
      Mike Starr authored
      Summary:
      If the value for backoff_max is less than backoff_min, we will see inconsistent behavior where the backoff_min sleep duration is used for the first 57 attempts, then backoff_max will be used.
      
      In our case, we hit an issue where 0 was passed for backoff_max. We would see backoff_min sleep times for the first 57 attempts, then immediately drop to 0 sleep time which led to no retry wait at all.
      
      If backoff_max < backoff_min, there's no way to respect both, but this makes the behavior consistent across all tries.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15282681
      
      fbshipit-source-id: d9dd7b2498d77e4a01c9454a639b612ed9e26519
      585e9bc7
    • Luca Niccolini's avatar
      Revert D15177816: [folly] Fix de-ref of evb after evb deletion · a88cfa0b
      Luca Niccolini authored
      Differential Revision:
      D15177816
      
      Original commit changeset: 7298fcdc3a73
      
      fbshipit-source-id: fc62ec2ecf7fb06bc60cdd0c33b17b53fe35af19
      a88cfa0b
  9. 12 May, 2019 1 commit
    • Subodh Iyengar's avatar
      Fix de-ref of evb after evb deletion · 9616c483
      Subodh Iyengar authored
      Summary:
      HHWheelTimer is a member of EventBase, and EventBase is passed to it in the ctor.
      However during the destruction of the evb, wheel timer gets destroyed after the evb is destroyed and still retains a reference to the evb. This is not so good.
      
      This diff fixes it by canceling the timer before the evb gets destroyed.
      
      Reviewed By: lnicco
      
      Differential Revision: D15177816
      
      fbshipit-source-id: 7298fcdc3a73041484a315c420bcb866175c19cc
      9616c483
  10. 10 May, 2019 14 commits
    • Udip Pant's avatar
      update docker os_image to ubuntu18 and gcc7 · 967e3cae
      Udip Pant authored
      Summary:
      This diff updates docker os_image to ubuntu18 and gcc7 in travis settings.
      The dependencies that we work with internally (e.g. gcc7, boost and so on) are not present in the ubuntu-16.04. Further, the support for gcc5 is going away. So maintaining this compatibility for these platforms is painful, especially for new projects, such as mvfst.
      
      Reviewed By: simpkins
      
      Differential Revision: D15286181
      
      fbshipit-source-id: eb0da9556cdb17d0aa132ac2aa4c35f9c6eccd97
      967e3cae
    • Yedidya Feldblum's avatar
      XLOG_EVERY_N, XLOG_EVERY_N_EXACT · 83ce3eb4
      Yedidya Feldblum authored
      Summary: [Folly] `XLOG_EVERY_N`, `XLOG_EVERY_N_EXACT`. Renaming `XLOG_EVERY_N` to `XLOG_EVERY_N_EXACT` and adding a new `XLOG_EVERY_N` which performs better under contention, at the cost of possibly missing increments and therefore over-logging.
      
      Reviewed By: simpkins
      
      Differential Revision: D15230953
      
      fbshipit-source-id: cf7b86b96340f78156f7cd25f7e784b0f1b8d5fa
      83ce3eb4
    • Yedidya Feldblum's avatar
      Let CPUThreadPoolExecutor use unbounded queues · 9a096e58
      Yedidya Feldblum authored
      Summary:
      [Folly] Let CPUThreadPoolExecutor use unbounded queues when no queue bounds are specified.
      
      One constructor remains which specifies queue bounds; that constructor uses bounded queues.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D15113118
      
      fbshipit-source-id: 9c8ace4f170fdfdeef152e55b371d434ad248866
      9a096e58
    • Amol Bhave's avatar
      Fix math portability for xplat · 82a53425
      Amol Bhave authored
      Summary:
      xplat folly sync got blocked due to an error with missing ::remainderl
      function.
      Not really sure why this function is missing, for now ignore it.
      
      Reviewed By: Orvid
      
      Differential Revision: D15298056
      
      fbshipit-source-id: 34035da5de826b55e28c79b8540aacd827e1ffdf
      82a53425
    • Joe Loser's avatar
      Remove GCC 4.9 workaround in FunctionTest (#1126) · 5c57c80c
      Joe Loser authored
      Summary:
      - On GCC 4.9 and below, the type of `vec` could not be deduced in the
        `for_each` call.
      - Since folly requires GCC 5.1 or later now, which has no issues in the
        deduction, remove the workaround and associated comment.
      Pull Request resolved: https://github.com/facebook/folly/pull/1126
      
      Reviewed By: Orvid
      
      Differential Revision: D15292875
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 50533536e9e73d2c3e5d466d1b6143d0d4085648
      5c57c80c
    • John Strizich's avatar
      add option to pass options to `git clone` · 4e928185
      John Strizich authored
      Summary: We need this for dependencies that require submodules
      
      Reviewed By: saifhhasan, GirasoleY
      
      Differential Revision: D15282792
      
      fbshipit-source-id: b0cc8d645e73668252409934fd6741fb211e30ae
      4e928185
    • Zeyi (Rice) Fan's avatar
      fix encoding issue when building on Windows · cea16735
      Zeyi (Rice) Fan authored
      Summary:
      On Windows, the writing operation would fail with:
      
      ```
      Traceback (most recent call last):
        File ".\opensource\fbcode_builder\getdeps.py", line 400, in <module>
          sys.exit(main())
        File ".\opensource\fbcode_builder\getdeps.py", line 393, in main
          return args.func(args)
        File ".\opensource\fbcode_builder\getdeps.py", line 236, in run
          change_status = fetcher.update()
        File "C:\open\fbsource\fbcode\opensource\fbcode_builder\getdeps\fetcher.py", line 451, in update
          return mapping.mirror(self.build_options.fbsource_dir, self.repo_dir)
        File "C:\open\fbsource\fbcode\opensource\fbcode_builder\getdeps\fetcher.py", line 400, in mirror
          f.write(name + "\n")
        File "C:\Python36\lib\encodings\cp1252.py", line 19, in encode
          return codecs.charmap_encode(input,self.errors,encoding_table)[0]
      UnicodeEncodeError: 'charmap' codec can't encode characters in position 104-105: character maps to <undefined>
      ```
      
      and this is caused by a file in libgit2: https://github.com/libgit2/libgit2/blob/master/tests/resources/status/%E8%BF%99, which is intended to test handling non-ASCII path.
      
      Python on Windows will write file in cp1252 encoding by default, which does not contain that Chines character. (Caveat: that file on my system doesn't have the correct file name as well, it is being encoded in IBM861 for some reason. However the characters in IBM861 does not exist in CP1252 either)
      
      Reviewed By: wez
      
      Differential Revision: D15281521
      
      fbshipit-source-id: 8a75e32bc1042167c945d67e26b549fda83b6b41
      cea16735
    • Wez Furlong's avatar
      getdeps: introduce TransientFailure exception type · 4be1b74a
      Wez Furlong authored
      Summary:
      The goal is to return an error code > 127 in the case of a
      transient, retryable, infrastructure error.  This diff generates
      those in the case of failure in downloading a URL or from interacting
      with LFS.
      
      Reviewed By: strager
      
      Differential Revision: D15266838
      
      fbshipit-source-id: 4f52a791320123968869032c37912dded464a86e
      4be1b74a
    • Wez Furlong's avatar
      getdeps: respect cmake WORKING_DIRECTORY for tests · ccb63d10
      Wez Furlong authored
      Summary:
      the cmake `add_test` and related functions allow specifying
      the WORKING_DIRECTORY to use for tests.  We weren't respecting this
      value, so this diff looks up the WORKING_DIRECTORY from the ctest
      json info and adjusts the buck test info json blob that we pass
      on the testpilot.
      
      Since that interface only allows passing an argv array, we use
      the `cmake -E chdir` command to run a command in a specified
      directory in a portable manner.
      
      Reviewed By: strager
      
      Differential Revision: D15274012
      
      fbshipit-source-id: 1f02d461d73178745794703d455494e31c2e09ed
      ccb63d10
    • Amol Bhave's avatar
      Add portability support for std::remainder · b2cecfb5
      Amol Bhave authored
      Summary:
      std::remainder isn't supplied by all platforms. Specifically, uclibc
      doesn't have it. Do a similar case as with std::nextafter, i.e. implement a
      folly version in case it doesn't exists.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15291533
      
      fbshipit-source-id: 96a70b52af11135102fda3183626df69cdaf4261
      b2cecfb5
    • Amol Bhave's avatar
      Add builtin folly::nextafter when using uclibc · e265e1ef
      Amol Bhave authored
      Summary:
      When building using uclibc, std::nextafter doesn't exist. This is
      similar case as for android, where std::nextafter doesn't exist.
      Add additional condition to choose folly supplied versions of this function.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15291534
      
      fbshipit-source-id: f6c9e213248f4e2a6e88e20578aeade46dc85d6b
      e265e1ef
    • Yedidya Feldblum's avatar
      Add sorted_unique ctor to sorted_vector_set and sorted_vector_map · b8d837fc
      Yedidya Feldblum authored
      Summary: [Folly] Add `sorted_unique` ctor to `sorted_vector_set` and `sorted_vector_map`. The `presorted` ctors are used with presorted but not necessarily unique inputs, so uniquify the inputs in that ctors. The untagged ctors which take a backing container presort but do not uniquify the backing container, so switch to presorting and uniquifying.
      
      Reviewed By: vitaut
      
      Differential Revision: D15215677
      
      fbshipit-source-id: bf920103cfb6c297c186e5389701c08218dbc4b9
      b8d837fc
    • Yedidya Feldblum's avatar
      Less unneeded generality in sorted-vector ctors · 85fd07e2
      Yedidya Feldblum authored
      Summary: [Folly] Less unneeded generality in `sorted_vector_set` and `sorted_vector_map` ctors in terms of `begin` and `end` - can just use member functions.
      
      Reviewed By: vitaut
      
      Differential Revision: D15215590
      
      fbshipit-source-id: e6c8c92fdd9ae16963768b4f748aa07e9566f947
      85fd07e2
    • Yedidya Feldblum's avatar
      Use sorted_equivalent in TDigest · f75e2a2a
      Yedidya Feldblum authored
      Summary: [Folly] Use `sorted_equivalent` in `TDigest` since it is less ambiguous than `presorted` and it is a backport from C++20.
      
      Reviewed By: vitaut
      
      Differential Revision: D15195608
      
      fbshipit-source-id: 07bb4c7e3750affd10f182efcdf3d9ee9e4a8cf8
      f75e2a2a