1. 28 Oct, 2020 2 commits
    • Michael Park's avatar
      Rename `FutureAwaitable` to `FutureAwaiter`. · 0c20854f
      Michael Park authored
      Summary: Merely a terminology thing. An object returned by `co_await` is an awaiter, not an awaitable.
      
      Reviewed By: yfeldblum, lewissbaker
      
      Differential Revision: D24524929
      
      fbshipit-source-id: ee9b7c8807972e78fff97f055d498977048d0c48
      0c20854f
    • Lewis Baker's avatar
      Add missing custom-allocation routine for InlineTaskDetached · 063ef0c0
      Lewis Baker authored
      Summary:
      Allocation of InlineTaskDetached coroutines now call through to the
      folly_coro_async_malloc() and folly_coro_async_free() functions so that
      their allocations can be correctly accounted for as coroutine allocations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24574568
      
      fbshipit-source-id: 9bece3f8e6f6d221bca021a50fe02e1eed88f07b
      063ef0c0
  2. 27 Oct, 2020 3 commits
    • Lewis Baker's avatar
      Change the way getDetachedRootAsyncStackFrame() calculates the address of detached_task() · e90879cf
      Lewis Baker authored
      Summary:
      The previous implementation was calculating an address within the
      detached_task() function by just adding the constant +2 to the
      function-pointer. This was causing some issues with some of the
      tools used to optimise binaries.
      
      Reworked this implementation to instead actually return a true
      return-address obtained from the compiler builtin so that it's
      hopefully less problematic for those tools.
      
      Reviewed By: maksfb
      
      Differential Revision: D24506346
      
      fbshipit-source-id: c41bd55ab09ebc70d040d355556ed4992243c14f
      e90879cf
    • Simon Capper's avatar
      Fix test failure introduced by D24505812 · 23e90e57
      Simon Capper authored
      Summary:
      D24542292 fixed a problem introduced by D24505812 (https://github.com/facebook/folly/commit/af8630489dc8318f72d18358591bc3fa0be304ff) with gcc version 6.
      
      Unfortunately this broke some python code generation.
      
      I didn't fully root cause the issue but it appears that the macro expansion of FMT_BEGIN_NAMESPACE is inconsistent.
      
      The original diff D24505812 (https://github.com/facebook/folly/commit/af8630489dc8318f72d18358591bc3fa0be304ff) hardcoded the fmt namespace I changed it to what the fmt lib used when declaring the formatter template.
      
      Reverting the change to use the macro back to hardcoding the fmt namespace fixes the test and still works around the gcc 6 compler problem.
      
      Reviewed By: vitaut
      
      Differential Revision: D24542292
      
      fbshipit-source-id: cfaecf8bb94f3c6fc084ebae79886ad3e2b58539
      23e90e57
    • Lewis Baker's avatar
      Fix some dangling reference bugs in folly::coro::Task tests · 59277b68
      Lewis Baker authored
      Summary:
      The TaskTests::FutureRoundtrip and TaskTests::StartInlineUnsafe tests were
      incorrectly using stateful lambdas in a way that leads to the coroutines
      having a dangling reference to a destructed temporary lambda. This was causing
      ASAN failures.
      
      This changes those usages to instead use stateless lambdas.
      
      Reviewed By: lxfind
      
      Differential Revision: D24542508
      
      fbshipit-source-id: 034d397b79e0553094a14d2cb6d00fe3816b4b92
      59277b68
  3. 26 Oct, 2020 3 commits
    • Michel Salim's avatar
      Fix HTML document titles · f9a8116a
      Michel Salim authored
      Summary:
      The document titles should be explicitly passed, otherwise pandoc generates a warning and tries to guess
      
      Before:
      ```
      folly/folly/docs on  master
      ❯ make Format.html
      /usr/bin/pandoc -s -H style.css -f markdown -t html --toc -o Format.html Format.md
      [WARNING] This document format requires a nonempty <title> element.
        Defaulting to 'Format' as the title.
        To specify a title, use 'title' in metadata or --metadata title="...".
      
      folly/folly/docs on  master
      ❯ make index.html
      /usr/bin/pandoc -s -H style.css -f markdown -t html --toc -o index.html *.md
      [WARNING] This document format requires a nonempty <title> element.
        Defaulting to 'AtomicHashMap' as the title.
        To specify a title, use 'title' in metadata or --metadata title="...".
      ```
      
      After:
      ```
      folly/folly/docs on  fix-docs [!]
      ❯ make Format.html
      /usr/bin/pandoc -s -H style.css -f markdown -t html --toc -o Format.html Format.md --metadata title="folly/Format.h"
      
      folly/folly/docs on  fix-docs [!]
      ❯ make index.html
      /usr/bin/pandoc -s -H style.css -f markdown -t html --toc -o index.html *.md --metadata title="Folly API Documentation"
      ```
      
      Reviewed By: danobi
      
      Differential Revision: D24546374
      
      fbshipit-source-id: 818e6ce39f361695a5f94c7662953062ea2f2868
      f9a8116a
    • Jeff Liang's avatar
      Fix int overflow when using PoissonDistribution with FunctionScheduler · fa7945b1
      Jeff Liang authored
      Summary: Using the FunctionScheduler with PoissonDistribution will not work if we supply an interval of 36min+. This is around 2^31 so looks like it's hitting some integer limit. Also, there is no failure message and the behavior is that the function scheduler just never executes the function even for the first time after startup interval. Fixing this by using the proper type in the disribution.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24505727
      
      fbshipit-source-id: ad050cf82bcf5a39383ffc601b52ad05d3d54f44
      fa7945b1
    • Huapeng Zhou's avatar
      Back out "Workaround a wasm dependency issue" · 26582c2b
      Huapeng Zhou authored
      Summary: Original commit changeset: 578dd8981922
      
      Reviewed By: jalopezsilva, pdubovitsky
      
      Differential Revision: D24531203
      
      fbshipit-source-id: 573ccd55a4d8f3b6841cc533e25c84b18fe24d4d
      26582c2b
  4. 25 Oct, 2020 2 commits
    • Eric Niebler's avatar
      Use static_cast instead of function-style cast in ConstexprMath.h · 5cdac587
      Eric Niebler authored
      Summary:
      Some llvm toolsets mis-parse the function-like C-style casts in ConstexprMath.h as function declarations, resulting in strange compiler errors. Prefer `static_cast` to eliminate the ambiguity.
      
      Note: We cannot use brace-initialization syntax, because that would error on narrowing conversions.
      
      Reviewed By: ispeters, Mizuchi
      
      Differential Revision: D24463342
      
      fbshipit-source-id: 5d5aabb08cd20e91a1a5f5460cc4505cafb3cdfc
      5cdac587
    • Pavel Dubovitsky's avatar
      Workaround a wasm dependency issue · 41a9dc8f
      Pavel Dubovitsky authored
      Summary: This is a quick and dirty hack that works around a wasm dependency issue. The issue manifests itself in a compile error when including fmt headers during a wasm build.
      
      Reviewed By: shodoco
      
      Differential Revision: D24516599
      
      fbshipit-source-id: 578dd8981922a97702992a8c30b88b47fef1706e
      41a9dc8f
  5. 24 Oct, 2020 3 commits
    • Simon Capper's avatar
      Workaround compiler error with gcc version 5 &6 · af863048
      Simon Capper authored
      Summary: gcc versions 5 & 6 do not support template specializations outside the original namespace of the template even if the namespace is explicitly included in the template specialization.
      
      Differential Revision: D24505812
      
      fbshipit-source-id: 693e93de5bc5074866fdea713436a06d35762cb7
      af863048
    • Andrii Grynenko's avatar
      Make AtomicNotificationQueue::size() TSAN-clean · 05786142
      Andrii Grynenko authored
      Summary:
      taskExecuteCount_ can be incremented from a single thread, but reading it from another thread is still technically a data race. Mark it as atomic to make TSAN happy.
      Also make sure we never return < 0 when called from a non-consumer thread (since we only have the synchronization guarantee on the consumer thread).
      
      Differential Revision: D24523284
      
      fbshipit-source-id: 6185125e132d71a83a3f29c909b7e4eab09e6e79
      05786142
    • Dave Rigby's avatar
      FindGlog: Add support for 'glogd' Debug library (#1479) · 5fd7f424
      Dave Rigby authored
      Summary:
      Glog v0.4.0 when configured with Debug build type adds a 'd' suffix to
      the library file. This results in FindGlog.cmake failing to locate it.
      
      Update FindGlog.cmake to use check for 'glogd', and use
      select_library_configurations() to set GLOG_LIBRARY to the correct
      found filename.
      
      (Note: this has no effect if a non-Debug type is used.)
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1479
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24503510
      
      Pulled By: Orvid
      
      fbshipit-source-id: 705df05a4a3d7df2df8af3bb66c319fb044adbce
      5fd7f424
  6. 23 Oct, 2020 5 commits
    • Andrii Grynenko's avatar
      Use alignas(folly::cacheline_align_v) to improve NotificationQueue perf · 1592db4a
      Andrii Grynenko authored
      Summary: This also splits queue size counter into two to make sure we do fewer atomic operations on the consumer thread.
      
      Differential Revision: D24490151
      
      fbshipit-source-id: 69297a2fd0c5fddcd7355a28fe600b72320e81cd
      1592db4a
    • Andrii Grynenko's avatar
      Minor AtomicNotificationQueue cleanup · a876ba8b
      Andrii Grynenko authored
      Summary: Following up on some comments on the initial diff.
      
      Differential Revision: D24489715
      
      fbshipit-source-id: baea66c7b811ebabf4476d7fd6a1136ab9ec2282
      a876ba8b
    • Andrii Grynenko's avatar
      Use AtomicNotificationQueue in EventBase · a7c4b5ba
      Andrii Grynenko authored
      Differential Revision: D24414496
      
      fbshipit-source-id: ad552d3dd58b6c351c99e5f8c9056c5829c4c095
      a7c4b5ba
    • Victor Zverovich's avatar
      Add a StringPiece formatter · 6d95d30f
      Victor Zverovich authored
      Summary: Add an {fmt} formatter for `StringPiece`. This is much faster than going through ostream `operator<<` which we fallback to otherwise.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24337424
      
      fbshipit-source-id: c6f1775cf83cfa6bcaa25cb4f6b665a76672e7c3
      6d95d30f
    • Nanshu Chen's avatar
      clean up unnecessary c++ extern imports · 35b4d759
      Nanshu Chen authored
      Summary:
      A lot of these imports with specialization is not necessary. Clean up them to use generic functions instead.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24236181
      
      fbshipit-source-id: fe6e6c41f680561c625b263bc6adeba738ddb252
      35b4d759
  7. 22 Oct, 2020 6 commits
    • Sridhar Srinivasan's avatar
      Invoke life cycle observer callbacks during event base attach and · 99f8dcdd
      Sridhar Srinivasan authored
      Summary: Inform LifecycleObservers when an EventBase is attached or detached from an AsyncSocket.
      
      Reviewed By: bschlinker
      
      Differential Revision: D24294292
      
      fbshipit-source-id: 652ec438d0b6213a78742b8a8ef0d24d55ac9816
      99f8dcdd
    • Margot Leibold's avatar
      Implement ReadMostlyTLObserver · d5d78479
      Margot Leibold authored
      Summary: Implement a thread local Observer that optimizes on the shared_ptr copy by using ReadMostlySharedPtr
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D24439652
      
      fbshipit-source-id: 9174be7f3f2fc34bdc79bd83eab571972b0c057d
      d5d78479
    • Margot Leibold's avatar
      constructor benchmark · 31563f4c
      Margot Leibold authored
      Summary: Construction of ReadMostlyMainPtr is much slower than shared_ptr
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24350176
      
      fbshipit-source-id: 55730192f79288e7ad848b4cec6483bc0c1711b6
      31563f4c
    • Andrii Grynenko's avatar
      AtomicNotificationQueue · 50e9d1bb
      Andrii Grynenko authored
      Summary:
      This is a lock-free replacement for NotificationQueue. Unlike notification queue it supports only one consumer, which allows simplifying the internal structure a lot and avoiding any use of spin locks.
      Another improvement comparing to NotificationQueue is the use of epoll edge-triggered events. This allows completely eliminating read syscals, since we don't need to drain eventfd to stop it from waking up the epoll loop.
      
      Differential Revision: D24297158
      
      fbshipit-source-id: 1f418d861210f6dcad52b4d663f49eb2e8f3ae8c
      50e9d1bb
    • Michel Salim's avatar
      encode PACKAGE_VERSION in libfolly.pc · eaee7b4b
      Michel Salim authored
      Summary:
      `libfolly.pc` should contain the actual version of Folly, instead of just
      `master`.
      
      Reviewed By: danobi
      
      Differential Revision: D24471074
      
      fbshipit-source-id: 5fc29eeee25c8c317c3405f430fd079d47c441bd
      eaee7b4b
    • Andrii Grynenko's avatar
      Fix EventBase death tests · 298b697f
      Andrii Grynenko authored
      Summary:
      Existing test was supposed to be testing the exception, but was instead dying because of the pid check.
      Have 2 separate tests and use crash message regex to make sure they actually test what they are supposed to be testing.
      
      Differential Revision: D24461683
      
      fbshipit-source-id: b7ef30e488d266ea17e283f9b13b5d013a4a125a
      298b697f
  8. 21 Oct, 2020 6 commits
    • Davide Cavalca's avatar
      folly: set shared libraries version · f817aff7
      Davide Cavalca authored
      Summary:
      This should make packaging folly easier, as it allows one to set the
      .so version to denote ABI breaks. Specifically, we're looking to use this in
      https://bugzilla.redhat.com/show_bug.cgi?id=1887621 to package folly in Fedora
      and have the version match the tagged release version (i.e. treat every release
      as ABI breaking).
      
      Differential Revision: D24451669
      
      fbshipit-source-id: f63be760c90567117f1ebbec37416c0d9d8a4736
      f817aff7
    • Davide Cavalca's avatar
      folly: always enable PIE in shared libs build · 3b1bdb98
      Davide Cavalca authored
      Summary:
      This reverts https://github.com/facebook/folly/pull/833 by adding back
      the unconditional setting of `POSITION_INDEPENDENT_CODE` when building shared
      libs. Without it, the build fails with a number of relocation errors. This was
      previously reported in https://github.com/facebook/folly/issues/983
      
      Differential Revision: D24449731
      
      fbshipit-source-id: 6f6cb71ef545d02998afb09909772b62657c1262
      3b1bdb98
    • Davide Cavalca's avatar
      folly: fix permissions on a couple of files · c20d1a93
      Davide Cavalca authored
      Summary: These do not need to be executable
      
      Differential Revision: D24449732
      
      fbshipit-source-id: 5f013c62dd6bf88fe4d50782a4c5bfcec6834aec
      c20d1a93
    • Michael Lee (Engineering)'s avatar
      `FOLLY_MAYBE_UNUSED` does not work on Windows · a55fdc39
      Michael Lee (Engineering) authored
      Summary:
      `frame` may be unused depending on whether it is compiled with or without asserts.
      
      `FOLLY_MAYBE_UNUSED` is supposed to take care of this, but it does not work on Windows and trips up the comiler:
      
      ```
      warning C4100: frame: unreferenced formal parameter
      ```
      
      Reviewed By: johnkearney, akrieger
      
      Differential Revision: D24451220
      
      fbshipit-source-id: 8225640a5e8fd0ceed4ffcc53cea7422a5581d6f
      a55fdc39
    • Yedidya Feldblum's avatar
      to_shared_ptr_aliasing · 9ffd6285
      Yedidya Feldblum authored
      Summary: [Folly] `to_shared_ptr_aliasing`, exposing the shared-ptr aliasing constructor as a free function deducing the types of its arguments.
      
      Reviewed By: Mizuchi
      
      Differential Revision: D24414504
      
      fbshipit-source-id: 290e822464860b824961986211375d87f942f483
      9ffd6285
    • Lewis Baker's avatar
      Update folly::fibers to preserve thread_local AsyncStackRoot · 039b4056
      Lewis Baker authored
      Summary:
      Updates the FiberManager to make sure that it saves/restores the current-thread's
      top-most active AsyncStackRoot when the coroutine is suspended/resumed.
      
      This is required for correctness to ensure async stack traces remain functional
      in the presence of fiber context-switches.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21130668
      
      fbshipit-source-id: 4002bae0fc12a61c38836f9f099da4e6cf9183f4
      039b4056
  9. 20 Oct, 2020 2 commits
    • Alex Blanck's avatar
      Fix UndefinedBehaviorSanitizer error in `retryingPolicyCappedJitteredExponentialBackoff` · c663849f
      Alex Blanck authored
      Summary:
      While running some unit tests which happen to call into `folly::futures::retryingPolicyCappedJitteredExponentialBackoff`, I noticed that  `retryingJitteredExponentialBackoffDur` was triggering a "float-cast-overflow" error from UndefinedBehaviorSanitizer.
      
      It turns out that this only happened if `backoff_min` was 0 and there were at least 1025 retries. The large retry count caused the exponential term in the calculation to become `Infinity`. In floating point, Infinity multiplied by 0 was `NaN`, causing the sanitizer error.
      
      Although `backoff_min` should typically not be set to 0 because this effectively disables all backoff, I think there may be cases, such as unit tests, where setting `backoff_min` to 0 does make sense. This commit adds an additional check to handle this unusual case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24122470
      
      fbshipit-source-id: 48a8aede0d22e73cf001dab5eb184e841f3c23aa
      c663849f
    • Dan Melnic's avatar
      Remove FOLLY_HAVE_MSG_ERRQUEUE check · d1015a0b
      Dan Melnic authored
      Summary: Remove FOLLY_HAVE_MSG_ERRQUEUE check
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24295244
      
      fbshipit-source-id: 24d4a69a013951b37fe7c93539b26eedf8113360
      d1015a0b
  10. 19 Oct, 2020 4 commits
    • Daniel Xu's avatar
      Use assert() instead of DCHECK · 81e350e1
      Daniel Xu authored
      Summary:
      We were seeing the following build failures on i386:
      ```
      In file included from folly/stats/detail/BufferedStat.h:151,
                       from folly/stats/QuantileEstimator.h:20,
                       from folly/stats/QuantileEstimator.cpp:17:
      folly/stats/detail/BufferedStat-inl.h: In member function 'void folly::detail::BufferedStat<DigestT, ClockT>::doUpdate(folly::detail::BufferedStat<DigestT, ClockT>::TimePoint, const std::unique_lock<folly::SharedMutexImpl<false> >&, folly::detail::BufferedStat<DigestT, ClockT>::UpdateMode)':
      folly/stats/detail/BufferedStat-inl.h:72:3: error: there are no arguments to 'DCHECK' that depend on a template parameter, so a declaration of 'DCHECK' must be available [-fpermissive]
         72 |   DCHECK(g.owns_lock());
            |   ^~~~~~
      ```
      
      My best guess is some kind of argument dependent lookup complication.
      
      This diff sidesteps the issue by using plain old `assert()` instead
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24375147
      
      fbshipit-source-id: d702d883fcabc548e8f4969207e265abf21acf2b
      81e350e1
    • Dan Melnic's avatar
      AsyncUDPSocket: use actual controllen size instead of max · a07ea58a
      Dan Melnic authored
      Summary: AsyncUDPSocket: use actual controllen size instead of max
      
      Reviewed By: danobi
      
      Differential Revision: D24368739
      
      fbshipit-source-id: 0c1083a058d8fe0ddc212989a262f3eeebfa610c
      a07ea58a
    • Lukas Piatkowski's avatar
      rust/shed/hostname: rename hostname dependency to unbreak doctests (#15) · 1d8b0ebc
      Lukas Piatkowski authored
      Summary:
      Pull Request resolved: https://github.com/facebookexperimental/rust-shed/pull/15
      
      With the update from rustc 1.44 to 1.47 the doctests started to break when building a crate that depends on a different crate of the same name, see this: https://github.com/rust-lang/cargo/issues/6819
      
      This diff also removes the TravisCI build as it was broken and unused for some time.
      
      Reviewed By: krallin
      
      Differential Revision: D24390815
      
      fbshipit-source-id: fa9c78ef394640afbf8c419f8276bbf339960406
      1d8b0ebc
    • generatedunixname89002005325676's avatar
      Daily `arc lint --take CLANGFORMAT` · 6cc4b27d
      generatedunixname89002005325676 authored
      Reviewed By: zertosh
      
      Differential Revision: D24388883
      
      fbshipit-source-id: 6bba618c6a919cd3947d2a65954feff989bb80a2
      6cc4b27d
  11. 18 Oct, 2020 1 commit
    • Richard Barnes's avatar
      Add `midpoint()` calculation to folly · 430aa0d8
      Richard Barnes authored
      Summary:
      A number of libraries at Facebook include interval midpoint calculations; however, doing these in a mathematically precise way (without over/underflow) can be tricky. Doing them wrong can break binary searches over large datasets and give imprecise floating-point calculations.
      
      This function provides an early opportunity to fix binary searches and other calculations which can later be updated to `std::midpoint()` when C++20 becomes available.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23997097
      
      fbshipit-source-id: 373e0dc1d1ff071f697ee782be46fb0d49a2f8f7
      430aa0d8
  12. 17 Oct, 2020 1 commit
    • Xavier Deguillard's avatar
      logging: fix prefix stripping on Windows · 9db54edd
      Xavier Deguillard authored
      Summary:
      Windows paths can both use forward slashes as well as backslashes, and also
      contain colons that folly uses to separate prefixes to strip.
      
      The xlogStripFilename unfortunately didn't handle both of these cases leading
      to log categories to always contain the full path instead of a suffix path.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24353208
      
      fbshipit-source-id: ff17afe4b46f36d46bf468a5e3cf9ba9ba8412b8
      9db54edd
  13. 16 Oct, 2020 2 commits
    • Robin Cheng's avatar
      Relax the stack trace limit for opt mode too. · 308bab0e
      Robin Cheng authored
      Summary:
      Similar to D24179337 (https://github.com/facebook/folly/commit/7cc28784d1749283b7eb78399a0f0a77594dbc14).
      
      Though I'm not actually sure what's causing the increase... maybe the right thing to do is the debug the underlying cause, but I'm also not sure how to debug this exactly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24353676
      
      fbshipit-source-id: 12bc5eae939f95d8d091280dc5b5af638f0152a0
      308bab0e
    • Xavier Deguillard's avatar
      HazptrDomain: fix MSVC truncation warning · 2b5dedea
      Xavier Deguillard authored
      Summary:
      The MSVC compiler complains about truncation of size_t to int:
      
        Z:\installed\folly\include\folly/synchronization/HazptrDomain.h(210): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
      
      MSVC being very verbose, this is followed by 25 lines of template expansion.
      
      Since `shard` is a size_t due to `calc_shard` returning that type, let's simply
      make the shard argument of hazptr_warning_list_too_large a size_t too to
      silence the warning.
      
      Reviewed By: magedm
      
      Differential Revision: D24365556
      
      fbshipit-source-id: b426cee7caaf593eb112691bc45b83e564342b0e
      2b5dedea