1. 22 Nov, 2019 5 commits
    • Adam Simpkins's avatar
      getdeps: remove the fb-mercurial-rust target · 58fc256b
      Adam Simpkins authored
      Summary:
      Remove the standalone fb-mercurial-rust target that was an internal-only
      dependency for the Eden build.  This build step is now done entirely in the
      Eden build.
      
      Reviewed By: fanzeyi
      
      Differential Revision: D18623943
      
      fbshipit-source-id: c62a1155ddd1c0a6b2270c472176ba25194c6145
      58fc256b
    • Robin Battey's avatar
      added "info fibers" command · 62e82322
      Robin Battey authored
      Summary:
      Re-implementation of fiber gdb integration.  All previous functionality still works as well.
      
      Commands:
      * `fiber`: switch to fiber by address, alias, or assigned short id
      * `fiber apply`: run arbitrary gdb commands for each specified fiber (or "all")
      * `fiber deactivate`: switch back to normal thread behavior
      * `fiber name`: assign or clear an alias to a particular fiber
      * `info fibers`: print out each fiber manager and fiber, with ids and current frame info
      
      Parameters:
      * `fiber info-frame-skip-words`: the "uninteresting" function matches to skip frames of when showing fiber info
      * `fiber manager-print-limit`: limit of the number of fibers displayed when printing a fiber manager
      
      Fibers are assigned ids of the form "<MANAGER_ID>.<FIBER_ID>".  When specifying fibers for `info fibers` or `fiber apply`, you can specify any number of space-separated fiber ids, and additionally you can specify a manager id by itself to refer to all fibers in that manager.
      
      When printing info with `info fibers`, every stopped fiber will be in `folly::fibers::FiberImpl::deactivate()`, which isn't particularly useful.  To give more-useful information, it will skip past all frames whose function names include the strings "folly::fibers" or "wait" and print the first non-matching frame's information instead.  The `fiber info-frame-skip-words` parameter defines the strings to match on, specified as a space-separated list of words.
      
      Due to gdb limitations, the selecting a fiber "masks" the currently selected thread, and to see the current thread again you will need to run `fiber deactivate`, same as before.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D18342802
      
      fbshipit-source-id: 5b2204bb09eca4c8f977c6c17b0348e39465dff6
      62e82322
    • Koray Polat's avatar
      Add SAI-1.4.0 to opensource build · e375f666
      Koray Polat authored
      Summary:
      - Added sai to getdeps
      - added SAI to FBOSS as a dependency
      - Included path of SAI headers to FBOSS's cmake file.
      
      Reviewed By: shri-khare
      
      Differential Revision: D18629127
      
      fbshipit-source-id: 119a6b7f2b64bd84414d9e16a903bc8df48a35e7
      e375f666
    • Lee Howes's avatar
      Add new immutable global CPU executor that is guaranteed to not be changed. · 3c383a2d
      Lee Howes authored
      Summary:
      The mutable global executor is problematic: it defaults to Inline, and it is constructed off of an error-prone weak_ptr and it returns a shared_ptr. A KeepAlive-based global immutable executor is a cleaner default.
      
      This change adds immutable global executors, and moves the default executors into separate singletons for cleaner interaction between the mutable executor and the underlying default immutable ones, including the default inline global cpu executor.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D18513433
      
      fbshipit-source-id: 0ad825c34cc7ba935f57ff81adb8cff3bf001a45
      3c383a2d
    • Dennis Zhou's avatar
      jemalloc: touch backing pages for JemallocHugePageAllocator · 7f4492d6
      Dennis Zhou authored
      Summary:
      With THP set to madvise, page faults on these pages will block until a
      huge page is found to service it. However, if memory becomes fragmented
      before these pages are touched, then we end up blocking for kcompactd to
      make a page available. As this increase pressure, oomd comes in and kills
      us :(. So, preemptively touch these pages to get them backed as early as
      possible to prevent stalling due to no available huge pages.
      
      Reviewed By: hnaz, interwq
      
      Differential Revision: D18579722
      
      fbshipit-source-id: 5f54676a128207026cb16b9cdc03a055cbb1f9b9
      7f4492d6
  2. 21 Nov, 2019 4 commits
    • Banit Agrawal's avatar
      Never decay the huge pages in JEMalloc · 9113678d
      Banit Agrawal authored
      Summary: This diff disables the purging of huge pages and hence they will never be freed and will be counted towards the RSS of the process. This was done to ensure that we don't block on madvise call to get the huge pages and increase memory pressure on the system.
      
      Reviewed By: gdankel
      
      Differential Revision: D18607196
      
      fbshipit-source-id: 79e483a715290fdfbdd1963433ec3918561a0e0e
      9113678d
    • Aaron Dierking's avatar
      Rename LockTraits.h invokers to work around Clang 7 issue · 6a47d8fb
      Aaron Dierking authored
      Summary:
      Clang 7 seems to have trouble with `FOLLY_CREATE_MEMBER_INVOKER()` on Windows targets if the invoker's name is the same as the invocable name. It's spewing `-Wmicrosoft-explicit-constructor-call` warnings and the `static_assert`s in LockTraits.h are failing. As a workaround, we can rename the LockTraits.h invokers to use an `_invoker` suffix.
      
      See https://gcc.godbolt.org/z/j4qRd9 for a demonstration of the issue.
      
      Reviewed By: vitaut
      
      Differential Revision: D18626335
      
      fbshipit-source-id: c9147daaa10b02b0692c32963f9ede8cc645e329
      6a47d8fb
    • Adam Simpkins's avatar
      getdeps: update eden dependencies · 8f815149
      Adam Simpkins authored
      Summary:
      Include tools/lfs in the shipit path map for now, since it is needed to
      download vendored Rust crates on internal builds.  Also correctly indicate
      that the fb-mercurial* dependencies also apply only to internal builds.
      
      Reviewed By: chadaustin
      
      Differential Revision: D18621421
      
      fbshipit-source-id: 74f00bf318ff9aefdca8696a61a8f33587749e66
      8f815149
    • Adam Simpkins's avatar
      getdeps: automatically detect if a build appears to be Facebook-internal · c951878f
      Adam Simpkins authored
      Summary:
      Automatically detect the `--facebook-internal` flag based on the current
      repository project name.
      
      Reviewed By: wez
      
      Differential Revision: D18621358
      
      fbshipit-source-id: f2b3018169b151811eec455863a8bfc17667d4d8
      c951878f
  3. 20 Nov, 2019 5 commits
    • Sasha Elaine Fox's avatar
      Add instructions for installiing fmt from source (#1263) · 352c2d8b
      Sasha Elaine Fox authored
      Summary:
      Dovetailing off of https://github.com/facebook/folly/issues/1262 ; Folly's dependency on `fmt` isn't explicitly mentioned nor are from-source install instructions provided. This PR adds a short section to the README describing how to build and install fmt from source.
      Pull Request resolved: https://github.com/facebook/folly/pull/1263
      
      Reviewed By: vitaut
      
      Differential Revision: D18622693
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: e43ab8c5524df9decc79cdd0cb2aea3d88826617
      352c2d8b
    • generatedunixname89002005287564's avatar
      Remove dead includes in folly/lang · 4a7bb8ed
      generatedunixname89002005287564 authored
      Reviewed By: yfeldblum
      
      Differential Revision: D18614792
      
      fbshipit-source-id: 9b77ae8aba9153c9051dd5935cda807dfad4e6e2
      4a7bb8ed
    • Yedidya Feldblum's avatar
      FOLLY_CREATE_STATIC_MEMBER_INVOKER · d5cfc736
      Yedidya Feldblum authored
      Summary: [Folly] `FOLLY_CREATE_STATIC_MEMBER_INVOKER`, for creating invoker types which can invoke class static members.
      
      Reviewed By: vitaut
      
      Differential Revision: D18035183
      
      fbshipit-source-id: 2bcab988f684042b26843d5fe0a13ad7c549e43a
      d5cfc736
    • Giuseppe Ottaviano's avatar
      Reimplement EliasFanoReader::{jump,jumpTo} in terms of {skip, skipTo} · a0776ffe
      Giuseppe Ottaviano authored
      Summary:
      Since D18140137 `reset()` doesn't perform any data reads, so we can simplify the implementation of the `jump*` functions to just reset the reader in case of a backward jump. The only tricky case we need to handle is when `jumpTo` is called from the middle of a run of identical values.
      
      Delegating to `skip*` the additional benefit of inheriting the optimizations for small forward skips.
      
      Differential Revision: D18496743
      
      fbshipit-source-id: 73dc8b21534fba90f1ac2a924a7cebc56ffaba94
      a0776ffe
    • Yedidya Feldblum's avatar
      to_narrow · 60923bd6
      Yedidya Feldblum authored
      Summary: [Folly] `to_narrow`, for explicitly performing a possibly-narrowing integral conversion without specifying the destination type. Does not permit changing signs.
      
      Reviewed By: luciang
      
      Differential Revision: D18498269
      
      fbshipit-source-id: be597daf981376758effa0b3721cad67a49c9ef1
      60923bd6
  4. 19 Nov, 2019 6 commits
    • Constantin Dolghier's avatar
      Make semantically-const methods in SharedPromise const · 547f5abf
      Constantin Dolghier authored
      Summary:
      1) SharedPromise is semantically a regular Promise one can get multiple Futures off. One would expect that all methods which are const in Promise to also be const in SharedPromise - but they are not because their implementations needs using a mutex.
      2) Semantically, `SharedPromise::getFuture()` and `SharedPromise::getSemiFuture()` do not change the observable state of the object.
      3) As real-life consequence,  these non-const `SharedPromise` methods become viral in downstream code which then has to hack around it in downstream `const` methods by marking the SharedPromise instance mutable. That solution leads to the program being less const-correct than it should be, as now the type system allows `const` methods to reassign or `setValue` the SharedPromise.
      
      This diff changes `hasResult`, `isFulfilled`, `size()`, `getFuture()` and `getSemiFuture()` to be `const`. In order to achieve that, the private fields `mutex_` and `size_` had to be marked `mutable`.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D18565877
      
      fbshipit-source-id: ff63a48c02235f72c5b0191423ae68f7b7c42fb3
      547f5abf
    • Adam Simpkins's avatar
      getdeps: update FBPythonBinary.cmake to generate executable files on Windows · c2bab5e5
      Adam Simpkins authored
      Summary:
      On Windows, compile a small C executable to prepend to the zip file, to allow
      the resulting executable files to be run directly on Windows, without needing
      to explicitly invoke the Python interpreter to run the output file.
      
      Reviewed By: wez
      
      Differential Revision: D17733616
      
      fbshipit-source-id: 989a93851412d0bbe1e7857aa9111db082f67a4c
      c2bab5e5
    • generatedunixname89002005287564's avatar
      Remove dead includes in folly/container · 385acc50
      generatedunixname89002005287564 authored
      Reviewed By: yfeldblum
      
      Differential Revision: D18449687
      
      fbshipit-source-id: 6d630cef35132abb157e80d02ad2b6dee7268fce
      385acc50
    • Jason Rahman's avatar
      Add value_or to optional.pxd · cd30e62e
      Jason Rahman authored
      Summary: Expose the call to folly::Optional::value_or() in the Cython bindings
      
      Reviewed By: nanshu
      
      Differential Revision: D18526111
      
      fbshipit-source-id: f2694ca589bf73653bc86d5c98b52e15406bed77
      cd30e62e
    • Jason Rahman's avatar
      Add folly::Function cython wrapper · 6fdd1b5b
      Jason Rahman authored
      Summary:
      Add basic wrapper to support wrapping C++ APIs that contain
      folly::Function in their interfaces. Does not support calling operator() from
      within Cython, but only pass through of folly::Function<> to such APIs.
      
      Reviewed By: nanshu
      
      Differential Revision: D18526112
      
      fbshipit-source-id: d219d480e59464099a109e5ef30d015151588b1f
      6fdd1b5b
    • Jason Rahman's avatar
      Add folly::Expected cython wrapper · 47403093
      Jason Rahman authored
      Summary:
      Add new cython wrapper class to expose folly::Expected to other
      cython_libraries
      
      Reviewed By: jkedgar
      
      Differential Revision: D18523642
      
      fbshipit-source-id: 0dfb4820b2613361b7c1af05b89b5231a1bfecbc
      47403093
  5. 18 Nov, 2019 2 commits
    • Giuseppe Ottaviano's avatar
      Document and test some EliasFanoCoding corner cases · 2c464254
      Giuseppe Ottaviano authored
      Summary:
      EliasFanoCoding supports sequences with duplicate values, but there is no test coverage and the behavior of some corner cases (`skipTo` and `jumpTo` from the middle of a run) is not documented.
      
      This diff adds coverage and documentation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D18496744
      
      fbshipit-source-id: 00e112a902a8b11ac9601520b858172a1d2c0f57
      2c464254
    • Victor Zverovich's avatar
      Replace Folly Format with fmt in logger to reduce binary size · da41ae50
      Victor Zverovich authored
      Summary:
      Now that fmt is available in Folly builds (D14813810), use it to reduce binary code size in Folly Logger. This is done by moving most of the formatting logic behind the type-erased `vformat` API. Previously it was instantiated for all combinations of formatting argument types used in calls to `FB_LOGF` and `XLOGF` in a program.
      
      The effect of this change can be illustrated by looking at symbol sizes as given by `nm -S -td` for the following test function:
      
      ```
      void test_log() {
        FB_LOGF(logger, WARN, "num events: {:06d}, duration: {:6.3f}", 1234, 5.6789);
      }
      ```
      compiled in `opt` mode.
      
      `nm` before:
      
      ```
      0000000004236736 0000000000000231 T test_log()
      0000000004236992 0000000000001002 W std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > folly::LogStreamProcessor::formatLogString<int, double>(folly::Range<char const*>, int const&, double const&)
      ```
      
      `nm` after:
      
      ```
      0000000004237536 0000000000000231 T test_log()
      0000000004237792 0000000000000251 W std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > folly::LogStreamProcessor::formatLogString<int, double>(folly::Range<char const*>, int const&, double const&)
      0000000004238048 0000000000000740 W folly::LogStreamProcessor::vformatLogString[abi:cxx11](folly::Range<char const*>, fmt::v5::format_args, bool&)
      ```
      
      Before we had one 1002 byte instantiation of `formatLogString<int, double>`. With this change it was reduced 4x to 251 bytes and non-template function `vformatLogString` was added which is shared among all logging calls. The size of `test_log` remained unchanged. There are even bigger savings from Folly Formatter instantiations which are no longer needed, e.g.
      
      ```
      0000000004238032 0000000000001363 W _ZNK5folly13BaseFormatterINS_9FormatterILb0EJRKiRKdEEELb0EJS3_S5_EEclIZNKS7_8appendToINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENSt9enable_ifIXsr12IsSomeStringIT_EE5valueEvE4typeERSH_EUlNS_5RangeIPKcEEE_EEvSK_
      ```
      
      So in total this change results in ~5x per-call/instantiation binary size. It is possible to reduce binary size even further but it is not done in the current diff to keep it manageable.
      
      In addition to binary size improvements, switching to fmt will potentially
      
      * allow catching errors in format strings at compile time,
      * simplify future migration to C++20 [`std::format`](http://eel.is/c++draft/format).
      
      Reviewed By: simpkins
      
      Differential Revision: D15485589
      
      fbshipit-source-id: 06db4436839f11c2c3dbed7b36658e2193343411
      da41ae50
  6. 17 Nov, 2019 1 commit
    • Wez Furlong's avatar
      getdeps: fix node/yarn detection for watchman builds · 8e0ca467
      Wez Furlong authored
      Summary:
      When we detect that we are building out of the fbsource
      monorepo internal to FB, pre-set some environment variables to help
      projects detect our internally pinned versions of node and yarn.
      
      Previously, the detection logic was deciding that the `yarn` shell
      script was the executable to invoke, but since that is a bash script
      it would fail to spawn.
      
      Reviewed By: simpkins
      
      Differential Revision: D18523871
      
      fbshipit-source-id: b932d2b0ccd7b79d6f9cd74d363bc426c288e38f
      8e0ca467
  7. 16 Nov, 2019 2 commits
  8. 15 Nov, 2019 6 commits
    • generatedunixname89002005287564's avatar
      Remove dead includes in folly/executors · 789882d5
      generatedunixname89002005287564 authored
      Reviewed By: yfeldblum
      
      Differential Revision: D18528940
      
      fbshipit-source-id: 288abb510535540698416ac046c1057e110e4478
      789882d5
    • Yedidya Feldblum's avatar
      Erase the invokers · 02fb0302
      Yedidya Feldblum authored
      Summary: [Folly] Erase the invokers. A catchy title, but forcibly inline the invoker call operators.
      
      Reviewed By: vitaut
      
      Differential Revision: D18035184
      
      fbshipit-source-id: 5cf57d785523904a5260f7ed24c9ed34148370eb
      02fb0302
    • Yedidya Feldblum's avatar
      Fix possible segv in Function shared proxy · 1bb7c1fb
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix possible segv in `Function` shared proxy when invoking the (public!) `nullptr`-taking ctor.
      
      This proxy is used when converting `folly::Function` to `std::function` with shared state.
      
      Reviewed By: ot
      
      Differential Revision: D18517365
      
      fbshipit-source-id: c414c1d1ae2b4f30ffa3269b216be07fedbf838c
      1bb7c1fb
    • Yedidya Feldblum's avatar
      Avoid overloading other names from within detail namespaces · c9bd77f1
      Yedidya Feldblum authored
      Summary: [Folly] Avoid overloading other names from within detail namespaces - prefer renaming or at least mangling.
      
      Reviewed By: Orvid
      
      Differential Revision: D18502700
      
      fbshipit-source-id: a4f455db69396962b298c6291929f1eb152e1576
      c9bd77f1
    • Rosen Penev's avatar
      Asm: pause under MIPS as well (#1257) · 6f5a64d6
      Rosen Penev authored
      Summary:
      The instruction is identical to the x86 one. First introduced in MIPS32r2.
      Signed-off-by: default avatarRosen Penev <rosenp@gmail.com>
      Pull Request resolved: https://github.com/facebook/folly/pull/1257
      
      Reviewed By: Orvid
      
      Differential Revision: D18467031
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 04b695167184db8ef71df47e82e414793ddb0ab9
      6f5a64d6
    • Yedidya Feldblum's avatar
      FOLLY_CREATE_FREE_INVOKER, FOLLY_CREATE_MEMBER_INVOKER · 808c845b
      Yedidya Feldblum authored
      Summary:
      [Folly] `FOLLY_CREATE_FREE_INVOKER` and `FOLLY_CREATE_MEMBER_INVOKER` to replace `FOLLY_CREATE_FREE_INVOKE_TRAITS` and `FOLLY_CREATE_MEMBER_INVOKE_TRAITS`.
      
      New approach: just emit an invoker object. For the traits, just use the normal traits instead of rewriting them, or use `invoke_traits` to get an invoke-traits type specialized to the invoker.
      
      Reviewed By: vitaut
      
      Differential Revision: D18079121
      
      fbshipit-source-id: 8258c36b8ba6ee62a8ecc104cd1b6281d313960f
      808c845b
  9. 14 Nov, 2019 4 commits
    • Rosen Penev's avatar
      Use auto where appropriate (#1256) · 3de8f357
      Rosen Penev authored
      Summary:
      Found with modernize-use-auto
      Signed-off-by: default avatarRosen Penev <rosenp@gmail.com>
      Pull Request resolved: https://github.com/facebook/folly/pull/1256
      
      Reviewed By: Orvid
      
      Differential Revision: D18421629
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: c49418a3b3413acd1506c550af44c806332eedb8
      3de8f357
    • Maged Michael's avatar
      hazptr: Support obj batch bypass to domain · 99b49e47
      Maged Michael authored
      Summary:
      This diff adds support for optionally setting an obj batch such that objects retired to the batch bypass the batch and are directly pushed to the domain.
      This is useful in cases where the benefits of earlier reclamation outweigh the benefits of amortizing the cost of pushing objects to the domain.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D18114444
      
      fbshipit-source-id: a1af88dfa1b601827b2f71e700fb1dfcb08e513c
      99b49e47
    • Dan Melnic's avatar
      Fix -Wshorten-64-to-32 compile warning treated as error · c31d1330
      Dan Melnic authored
      Summary:
      Fix -Wshorten-64-to-32 compile warning treated as error
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: nbronson
      
      Differential Revision: D18493255
      
      fbshipit-source-id: 10a2a576c7f587d02a61860285171f2c5f0534ad
      c31d1330
    • Phil Willoughby's avatar
      add a message propagation barrier · cd7a67ad
      Phil Willoughby authored
      Summary:
      Allows a category to be configured to selectively propagate messages to its parent category.
      
      I preferred this over a simple `true`/`false` filter because it can be useful to have one log file for all DBG logs from a component while still limiting it to `INFO` or whatever in the main application log file.
      
      Reviewed By: simpkins
      
      Differential Revision: D18360804
      
      fbshipit-source-id: a45098c81fdc8b984e440748880e8943df95acd2
      cd7a67ad
  10. 13 Nov, 2019 3 commits
    • Maged Michael's avatar
      hazptr: Allow destruction of obj batch after default domain · 9feea971
      Maged Michael authored
      Summary:
      Allow hazptr_obj_batch-es to outlive the default domain.
      
      Background: Until now it was expected that batches are destructed before the destruction of the default domain. This may be restrictive to good use cases.
      
      This diff removes the above mentioned restriction and gives hazptr_obj_batch::shutdown_and_reclaim() to decide whether or not to access the default domain by supporting a singleton bool in default_hazptr_domain_alive() that could be made to outlive the default domain by calling that function before constructing the user object that may outlive the default domain.
      
      Reviewed By: aary
      
      Differential Revision: D18297698
      
      fbshipit-source-id: 6021479ab36ce86d2c411fd71974fde47f7502a2
      9feea971
    • Eric Niebler's avatar
      permit `co_return {};` in a coro::Task<T>-returning coroutine to default-construct a T · ddf4beb9
      Eric Niebler authored
      Summary: In a coroutine returning a `coro::Task<T>`, make `co_return {};` return a default-constructed `T` rather than a default-constructed `folly::Try`.
      
      Reviewed By: yfeldblum, andriigrynenko
      
      Differential Revision: D18466785
      
      fbshipit-source-id: ed20f0f5ad98a0ef8e693e490417a7e36f706822
      ddf4beb9
    • Orvid King's avatar
      Support newer CRT versions for the portibility shims · 67c9b092
      Orvid King authored
      Summary: Newer CRT versions have changed how certain definitions were gated, so we need to update to support them.
      
      Reviewed By: akrieger, guangyfb
      
      Differential Revision: D18435320
      
      fbshipit-source-id: 40ffc57ed1fe0ad1b01ab834aed9762bde5563cb
      67c9b092
  11. 12 Nov, 2019 2 commits