1. 27 Feb, 2019 4 commits
    • Joe Loser's avatar
      Cut disabling uninitialized warnings in folly/experimental/Bits.h (#1033) · a79183e4
      Joe Loser authored
      Summary:
      - `folly/experimental/Bits.h` has a section where we disable two
        uninitialized-flavors of warnings that were needed for GCC 4.8
      - Since we do not support GCC 4.8 anymore and GCC 5.1 does not have
        issues with this, do not disable the warnings anymore.
      Pull Request resolved: https://github.com/facebook/folly/pull/1033
      
      Reviewed By: Orvid
      
      Differential Revision: D14223285
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 0088341b13e26dff2dc90a768319cccc45e942da
      a79183e4
    • Yedidya Feldblum's avatar
      DefaultKeepAliveExecutor::reset · c971b9f7
      Yedidya Feldblum authored
      Summary: [Folly] `DefaultKeepAliveExecutor::reset` in case of restartable executors.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14236173
      
      fbshipit-source-id: 14f71af6bd54777770fdfe6036a4137af4e884bc
      c971b9f7
    • Yedidya Feldblum's avatar
      Cut deducible template arg in DefaultKeepAliveExecutor init · c2a61864
      Yedidya Feldblum authored
      Summary: [Folly] Cut deducible template arg in `DefaultKeepAliveExecutor` init - let it be deduced instead.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14236171
      
      fbshipit-source-id: 2de043efe541c13c59764715516b08d77efcb99b
      c2a61864
    • Andrii Grynenko's avatar
      Fix a race when a leaf update is missed · bde0b49f
      Andrii Grynenko authored
      Summary:
      If multiple leaves are updated at the same time (or a new observer is created concurrently that depends on the updated leaf) it's possible for refresh to be called concurrently with force=false which will not update the leaf value, but also ignore the refresh with force=true.
      This is fixed by making force to be the property of the leaf observer itself, which is set when the version is bumped.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14222400
      
      fbshipit-source-id: 657c2c273002f576dbe48a232eaef2d530cea07d
      bde0b49f
  2. 26 Feb, 2019 4 commits
    • Ning Xu's avatar
      Surround code snippets with tildes (#1032) · 017cd274
      Ning Xu authored
      Summary:
      Angled brackets inside angled brackets is not displayed.
      This makes the document misleading.
      Pull Request resolved: https://github.com/facebook/folly/pull/1032
      
      Reviewed By: shixiao
      
      Differential Revision: D14207772
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 4f2e58145a5473a7b887ef1da4efbeb16d5330c6
      017cd274
    • Lee Howes's avatar
      Change return type of futures::sleep to SemiFuture · 75d20258
      Lee Howes authored
      Summary:
      futures::sleep returning a Future leads to continuations easily being run on
      the Timekeeper's callback. The goal is to change the return type so that
      futures::sleep returns a folly::SemiFuture.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14069549
      
      fbshipit-source-id: b98e2c76ccbf0a80aed28f90a1f3c63f15eb2e5c
      75d20258
    • Joe Loser's avatar
      Remove disabling -Warray-bounds for GCC in FBString.h (#999) · 268ab2a1
      Joe Loser authored
      Summary:
      - Existing code disables `-Warray-bounds` warning for GCC due to a bug in
        GCC 4.9.
      - As seen in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124, the bug
        has been resolved for GCC 5.1.
      - Since the bug has been resolved, we no longer need to disable the
        warning.
      
      yfeldblum I suspect that we have to hold off on this PR until the internal use cases relying on GCC 4.9 upgrade, but I figured it is better to have some of these cleanup opportunities ready for when the time arises.
      Pull Request resolved: https://github.com/facebook/folly/pull/999
      
      Reviewed By: ot, Orvid
      
      Differential Revision: D13729723
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: da33704c2e2022c2dad0681e4d6152105a1cf54d
      268ab2a1
    • Yedidya Feldblum's avatar
      Address MSVC C4686 in folly/lang/Pretty.h · 6f14ffa5
      Yedidya Feldblum authored
      Summary:
      [Folly] Address MSVC C4686 in `folly/lang/Pretty.h`.
      
      Resolves:
      
      ```
      folly\lang\pretty.h(119): warning C4686: 'folly::detail::pretty_name_zarray<T>::zarray_': possible change in behavior, change in UDT return calling convention
      ```
      
      Reviewed By: Orvid
      
      Differential Revision: D14214290
      
      fbshipit-source-id: c5e0ebd7c100413737bdcba157ec8b5ce42895de
      6f14ffa5
  3. 25 Feb, 2019 8 commits
    • Marc Berenbach's avatar
      Fix unnecessary copy warnings found by Infer · 986a6124
      Marc Berenbach authored
      Summary:
      Infer AL has reported valid warnings on some folly and thrift code:
      
      ```
      fbcode/folly/io/async/AsyncUDPServerSocket.h:228:19:
      WARNING Extra Copy: Potentially unnecessary to copy var `client` at line 228, column 19. Use 'const auto&' or 'auto&' if possible.
      fbcode/folly/io/async/AsyncUDPServerSocket.h:230:19:
      WARNING Extra Copy: Potentially unnecessary to copy var `socket` at line 230, column 19. Use 'const auto&' or 'auto&' if possible.
      fbcode/thrift/lib/cpp/TProcessorEventHandler.h:148:15:
      WARNING Extra Copy: Potentially unnecessary to copy var `ew` at line 148, column 15. Use 'const auto&' or 'auto&' if possible.
      fbcode/thrift/lib/cpp2/server/ThriftServer.h:705:20:
      WARNING Extra Copy: Potentially unnecessary to copy var `sockets` at line 705, column 20. Use 'const auto&' or 'auto&' if possible.
      ```
      
      As these are transitively included in many services, they are fairly prevalent/annoying warnings. Let's fix them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14168260
      
      fbshipit-source-id: 12e537fe5aa73e653c15c4fef01ac618e51cd4d0
      986a6124
    • Joe Loser's avatar
      Add std::string_view specialization in F14Table.h (#1031) · 223aae6b
      Joe Loser authored
      Summary:
      - `F14Table.h`'s fallback when SIMD isn't used has template specializations
        to track which `std::hash` implementations are considered worth caching by
        `std::unordered_map`. This included `std::string` but was missing
        support for `std::string_view`. This commit adds support for marking
       `std::string_view` as not fast.
      Pull Request resolved: https://github.com/facebook/folly/pull/1031
      
      Reviewed By: nbronson
      
      Differential Revision: D14197661
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: bd634b5755e2794891200c7f71e9d6874a60cc38
      223aae6b
    • Joe Loser's avatar
      Cut FOLLY_USE_CPP14_CONSTEXPR and FOLLY_CPP14_CONSTEXPR (#1029) · cd3b981a
      Joe Loser authored
      Summary:
      - `FOLLY_USE_CPP14_CONSTEXPR` macro is not needed as Folly requires a
        recent enough version of MSVC where its constexpr support is "good
        enough". For Clang and GCC, the min compiler versions supported would
        both evaluate the prior implementation of this macro to true in both
        cases. This is potentially slightly behavior changing since
        `FOLLY_USE_CPP14_CONSTEXPR` would be `inline` for ICC and I am not
        sure if its constexpr support is "good enough" for a min version of
        ICC we claim support for.
      - Replace `FOLLY_CPP14_CONSTEXPR` with `constexpr` in all call sites and
        remove the `FOLLY_CPP14_CONSTEXPR` macro.
      - Simplify how we define `FOLLY_STORAGE_CONSTEXPR` and
        `FOLLY_STORAGE_CPP14_CONSTEXPR` after cutting
        `FOLLY_USE_CPP14_CONSTEXPR`.
      Pull Request resolved: https://github.com/facebook/folly/pull/1029
      
      Reviewed By: Orvid
      
      Differential Revision: D14199538
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 99daecf7d7ad0c4bf6735e74247112a78923602a
      cd3b981a
    • Yedidya Feldblum's avatar
      Use pretty_name in F14TableStats · 02e56189
      Yedidya Feldblum authored
      Summary: [Folly] Use `pretty_name` in `F14TableStats`, which may not be exact in edge cases (e.g. function-local policy types) but which works without RTTI.
      
      Reviewed By: nbronson
      
      Differential Revision: D14129242
      
      fbshipit-source-id: 6f7a8e0b3af4d6b16673770228e98cd989ab0c3f
      02e56189
    • Lee Howes's avatar
      Make TimekeeperTest use thenError · d389009f
      Lee Howes authored
      Summary: Update to use thenError rather than onError.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14209634
      
      fbshipit-source-id: 5cbb66146b148654641a7a0a58717a31608a4ac7
      d389009f
    • Yedidya Feldblum's avatar
      Omit excess landing pads with StaticSingletonManager · c17964fd
      Yedidya Feldblum authored
      Summary:
      [Folly] Omit excess landing pads with `StaticSingletonManager` when the type of the global is nothrow-default-constructible.
      
      This changes behavior for nothrow-default-constructible types to terminate immediately if the process is out of memory while performing the bookkeeping around attempting to instantiate a global.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14203826
      
      fbshipit-source-id: 8c9becde3b245d6b027c97bd8541c48745727dff
      c17964fd
    • Joe Loser's avatar
      Add to_underlying_type to cast enum to underlying (#1028) · 83b597e5
      Joe Loser authored
      Summary:
      - It is verbose at the call sites to cast an enum or enum class to its
        underlying type.
      - Introduce `to_underlying_type`, which, given an enum or enum class,
        returns the value from static casting to the underlying type.
      Pull Request resolved: https://github.com/facebook/folly/pull/1028
      
      Reviewed By: stevegury
      
      Differential Revision: D14199619
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: fde85b9be50945a390b18ba1448a0137f3d7b63e
      83b597e5
    • Orvid King's avatar
      Remove the fd overload of AsyncServerSocket::useExistingSockets · b66dfacb
      Orvid King authored
      Summary: Remove all uses and remove the overload.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14194039
      
      fbshipit-source-id: c3b271747200b9219b734e5a0f19c6d5d4d135a2
      b66dfacb
  4. 24 Feb, 2019 1 commit
    • Aaryaman Sagar's avatar
      Fix namespace in folly::copy comments · 8fc76076
      Aaryaman Sagar authored
      Summary: Fix namespace in folly::copy comments
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14202488
      
      fbshipit-source-id: 14ebc5a58bfd3b62e4d6ecd03e1ceffa796f4b1f
      8fc76076
  5. 23 Feb, 2019 6 commits
    • Orvid King's avatar
      Add a safety net to NetworkSocket::fromFd · 51a97c31
      Orvid King authored
      Summary: The codemod tooling has demonstrated issues distinguishing between integer and bool overloads, so add a safety net just in case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D13995489
      
      fbshipit-source-id: 2a853f8c961953d4cdd24256420ecc29cb13c677
      51a97c31
    • Orvid King's avatar
      Shift from the file descriptor overload of EventHandler to the NetworkSocket overload · add0a129
      Orvid King authored
      Summary: The file descriptor overload will be going away.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14070240
      
      fbshipit-source-id: 20a0248fd9840629e31a3274032b889b6bb5f8de
      add0a129
    • Orvid King's avatar
      Remove the fd overloads of AsyncSocket get & detach fd · 88c2fecb
      Orvid King authored
      Summary: They are dead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14191874
      
      fbshipit-source-id: 80e6b9c51aa7d29ccc01148ccb1fd1014688c764
      88c2fecb
    • Yedidya Feldblum's avatar
      Shrink StaticSingletonManager inline slow path · 29ec891c
      Yedidya Feldblum authored
      Summary: [Folly] Shrink `StaticSingletonManager` inline slow path by passing only one argument to the outline slow path, rather than passing three arguments. In optimized builds, the argument is an immediate loaded into a register.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14121341
      
      fbshipit-source-id: f715225d0dc94df9bf2bef440ffeb08bb7a88fba
      29ec891c
    • Yedidya Feldblum's avatar
      Cut outdated comment in FOR_EACH_RANGE · f3729dd6
      Yedidya Feldblum authored
      Summary:
      [Folly] Cut outdated comment in `FOR_EACH_RANGE` implementation details.
      
      It refers to a shortcoming in a specific version of boost which is no longer supported in folly.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: Orvid
      
      Differential Revision: D14197473
      
      fbshipit-source-id: 3379af1cc69ab96fcb77be0a56ea7a5762ff7db5
      f3729dd6
    • Murali Vilayannur's avatar
      Fix rangeAdjust to handle cases of non-overlapping time ranges · ed7dbad4
      Murali Vilayannur authored
      Summary:
      When adjusting nextBucketStart by rounding down, we should also check if
      that causes it to not overlap with the user-specified [start, end) time
      interval. If it does not overlap, then return an empty return type since
      this bucket does not contribute anything to the specified time-range.
      
      Reviewed By: simpkins
      
      Differential Revision: D14121401
      
      fbshipit-source-id: bbfb1d6a71c9fb99244cdff887a7a9ee18741f25
      ed7dbad4
  6. 22 Feb, 2019 5 commits
    • Yedidya Feldblum's avatar
      Revert StaticMeta deleted dtor · ab893da3
      Yedidya Feldblum authored
      Summary: [Folly] Revert `StaticMeta` deleted dtor, which does not work well with standard constructibility tests like `std::is_constructible<StaticMeta<...>, ...>`.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14181902
      
      fbshipit-source-id: de75fe2fc864c9a32a74b8058532ef49412ac838
      ab893da3
    • Yedidya Feldblum's avatar
      FOLLY_TYPE_INFO_OF · aa63328b
      Yedidya Feldblum authored
      Summary: [Folly] `FOLLY_TYPE_INFO_OF` for cases where `folly::type_info_of` is insufficient.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D14181350
      
      fbshipit-source-id: 65d63424a5feaa6597eaddb670f760f0223717ae
      aa63328b
    • Adam Simpkins's avatar
      logging: add XCHECK_EQ and friends to XCHECK and XDCHECK · f9453967
      Adam Simpkins authored
      Summary:
      Add XCHECK_EQ(), XCHECK_NE(), XCHECK_LT(), XCHECK_LE(), XCHECK_GT(), and
      XCHECK_GE(), plus corresponding XDCHECK_*() versions that only fail in debug
      buildk.
      
      These are similar to XCHECK()/XDCHECK(), but on failure they also log the
      values of the two expressions being compared.
      
      Reviewed By: therealgymmy
      
      Differential Revision: D14016494
      
      fbshipit-source-id: dba02d748f78d306227ec734d9e52ef0bc73919b
      f9453967
    • Adam Simpkins's avatar
      fix an UBSAN failure in DistributedMutex · d3858daa
      Adam Simpkins authored
      Summary:
      Fix an `invalid-shift-base` UndefinedBehaviorSanitizer failure.
      Previously all of the DistributedMutex-inl.h tests would fail with the
      following message on my system:
      
        runtime error: left shift of 94500093116194837 by 8 places cannot be
        represented in type 'long'
      
      It might be slightly nicer in the long run to change this code to use
      `std::chrono::duration<std::uint64_t, std::nano>` throughout rather than
      `std::chrono::nanoseconds`.  Currently the `time()` function casts the
      `uint64_t` value returned by `folly::hardware_timestamp()` into a signed
      value.
      
      Reviewed By: yfeldblum, aary
      
      Differential Revision: D14180336
      
      fbshipit-source-id: b199ae22d951162dc6f31d7f1c41a7d67cbcc935
      d3858daa
    • Yedidya Feldblum's avatar
      Better constrain EvictingCacheMap iterator conversions · 679a76a9
      Yedidya Feldblum authored
      Summary: [Folly] Better constrain `EvictingCacheMap` iterator conversions.
      
      Reviewed By: shixiao
      
      Differential Revision: D14162009
      
      fbshipit-source-id: 8a3011450620fcf1ee6a137834ebbd1e5953e0ed
      679a76a9
  7. 21 Feb, 2019 8 commits
    • Gisle Dankel's avatar
      Add option to set decay time to 0 for huge page allocator · c673fbd1
      Gisle Dankel authored
      Summary:
      We observed some RSS regression for certain use cases - setting decay time to 0 should fix this as freed regions will be released back to the kernel immediately instead of delayed.
      
      The risk is that we lose regions before we can reallocate them and thus over time end up with holes in the huge page region.
      If we see this becoming an issue for some use cases, we can add a parameter to control the decay time.
      
      Releasing immediately should be OK for huge pages in most cases. For cases with frequent allocation and deallocation of large areas there can be a perf impact however.
      
      Reviewed By: interwq
      
      Differential Revision: D13853171
      
      fbshipit-source-id: 83fb95ed9c9bcb6ebdd1f80d78347e5eec61c084
      c673fbd1
    • Joe Loser's avatar
      Cut include needed from autotools build days (#1023) · 2ac8a368
      Joe Loser authored
      Summary:
      - When Folly supported autotools builds, a different include for
        `dwarf.h` was required in `folly/experimental/symbolizer/Dwarf.cpp`.
      - Since Folly does not support autotools  builds as of `1d58fd57`, cut
        this include and just assume `<dwarf.h>` works.
      Pull Request resolved: https://github.com/facebook/folly/pull/1023
      
      Reviewed By: simpkins
      
      Differential Revision: D14119901
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: f676f72ec91e25390cb3bbbe544de7cbc68e1d73
      2ac8a368
    • Yedidya Feldblum's avatar
      type_info_of · 69e54672
      Yedidya Feldblum authored
      Summary: [Folly] `type_info_of`, which returns `typeid` when RTTI is available, otherwise `nullptr`.
      
      Reviewed By: swolchok
      
      Differential Revision: D14159675
      
      fbshipit-source-id: b64ab770f12c7385bb286f658627d085e561def6
      69e54672
    • Yedidya Feldblum's avatar
      Simplify is_negative · 12314eb7
      Yedidya Feldblum authored
      Summary: [Folly] Simplify `is_negative`.
      
      Reviewed By: stevegury
      
      Differential Revision: D14141289
      
      fbshipit-source-id: 88bfd5923d90c5ac23d431110c0f2dc6c476d868
      12314eb7
    • Chad Austin's avatar
      only depend on libiberty on linux · 7a489dcf
      Chad Austin authored
      Summary: demangle.h isn't available on macOS, so only include it on Linux.
      
      Reviewed By: andrewjcg
      
      Differential Revision: D14114593
      
      fbshipit-source-id: 59b12bfb4a52ada636b3648115dec1383f58c22f
      7a489dcf
    • Yedidya Feldblum's avatar
      Avoid unary negation of unsigned in FormatValue · dcc31061
      Yedidya Feldblum authored
      Summary:
      [Folly] Avoid unary negation of unsigned in `FormatValue`, which some compilers may warn against.
      
      ```
      folly\format-inl.h(452): error C4146: unary minus operator applied to unsigned type, result still unsigned
      ```
      
      Reviewed By: Orvid
      
      Differential Revision: D14141989
      
      fbshipit-source-id: 3bff06fe09fd4ec22d93b72a74f086ad9c576692
      dcc31061
    • Yedidya Feldblum's avatar
      Remove a legacy guard around an exceptionStr overload · 9715d540
      Yedidya Feldblum authored
      Summary: [Folly] Remove a legacy guard around an `exceptionStr` overload protecting against platforms lacking `std::exception_ptr`.
      
      Reviewed By: mzlee
      
      Differential Revision: D14129260
      
      fbshipit-source-id: 2947c5b00d901ccaf58aefeef51e442121777eba
      9715d540
    • Yedidya Feldblum's avatar
      Use bit_cast in Endian · cc7dde63
      Yedidya Feldblum authored
      Summary:
      [Folly] Use `bit_cast` in `Endian`.
      
      Requires moving `bit_cast` to the top of the header.
      
      Reviewed By: aary
      
      Differential Revision: D14080604
      
      fbshipit-source-id: cae28003895f1326138459c3a951d38e27e27506
      cc7dde63
  8. 20 Feb, 2019 4 commits
    • Yedidya Feldblum's avatar
      Cut unnecessary unreachable note in exceptionStr · e90b9cb4
      Yedidya Feldblum authored
      Summary: [Folly] Cut unnecessary `assume_unreachable` in `exceptionStr`.
      
      Reviewed By: meyering
      
      Differential Revision: D14129281
      
      fbshipit-source-id: a7ae13188bb19d829a6c977243719285186dbfec
      e90b9cb4
    • Alex Guzman's avatar
      Remove code for custom OpenSSL 1.0.2 async · 02ddfa11
      Alex Guzman authored
      Summary: Removes references to custom patches to OpenSSL 1.0.2 for async from AsyncSSLSocket.
      
      Reviewed By: anirudhvr
      
      Differential Revision: D13908917
      
      fbshipit-source-id: a01c1a8a7523dd7b4b95a7f701cc6b356c645332
      02ddfa11
    • Joe Loser's avatar
      Cut backport of std::index_sequence and friends (#1022) · 08969df3
      Joe Loser authored
      Summary:
      - Backporting `std::index_sequence`, `std::integer_sequence`, and other
        associated template aliases such as `index_sequence_for` and
        `make_index_sequence` is not needed as Folly requires C++14. These
        functions and template aliases are available in C++14 standard libraries,
        including GCC 4.9.
      Pull Request resolved: https://github.com/facebook/folly/pull/1022
      
      Reviewed By: Orvid
      
      Differential Revision: D14119891
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 5ba55cc91495cf488cebfa1ebe82c0ff919e9840
      08969df3
    • Michael Liu's avatar
      Overload getKeepAliveToken · f28c81ee
      Michael Liu authored
      Summary: getKeepAlive can get a KeepAlive object and return a copy of itself
      
      Reviewed By: yfeldblum
      
      Differential Revision: D14095402
      
      fbshipit-source-id: 9d00ebecddc938e8cf02bcb7cee0642a666db349
      f28c81ee