1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 10 May, 2019 17 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
    • Yedidya Feldblum's avatar
      Add missing comment for TDigest::merge overload · cb3ff81d
      Yedidya Feldblum authored
      Summary: [Folly] Add missing comment for `TDigest::merge` overload.
      
      Reviewed By: vitaut
      
      Differential Revision: D15215559
      
      fbshipit-source-id: 781105819d8160b73d6d70dc22937482f6851f4f
      cb3ff81d
    • Yedidya Feldblum's avatar
      sorted_unique_t, sorted_equivalent_t · 1c0529a5
      Yedidya Feldblum authored
      Summary:
      [Folly] `sorted_unique_t`, `sorted_equivalent_t`, backporting from p0429 and C++20.
      
      Note that the existing `presorted_t` is ambiguous between `sorted_unique_t` as is assumed in `sorted_vector_set` and `sorted_vector_map` and `sorted_equivalent` as is assumed in `TDigest`.
      
      http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0429r6.pdf
      
      Reviewed By: Orvid
      
      Differential Revision: D15215532
      
      fbshipit-source-id: d90379d609088c6b306a0fc5c7db9b1ad3cdeee8
      1c0529a5
    • Amol Bhave's avatar
      Fix test AsyncUDPSocketTest for stress testing · fe95b7f0
      Amol Bhave authored
      Summary:
      If multiple instances of this test are running, it is possible for a
      filename conflict to occur. This fixes that behavior by using a different temp
      name each time.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15258558
      
      fbshipit-source-id: 40e71c57e68a90bc730fb5ba427d999789f6f88c
      fe95b7f0
  7. 09 May, 2019 6 commits
    • Yuhan Hao's avatar
      remove mstch from fbthrift's fbcode_builder spec · fd4e0165
      Yuhan Hao authored
      Summary: mstch is no longer required for fbthrift, we can remove it from oss build spec
      
      Reviewed By: vitaut
      
      Differential Revision: D15280267
      
      fbshipit-source-id: 5008e54af9c927f23b0d6acbf0d9beb6e004eee1
      fd4e0165
    • Yuhan Hao's avatar
      mstch is no longer required for fbthrift · 93fea16b
      Yuhan Hao authored
      Summary: mstch is no longer required for fbthrift, we can remove it from manifests
      
      Reviewed By: vitaut
      
      Differential Revision: D15279652
      
      fbshipit-source-id: 1772de7ab51fbfe048808f66290c4ca79de60608
      93fea16b
    • Chad Austin's avatar
      require FOLLY_SKIP_AS_FAILURE to be 1 · 48f70c58
      Chad Austin authored
      Summary: yfeldblum says convention here is 1 or empty (or 0).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15271809
      
      fbshipit-source-id: 528e4143eaa8ee86807b06c824b3d84a586ec69c
      48f70c58
    • Nick Sukhanov's avatar
      Make `next` relaxed · 6a80914d
      Nick Sukhanov authored
      Summary: We had a rare data race on next this diff is fixing that.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15120382
      
      fbshipit-source-id: d3f0e521b941fdfcd1d968a42d7e8d240c3f74e6
      6a80914d
    • Andrii Grynenko's avatar
      Use unbounded queues · 15666e6a
      Andrii Grynenko authored
      Summary: There's no way we can size such queues appropriately.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15271382
      
      fbshipit-source-id: 7d8c5b0a3faffac3e86cb87fa18d0597facc3189
      15666e6a
    • Chad Austin's avatar
      detect at runtime whether SKIP should fail · 2b928806
      Chad Austin authored
      Summary: Detect at runtime whether the test runner expects skips to fail.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15210476
      
      fbshipit-source-id: f1948d469b1008c85de9ed3ae93cc780caaf7f32
      2b928806
  8. 08 May, 2019 5 commits
    • Orvid King's avatar
      Fix minor compilation issue for PPC64LE · 63ad770a
      Orvid King authored
      Summary:
      Always throwing an exception in a function marked `noexcept` generates warnings that show up as errors, so just directly call `std::terminate()` instead.
      
      Fixes https://github.com/facebook/folly/issues/1124
      
      Reviewed By: aary
      
      Differential Revision: D15263327
      
      fbshipit-source-id: cf12bab76a5dc7da9414c6873fc0b0c1335691fa
      63ad770a
    • Giuseppe Ottaviano's avatar
      Implement extractFirstSet · 2180558b
      Giuseppe Ottaviano authored
      Summary: This can be useful to iterate bitmasks that are ORs of power-of-2 enum flags.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15245333
      
      fbshipit-source-id: 661e0bdbe4468b693e37fda12e513202a3b3ed17
      2180558b
    • Wez Furlong's avatar
      getdeps: introduce `build --enable-tests` option · 42925695
      Wez Furlong authored
      Summary:
      This controls whether tests are built or not.
      They are not built by default.  When `--enable-tests` is turned on,
      tests are enabled for the named project only, not all of the deps.
      This results in a faster build, because eg: the number of tests in
      folly is very large and consumers of folly don't want to spend so
      much time waiting to build tests when really all they want to do
      is build their own project.
      
      Reviewed By: strager
      
      Differential Revision: D15246336
      
      fbshipit-source-id: 2e22fd60c983b059f71639602712087f2a188ec6
      42925695
    • Wez Furlong's avatar
      getdeps: if the hash has changed, force a cmake reconfigure · 1bf2a1af
      Wez Furlong authored
      Summary:
      This is needed to correctly pick up changes made to
      eg: cmake.defines sections in the manifest for first-party
      projects.
      
      Reviewed By: strager
      
      Differential Revision: D15246337
      
      fbshipit-source-id: 35e525e885f87d6136d5ff3b94ebf34516ab947c
      1bf2a1af
    • Victor Zverovich's avatar
      Add conversion from fbstring to std::string_view · 41f67441
      Victor Zverovich authored
      Summary:
      Add an implicit conversion from `folly::fbstring` to `std::string_view` for
      compatibility with `std::string`. Among other things this enables formatting of
      `fbstring` with fmt.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D15230438
      
      fbshipit-source-id: 8f5a606c5e2a761cb332421130de638abfab4065
      41f67441