1. 10 Apr, 2021 1 commit
    • Andrii Grynenko's avatar
      Fix a shutdown race in CPUThreadPoolExecutor::add · b91dd2f6
      Andrii Grynenko authored
      Summary:
      It's not safe to expect that the executor is alive after a task is added to the queue (this task could be holding the last KeepAlive and when finished - it may unblock the executor shutdown).
      The fix is to hold a KeepAlive if some operation has to be done after adding to the queue. However it's safe to avoid this in a case where executor thread count will never drop below 1 (otherwise not having active threads may result in a deadlock) and we already have the maximum number of threads running. This optimization should help avoid grabbing the KeepAlive on the fast path.
      
      Differential Revision: D27584518
      
      fbshipit-source-id: e1242e3f4c40cee4f7e0c6dfca39abe6d17415f1
      b91dd2f6
  2. 09 Apr, 2021 4 commits
    • Parvez Shaikh's avatar
      get rid of hack to support label attribute for 1.7.0 · 7c4413da
      Parvez Shaikh authored
      Summary:
      as titled, an ugly hack to support LABEL attribute for 1.7.0 which didn't exist.
      
      getting rid of it now since oss support upgraded to 1.7.1
      
      Differential Revision: D27536730
      
      fbshipit-source-id: 58653e71cbf20a1cda0b7414f66b5f0014d89b84
      7c4413da
    • Alexander Sklar's avatar
      Conditionally include fmt/format.h (#1551) · 3d0ae974
      Alexander Sklar authored
      Summary:
      Addresses - at least partly - issue https://github.com/facebook/folly/issues/1550
      
      We'd like to limit our exposure to additional libraries. Fmt is a new dependency. It doesn't look like we need it in actuality; gating the include based on whether the file exists or not makes it possible for clients (specifically React Native for Windows) to not need to fork Folly.
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1551
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27531237
      
      Pulled By: Orvid
      
      fbshipit-source-id: 340a7ff49be81872aaf23044945a1e8ecd157546
      3d0ae974
    • Giuseppe Ottaviano's avatar
      Add a function to check if the process is in crashing · dced0133
      Giuseppe Ottaviano authored
      Summary:
      This can be used to avoid noisy logging if the process is in the middle of a crash: symbolizing the stack trace can take a long time, so we can end up interleaving the crash report with unrelated logs.
      
      In particular, we can use this to guard monitoring code that is more likely to trip while the process is crashing (for example stall detectors).
      
      Reviewed By: yfeldblum, philippv, luciang
      
      Differential Revision: D27663380
      
      fbshipit-source-id: e3bb40292c3c57579b3eb172847ca089b0f9b07a
      dced0133
    • Yedidya Feldblum's avatar
      revert AccessSpreader thread-local and extern-template-struct · 6902012a
      Yedidya Feldblum authored
      Summary: They are observed to trigger pathological behavior.
      
      Differential Revision: D27659117
      
      fbshipit-source-id: 5e4e770e61ffde02075364f2247614cf5bbcf8ce
      6902012a
  3. 08 Apr, 2021 1 commit
  4. 07 Apr, 2021 3 commits
    • Genevieve Helsel's avatar
      flag manual import so autodeps won't add symbolizer to default init deps · eb3f0d20
      Genevieve Helsel authored
      Summary: as title, marking this import as manual will make it so autodeps won't double list it in the TARGETS file.
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D27418310
      
      fbshipit-source-id: 0c32ff1ad0ad7997a83b050f7fe3cdc522f582cc
      eb3f0d20
    • Seth Hinze's avatar
      Add ability to specify an offset to IOBuf::takeOwnership · c09d7af4
      Seth Hinze authored
      Summary: Allow callers to `IOBuf::takeOwnership()` to specify valid data in the middle of the underlying buffer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27583632
      
      fbshipit-source-id: 4651dec5e53c5eea341b2b4ad3782adfbe7ff779
      c09d7af4
    • Yedidya Feldblum's avatar
      excise AccessSpreader extern-template-struct · 67c99b13
      Yedidya Feldblum authored
      Summary:
      There appear always to be problems with `extern template struct`. In this case, some compilers either not emitting or dropping thread-local wrapper functions.
      
      ```
      stderr: Undefined symbols for architecture x86_64:
        "thread-local wrapper routine for folly::AccessSpreader<std::__1::atomic>::cpuCache", referenced from:
            folly::AccessSpreader<std::__1::atomic>::cachedCurrent(unsigned long) in CacheLocality.cpp.o
        "thread-local wrapper routine for folly::SequentialThreadId<std::__1::atomic>::currentId", referenced from:
            folly::SequentialThreadId<std::__1::atomic>::get() in CacheLocality.cpp.o
      ld: symbol(s) not found for architecture x86_64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      ```
      
      Reviewed By: Mizuchi
      
      Differential Revision: D27579816
      
      fbshipit-source-id: b539816fb1f62d9e50e22d6cbc3c91a0d82ac629
      67c99b13
  5. 06 Apr, 2021 4 commits
    • Yedidya Feldblum's avatar
      outline AccessSpreader::initialize · ad41ba19
      Yedidya Feldblum authored
      Summary: Extract its content to an outline function and pass it the template immediates it needs.
      
      Reviewed By: Mizuchi
      
      Differential Revision: D27579474
      
      fbshipit-source-id: 193c769d83f886b4fefea4a34118c44f7da08bd1
      ad41ba19
    • Genevieve Helsel's avatar
      make libunwind portability header · b98c937c
      Genevieve Helsel authored
      Summary: Adds a portability header for later ease of use when deciding to include external_deps libunwind in TARGETS files
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27416623
      
      fbshipit-source-id: fc42f010302b8caa280fdf5cbdf013ed1b23af04
      b98c937c
    • Yedidya Feldblum's avatar
      let to_ascii_port_clzll always return non-void · 54c929bc
      Yedidya Feldblum authored
      Summary: Required for msvc 32-bit builds - the result of `to_ascii_port_clzll` is used in an arithmetic expression.
      
      Reviewed By: SarahDesouky, Orvid
      
      Differential Revision: D27585004
      
      fbshipit-source-id: b84b5b6d6fe417f3c6adafcaf826505275aa827c
      54c929bc
    • Alan Huang's avatar
      revert default value of flag folly_memory_idler_purge_arenas · 897fd4bf
      Alan Huang authored
      Reviewed By: yfeldblum
      
      Differential Revision: D27575037
      
      fbshipit-source-id: fa5817ee3fe1eca99e83f26a13e43ec4a4a6e7cf
      897fd4bf
  6. 05 Apr, 2021 3 commits
    • Andrii Grynenko's avatar
      Make getWeakRef preserve SequencedExecutor tag · 2ff21656
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D27253836
      
      fbshipit-source-id: a72531e0deca9f0f6582339d483ed56f2eb37d87
      2ff21656
    • Seth Hinze's avatar
      Validate IOBuf capacity at construction time · 355fec90
      Seth Hinze authored
      Summary: Add a CHECK() to the IOBuf constructor to ensure the underlying buffer does not include any bytes that have been poisoned by AddressSanitizer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D25627483
      
      fbshipit-source-id: 5bca59e545c32ba7b61430d7cd4787712eecb204
      355fec90
    • Yedidya Feldblum's avatar
      avoid FOLLY_TLS in tests · 71255360
      Yedidya Feldblum authored
      Reviewed By: Orvid
      
      Differential Revision: D27559344
      
      fbshipit-source-id: cf90be5a19da87bffe72fb6646296dd46889bc90
      71255360
  7. 04 Apr, 2021 2 commits
    • Stiopa Koltsov's avatar
      File::dupCloseOnExec() · 1af19a96
      Stiopa Koltsov authored
      Summary:
      Close-on-exec is an important feature to avoid leaking file descriptors to spawned processes.
      
      This diff adds `File::dupCloseOnExec()` function which is equivalent to `File::dup` function, but sets close-on-exec flag where supported (i. e. everywhere except Windows).
      
      Practically most users want to have `closeOnExec = true` by default, but we need to preserve backwards compatibility, thus this diff leaves `dup` function as is.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27495214
      
      fbshipit-source-id: 540deb2bc6c8fec626a0120bc20c345950dc8af7
      1af19a96
    • Yedidya Feldblum's avatar
      support disabling tests in cmake under apple · 03fa494f
      Yedidya Feldblum authored
      Reviewed By: Orvid
      
      Differential Revision: D27555992
      
      fbshipit-source-id: d68dc183f7c7b7c64975ede21e6f3018575fb7c9
      03fa494f
  8. 03 Apr, 2021 4 commits
    • Yedidya Feldblum's avatar
      multiple tags per test in cmake build · 4033d186
      Yedidya Feldblum authored
      Reviewed By: Orvid
      
      Differential Revision: D27537202
      
      fbshipit-source-id: d1aa8ad81f3749129dd6f1795e788a0e55d9f06a
      4033d186
    • Yedidya Feldblum's avatar
      avoid forcing the type of clzll · c841c365
      Yedidya Feldblum authored
      Summary: Between gnu and msvc compilers, the builtins and intrinsics `__builtin_clzll` and `__lzcnt64` have different return types. They are wrapped in a portability function in `to_ascii` which currently forces a return type, which return type could trip implicit-conversion warnings. Avoid forcing the return type to avoid tripping implicit-conversion warnings.
      
      Reviewed By: luciang
      
      Differential Revision: D27535348
      
      fbshipit-source-id: 3339d5d04e095f936c18d2b39ac1fb4b32f8a810
      c841c365
    • Yedidya Feldblum's avatar
      avoid ambiguity in to_ascii_size · 5ef57d70
      Yedidya Feldblum authored
      Summary: The ambiguity is that the name appears as both `folly::to_ascii_size` and `folly::detail::to_ascii_size`, so that anything which imports both `folly` and `folly::detail` or which is within `folly::detail` may, depending on the particular compiler, find an unqualified call ambiguous.
      
      Differential Revision: D27535255
      
      fbshipit-source-id: 05db44e6b153d75b691d67c878785cab1655051d
      5ef57d70
    • Yedidya Feldblum's avatar
      un-monomorphize parts of SingletonRelaxedCounter · 8f802235
      Yedidya Feldblum authored
      Summary: SingletonRelaxedCounter is templated over tag types, but this leads to heavy monomorphization. extract the common code.
      
      Reviewed By: aary
      
      Differential Revision: D27383671
      
      fbshipit-source-id: e419579e4d9ab84b5107670bd1e94e1768dcebf4
      8f802235
  9. 02 Apr, 2021 7 commits
    • Yedidya Feldblum's avatar
      let to_ascii_max and to_ascii_max_decimal be variables · 0a8487bd
      Yedidya Feldblum authored
      Summary: No strict need for them to be functions.
      
      Differential Revision: D27484949
      
      fbshipit-source-id: f0fbc91aa9940720bbd3b685b730acc314bf122d
      0a8487bd
    • Yedidya Feldblum's avatar
      fix the flipped condition in MemoryIdler · db0244ad
      Yedidya Feldblum authored
      Reviewed By: philippv
      
      Differential Revision: D27535007
      
      fbshipit-source-id: 384235553b18320fa9728740f7f1b83b4c8b0a1a
      db0244ad
    • Yedidya Feldblum's avatar
      revise LockFreeRingBuffer::internalBufferLocation doc · ab0952cb
      Yedidya Feldblum authored
      Reviewed By: WillerZ
      
      Differential Revision: D27489039
      
      fbshipit-source-id: 5d397a24fcb165b7ea25e32f0c81435bce474b04
      ab0952cb
    • Seth Hinze's avatar
      Fix linker error with SanitizeAddress.cpp on non-ASAN win32 builds · b3f67e05
      Seth Hinze authored
      Summary:
      Win32 does not support weak symbols.  This means the linker will fail due to the unresolved symbol `__asan_region_is_poisoned` when ASAN is not available.
      Use `FOLLY_CREATE_EXTERN_ACCESSOR` macro when filtering for ASAN availability in `SanitizeAddress.cpp` to ensure the symbol `__asan_region_is_poisoned` is referenced only when ASAN is available.
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D27278826
      
      fbshipit-source-id: 3c8efbfc687295c2fa70e3712402fd8dfe81bc45
      b3f67e05
    • Andrew Sun's avatar
      Allow customizing boost::po::command_line_style in NestedCommandLineApp · 09cc63cb
      Andrew Sun authored
      Summary:
      NestedCommandLineApp works by performing two passes over the argument vector:
      
      1. Treat the entire argv as a single command, ignoring subcommands. Consume all options that "match" a global flag here.
      
      2. Find the first positional argument in argv and treat it as a subcommand, then re-parse everything after it as options to the subcommand.
      
      This allows constructs like `cli subcommand --subcommand-flag --global-flag`. However, as a side effect, if `subcommand-flag` happens to be even a prefix of a global flag name, boost "helpfully" matches it with the global flag in the first pass so that the subcommand never even sees it.
      
      Fixing the issue of a subcommand flag conflicting with a global flag would break backwards compatibility; however, we can at least add an option to disable prefix matching so that there would need to be an exact flag name collision for this scenario to occur. It may be possible to extend NestedCommandLineApp in the future to detect flag collisions as well, instead of silently associating arguments with the wrong flag.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27419341
      
      fbshipit-source-id: 941c0769e16d40c87f96620155f0ab09927cef3d
      09cc63cb
    • Jason Rahman's avatar
      Disable zero copy when performing SSL handshake · 12466d5f
      Jason Rahman authored
      Summary:
      If zero copy starts out enabled on a unencrypted connection, disable
      it when the SSL handshake begins. Otherwise, AsyncSocket will receive send
      notifications for buffers that it did not pre-register.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27145232
      
      fbshipit-source-id: f07d006d095e1e6839eb2f4adb07d7c284786572
      12466d5f
    • Yedidya Feldblum's avatar
      extern access · 916d7d93
      Yedidya Feldblum authored
      Summary: A mechanism to make it easier conditionally to access possibly-defined names, which can be a bit tricky especially without `if constexpr`.
      
      Reviewed By: luciang
      
      Differential Revision: D27434753
      
      fbshipit-source-id: 4c9aaebe89b354aa94f4f370c8fbdc8456b0e7f7
      916d7d93
  10. 01 Apr, 2021 11 commits
    • Zhengxu Chen's avatar
      Fix darwin and hphp build failures for PrimaryPtr. · 6e9d4d69
      Zhengxu Chen authored
      Summary:
      On darwin with Xcode, deleter for a shared_ptr is passed by copying the whole lambda, causing issues when building PrimaryPtr.
      
      In this diff we try to work around this problem by putting the last promise value on the heap while sharing the control block with the shared_ptr exposed to user.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27354087
      
      fbshipit-source-id: 9cb23912c9f1058505f3c20384eb998233eba2da
      6e9d4d69
    • Zhiwei Chen's avatar
      Remove nonexistent path in CMakeLists.txt (#1553) · 056d288f
      Zhiwei Chen authored
      Summary:
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1553
      
      Differential Revision: D27504501
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 291036c64050896d3873271722c84380fd2b3ec7
      Co-authored-by: default avatarZhiwei Chen <condy0919@gmail.com>
      056d288f
    • Yedidya Feldblum's avatar
      a safer to_ascii api · 4fd5a6f2
      Yedidya Feldblum authored
      Summary: Let the `to_ascii` functions take and check the out range, not just the out begin. Add overloads which take arrays.
      
      Reviewed By: WillerZ
      
      Differential Revision: D27484478
      
      fbshipit-source-id: 56a9ba1465204b58d9df018bdae707d39ef6525d
      4fd5a6f2
    • condy's avatar
      Direct initialize semaphoreWaiter (#1554) · 91ef8d68
      condy authored
      Summary:
      Before this patch, it relies on the c++17 guaranteed copy elision, since `SemaphoreBase::Waiter` is NOT copy constructible due to `std::atomic<intptr_t>`.
      
      This patch makes it compile even using `-std=c++14`.
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1554
      
      Differential Revision: D27505938
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 6c26f82f77a24236a1233cff7921cd6b9f53bd09
      91ef8d68
    • Lee Howes's avatar
      Remove dead includes in folly/io · 2fd1e607
      Lee Howes authored
      Reviewed By: yfeldblum
      
      Differential Revision: D27461546
      
      fbshipit-source-id: 500ecd312b0b0ba15db7f373a3b6c7d633802846
      2fd1e607
    • Sandeep Kumar Pani's avatar
      OSS jobs to tpx · 6f1d51be
      Sandeep Kumar Pani authored
      Summary:
      Tpx works well for all OSS jobs, we should migrate to Tpx instead of
      relying testpilot.
      
      Reviewed By: marcelogomez
      
      Differential Revision: D27396539
      
      fbshipit-source-id: dd1994be0eb3b4396764c1f3e68ddd6763b60139
      6f1d51be
    • generatedunixname89002005287564's avatar
      Remove dead includes in folly/hash · 105cc30d
      generatedunixname89002005287564 authored
      Reviewed By: yfeldblum
      
      Differential Revision: D27461452
      
      fbshipit-source-id: 3e46ba71b10aea10d6006c3c6f145377ce6687da
      105cc30d
    • generatedunixname89002005287564's avatar
      Remove dead includes in folly/system · fbf1aff8
      generatedunixname89002005287564 authored
      Reviewed By: yfeldblum
      
      Differential Revision: D27461464
      
      fbshipit-source-id: 53facc1cc42f60ffa3083c12c32352bb78b16280
      fbf1aff8
    • Yedidya Feldblum's avatar
      shrink SingletonRelaxedCounter inline slow path · 85bc0de2
      Yedidya Feldblum authored
      Summary: Persuade the compiler to emit a tail call in the `SingletonRelaxedCounter` inline slow path.
      
      Differential Revision: D27383131
      
      fbshipit-source-id: 6f58b1eb23477c00221515d7d6e55a91668f7c84
      85bc0de2
    • Yedidya Feldblum's avatar
      remove folly::SpinLockGuard · 7426f02a
      Yedidya Feldblum authored
      Summary:
      C++17 permits use of `std::unique_lock` instead of `folly::SpinLockGuard`; just use that.
      
      C++11 permits use of `std::unique_lock<SpinLock>`.
      
      Differential Revision: D27390136
      
      fbshipit-source-id: bcc34a043644289523ddfdfbf47a260c133db186
      7426f02a
    • Andrii Grynenko's avatar
      Don't throw in noexcept ViaIfAsyncAwaiter::await_suspend · e4fb76b6
      Andrii Grynenko authored
      Summary: Avoids warnings with -Wterminate.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27452798
      
      fbshipit-source-id: 129b66179c5ff9bbf3f8fe791224cd925a3b33f3
      e4fb76b6