1. 10 Mar, 2020 2 commits
    • Victor Zverovich's avatar
      Make errnoStr return std::string instead of fbstring · 0d908464
      Victor Zverovich authored
      Summary:
      The result of `errnoStr` is often converted to `std::string` so returning `fbstring` adds an extra copy. Make it return `std::string` instead. This will also allow removing dependency between `String.h` and `FBString.h`.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20195395
      
      fbshipit-source-id: 0dc65f1566911156be3fcb715dd105c58f2a8822
      0d908464
    • Wez Furlong's avatar
      getdeps: use c:/open/scratch if available on windows · 8d276922
      Wez Furlong authored
      Summary:
      Ideally we'd be using mkscratch, but this still isn't shipped
      to our Windows systems.
      
      Pick a path that is more friendly to our corp windows environment by default.
      
      Reviewed By: pkaush
      
      Differential Revision: D20342277
      
      fbshipit-source-id: c85bccee6701adc03b26c92ba217b18bd684257a
      8d276922
  2. 08 Mar, 2020 2 commits
    • Yedidya Feldblum's avatar
      Cut CachelinePadded · 9489a9c1
      Yedidya Feldblum authored
      Summary: [Folly] Cut `CachelinePadded` after migrating all uses to `cacheline_aligned`.
      
      Reviewed By: aary
      
      Differential Revision: D19657696
      
      fbshipit-source-id: d2e5b4695bdc3734340723d5d3681e724734691e
      9489a9c1
    • Laurent Stacul's avatar
      Cannot build tests if Gtest not configured by CMake (#1331) · c3d09b78
      Laurent Stacul authored
      Summary:
      When Gtest cannot be discovered by CMake config file, the tests fails to compile:
      ```
      In file included from /home/docker/opensource/folly/folly/test/common/TestMain.cpp:23:
      /home/docker/opensource/folly/folly/portability/GTest.h:32:10: fatal error: gtest/gtest.h: No such file or directory
         32 | #include <gtest/gtest.h>
            |          ^~~~~~~~~~~~~~~
      ```
      This PR fixes this problem with a classic `find_package`.
      Pull Request resolved: https://github.com/facebook/folly/pull/1331
      
      Differential Revision: D20323404
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 2e41f99172c504063c00c45a9fa5c08a26bcc0c8
      c3d09b78
  3. 06 Mar, 2020 5 commits
    • Lee Howes's avatar
      Add Unsafe version of collect functions to ease migration to safe SemiFuture versions · 6f3d8f43
      Lee Howes authored
      Summary:
      Migration from Future-returning executor-erasing collectX forms to SemiFuture-returning forms, that are less risky in particular with coroutines.
      
      An earlier change added collectXSemiFuture. This diff adds collectXUnsafe as a migration path.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20255061
      
      fbshipit-source-id: 379b5ed95aa7782aa121dba8e84cb48f802a57cd
      6f3d8f43
    • Lee Howes's avatar
      Remove unnecessary include · 9db0f005
      Lee Howes authored
      Summary: SingletonThreadLocal is not needed by Future.cpp.
      
      Reviewed By: Orvid
      
      Differential Revision: D20142400
      
      fbshipit-source-id: d0f3b7c1bbef03226c8d6264abeb96822587a465
      9db0f005
    • Oded Horovitz's avatar
      make mlock2wrapper public · 0b4e86c2
      Oded Horovitz authored
      Summary: As title. Expose the useful portable mlock2() wrapper.
      
      Reviewed By: alikhtarov
      
      Differential Revision: D20239849
      
      fbshipit-source-id: 0fa776faf29ad69e551dfbe6eb69369560800a0e
      0b4e86c2
    • Jason Meisel's avatar
      Fix Conv.cpp unary minus operator applied to unsigned type · 043bf35f
      Jason Meisel authored
      Summary: Cast from unsigned to signed *before* negating. The resulting assembly code is the same, but there's no warning.
      
      Reviewed By: yfeldblum, jdonald
      
      Differential Revision: D19588115
      
      fbshipit-source-id: d0d61ab0543211e2399f42a86a7a7a2366679d37
      043bf35f
    • Dave Rigby's avatar
      Make GFlags actually optional (#1325) · 16b3011a
      Dave Rigby authored
      Summary:
      The absence of GFlags is already partially optional -
      portability/GFlags.h defines a number of stub macros / clases if
      FOLLY_HAVE_LIBGFLAGS is false.
      
      However the top-level CMake rules don't correctly handle when GFlags
      isn't present - they unconditionally add GFlags-related variables to
      CMAKE_REQUIRED_xxx variables.
      
      Additionally there are a couple of source files which should not be
      compiled if GFlags isn't available.
      Pull Request resolved: https://github.com/facebook/folly/pull/1325
      
      Differential Revision: D20252030
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 7c3441e8b2850d68df125fb9c14b8417f4d08b55
      16b3011a
  4. 05 Mar, 2020 2 commits
  5. 04 Mar, 2020 5 commits
    • Haijun Zhu's avatar
      Explicitly destroy c++ IOBuf from cython IOBuf · 27d015c7
      Haijun Zhu authored
      Summary: This seems to not happen reliably and causes rss to grow. The `__dealloc__` cannot fix it completely, although I verified it is called. So calling it explicitly seems to guarantee it to happen.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20206887
      
      fbshipit-source-id: 6285a8e8943a53d20714e54efd3220a545010102
      27d015c7
    • Yang Chi's avatar
      Mock recvmmsg in AsyncUDPSocket · 4e969a2d
      Yang Chi authored
      Summary: as title, just to add a mock function
      
      Reviewed By: yfeldblum, lnicco
      
      Differential Revision: D20130909
      
      fbshipit-source-id: 469d904cce93dc8e88c5dc4728b1f1fbd0baf798
      4e969a2d
    • Giuseppe Ottaviano's avatar
      Improve the documentation of Assume.h · 072c06e3
      Giuseppe Ottaviano authored
      Summary:
      We have noticed some inappropriate uses of `assume_unreachable()`, and we believe that the documentation does not convey strongly enough that it is not an assertion.
      
      This diff moves the implementation to a separate header (as the assertions in there might be misleading) and fleshes out more the intended use cases.
      
      Reviewed By: yfeldblum, mkatsevVR, luciang
      
      Differential Revision: D20182339
      
      fbshipit-source-id: 8a3be1ada06dead7ea936971c42c4f30389fc23a
      072c06e3
    • Yedidya Feldblum's avatar
      Fix small_vector::insert with non-random-access iterators · 7fbfb758
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `small_vector::insert` with non-random-access iterator arguments.
      
      Closes https://github.com/facebook/folly/issues/1322.
      
      Reviewed By: ot, terrelln
      
      Differential Revision: D20150453
      
      fbshipit-source-id: 184e748dcbb7cb60318b5f0a3104d9aeb8352d7b
      7fbfb758
    • Amlan Nayak's avatar
      Add methods to update Codel parameters · 5ead8bc2
      Amlan Nayak authored
      Summary:
      Codel is statically initialized with some default target delay and interval period. It would be useful to have the ability to update these parameters at runtime to fine tune load shedding to a given use case.
      
      Adding methods here to update the target delay and interval parameters.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19987838
      
      fbshipit-source-id: 4d67277f38037840883f6d9d5fd2d5f9be760f44
      5ead8bc2
  6. 03 Mar, 2020 4 commits
    • Ján's avatar
      add missing #include · cbe65786
      Ján authored
      Summary: `type_traits` needed for `std::enable_if_t`
      
      Reviewed By: yfeldblum, Orvid
      
      Differential Revision: D20196749
      
      fbshipit-source-id: 4d4e44c523959dda1f04b452d65880ca3401e036
      cbe65786
    • Phil Willoughby's avatar
      make glogstyleformatter stop guessing · fcfaecbc
      Phil Willoughby authored
      Summary: Might as well store the count of newlines in the Log Message - as the field is already padded to <pointersize> bytes by the alignment requirements of the field either side it will not use any more space than the existing `bool`
      
      Reviewed By: simpkins
      
      Differential Revision: D20200298
      
      fbshipit-source-id: 84cc52898069eae1af5bd0f103d4ab3177c45206
      fcfaecbc
    • Dan Melnic's avatar
      Add support for futures folly::HighResDuration · 6c881171
      Dan Melnic authored
      Summary: Add support for futures folly::HighResDuration
      
      Reviewed By: kevin-vigor
      
      Differential Revision: D19981652
      
      fbshipit-source-id: 4a321fda487d5acdee04d138b0e4f0f10a4119f1
      6c881171
    • Yedidya Feldblum's avatar
      Avoid uses of gflags integer aliases · 581e3369
      Yedidya Feldblum authored
      Summary: [Folly] Avoid uses of gflags integer aliases, preferring std integer aliases.
      
      Reviewed By: WillerZ, vitaut
      
      Differential Revision: D20204609
      
      fbshipit-source-id: e00b183ab2574af7ea064b9602f1ab8efced50b0
      581e3369
  7. 28 Feb, 2020 3 commits
    • Nathan Bronson's avatar
      work around compiler bug on some platforms · 9d9dad16
      Nathan Bronson authored
      Summary: g++ aggressively inlines F14VectorMap::operator[] calls from some testing loops with the loop index as a key. On platforms that have SSE2 but not SSE4.2 we use a multiplication and xor based bit mixer, which undergoes a strength reduction in optimized builds. Somehow the resulting code miscalculates the result (no minimal repro yet), which causes the tests to persistently fail. This diff blocks the compiler optimization, allowing the tests to pass.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19910180
      
      fbshipit-source-id: 6cccba67645481061f923bd7b3e681df573c4039
      9d9dad16
    • Yedidya Feldblum's avatar
      Let Init work without gflags support · 4534b679
      Yedidya Feldblum authored
      Summary: [Folly] Let `Init` work without `gflags` support.
      
      Reviewed By: simpkins
      
      Differential Revision: D20150102
      
      fbshipit-source-id: ceaae7ec3373f46457ba0d2a524b1223dec9961c
      4534b679
    • TJ Yin's avatar
      replace more folly::Optional::reset by clear inside template · 455116f7
      TJ Yin authored
      Reviewed By: vitaut
      
      Differential Revision: D20098574
      
      fbshipit-source-id: 409c3c1e7716a38f253fa3d0d8afe615139426cc
      455116f7
  8. 27 Feb, 2020 4 commits
    • Saif Hasan's avatar
      Use BaseService for thrift-handler from oss-fb303 · 4af06cab
      Saif Hasan authored
      Summary:
      This diff adds fb303 dependency to Open/R. fb303 is FB's open-sourced project
      which provides basic infrastructure for thrift service e.g. base functions,
      counters supports etc.
      
      Using this in Open/R will allow both internal & external users leverage counters
      via thrift APIs
      
      Reviewed By: xiangxu1121
      
      Differential Revision: D20134243
      
      fbshipit-source-id: 23782ec99dc749dd27dc19f2b2b023f1c229608b
      4af06cab
    • Lewis Baker's avatar
      Add some benchmarks for folly::coro::Task · 5096b62a
      Lewis Baker authored
      Summary: Adds a few simple benchmarks to get an idea for the overhead of `folly::coro::Task` coroutines.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19729527
      
      fbshipit-source-id: cdfbd5c408c24dd258c56bc159af0c03cb1cd55e
      5096b62a
    • Andrew Huang's avatar
      Add ability to enable TLS 1.3 in folly::SSLContext · fe8777e5
      Andrew Huang authored
      Summary: As a step to eventually supporting TLS 1.3 by default for OpenSSL, we want to add the ability to selectively enable TLS 1.3 in folly::SSLContext.
      
      Reviewed By: mingtaoy
      
      Differential Revision: D20102778
      
      fbshipit-source-id: 0865821ad2730482e797b888d16561b6989dca62
      fe8777e5
    • Mark Santaniello's avatar
      Fix memory leak in usingJEMalloc() · e697d574
      Mark Santaniello authored
      Summary: We should probably just free this.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20119718
      
      fbshipit-source-id: 2a6c79730243b7af5ba90dac631ce0c8e1e0e6a4
      e697d574
  9. 26 Feb, 2020 4 commits
  10. 25 Feb, 2020 2 commits
    • Maged Michael's avatar
      hazptr: rename start_hazptr_thread_pool_executor to enable_hazptr_thread_pool_executor · 97c7ab42
      Maged Michael authored
      Summary: This makes the function name more accurate. The function does not start the thread pool executor. It only enables the construction and use of a thread pool executor by the default hazptr domain when needed.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D19852860
      
      fbshipit-source-id: 5ae71d0fd2d2d20c9ca66f45d57e90085703b3fb
      97c7ab42
    • Max Katsev's avatar
      optimize small_vector::clear · 47696430
      Max Katsev authored
      Summary:
      clang fails to optimize the current version even in the opt mode
      
      code:
      ```
      void clear(folly::small_vector<int, 5>& vec) {
          vec.clear();
      }
      ```
      
      before:
      
      cat_huh
      
      ```
      0000000000000000 <clear(folly::small_vector<int, 5ul, void, void, void>&)>:
         0:	55                   	push   %rbp
         1:	48 89 e5             	mov    %rsp,%rbp
         4:	41 57                	push   %r15
         6:	41 56                	push   %r14
         8:	53                   	push   %rbx
         9:	50                   	push   %rax
         a:	49 89 fe             	mov    %rdi,%r14
         d:	48 8b 07             	mov    (%rdi),%rax
        10:	48 8d 4f 08          	lea    0x8(%rdi),%rcx
        14:	48 85 c0             	test   %rax,%rax
        17:	78 5a                	js     73 <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x73>
        19:	48 89 cf             	mov    %rcx,%rdi
        1c:	49 bf ff ff ff ff ff 	movabs $0x7fffffffffffffff,%r15
        23:	ff ff 7f
        26:	48 89 c3             	mov    %rax,%rbx
        29:	4c 21 fb             	and    %r15,%rbx
        2c:	74 3a                	je     68 <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x68>
        2e:	48 8d 34 9f          	lea    (%rdi,%rbx,4),%rsi
        32:	48 85 c0             	test   %rax,%rax
        35:	78 53                	js     8a <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x8a>
        37:	48 8d 14 99          	lea    (%rcx,%rbx,4),%rdx
        3b:	48 89 d9             	mov    %rbx,%rcx
        3e:	48 29 f2             	sub    %rsi,%rdx
        41:	74 0e                	je     51 <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x51>
        43:	e8 00 00 00 00       	callq  48 <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x48>
        48:	49 8b 06             	mov    (%r14),%rax
        4b:	48 89 c1             	mov    %rax,%rcx
        4e:	4c 21 f9             	and    %r15,%rcx
        51:	48 c1 e3 02          	shl    $0x2,%rbx
        55:	48 c1 fb 02          	sar    $0x2,%rbx
        59:	48 29 d9             	sub    %rbx,%rcx
        5c:	49 ff c7             	inc    %r15
        5f:	49 21 c7             	and    %rax,%r15
        62:	49 09 cf             	or     %rcx,%r15
        65:	4d 89 3e             	mov    %r15,(%r14)
        68:	48 83 c4 08          	add    $0x8,%rsp
        6c:	5b                   	pop    %rbx
        6d:	41 5e                	pop    %r14
        6f:	41 5f                	pop    %r15
        71:	5d                   	pop    %rbp
        72:	c3                   	retq
        73:	48 8b 39             	mov    (%rcx),%rdi
        76:	49 bf ff ff ff ff ff 	movabs $0x7fffffffffffffff,%r15
        7d:	ff ff 7f
        80:	48 89 c3             	mov    %rax,%rbx
        83:	4c 21 fb             	and    %r15,%rbx
        86:	75 a6                	jne    2e <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x2e>
        88:	eb de                	jmp    68 <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x68>
        8a:	48 8b 09             	mov    (%rcx),%rcx
        8d:	48 8d 14 99          	lea    (%rcx,%rbx,4),%rdx
        91:	48 89 d9             	mov    %rbx,%rcx
        94:	48 29 f2             	sub    %rsi,%rdx
        97:	75 aa                	jne    43 <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x43>
        99:	eb b6                	jmp    51 <clear(folly::small_vector<int, 5ul, void, void, void>&)+0x51>
      ```
      
      after (much better but still 3 instructions too many):
      ```
      0000000000000000 <clear(folly::small_vector<int, 5ul, void, void, void>&)>:
         0:	55                   	push   %rbp
         1:	48 89 e5             	mov    %rsp,%rbp
         4:	48 b8 00 00 00 00 00 	movabs $0x8000000000000000,%rax
         b:	00 00 80
         e:	48 21 07             	and    %rax,(%rdi)
        11:	5d                   	pop    %rbp
        12:	c3                   	retq
      ```
      
      Reviewed By: ot, philippv, luciang
      
      Differential Revision: D19890921
      
      fbshipit-source-id: 62f1b5325b4deda95976894b476849b5098fad4f
      47696430
  11. 24 Feb, 2020 7 commits
    • Phil Willoughby's avatar
      add glog->folly log bridge · 134472ee
      Phil Willoughby authored
      Summary: This class is intended to be useful when part of your project is using folly logging and part is using glog - simply install this bridge up-front and everything is routed to folly logging.
      
      Reviewed By: simpkins
      
      Differential Revision: D19952822
      
      fbshipit-source-id: 898846fc7b647ddd93222f46c56450c1454dc738
      134472ee
    • Dan Melnic's avatar
      Fix set SO_REUSEPORT error message, save errno, use throwSystemErrorExplicit · 8fd9c637
      Dan Melnic authored
      Summary:
      Fix set SO_REUSEPORT error message, save errno, use throwSystemErrorExplicit
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: vitaut
      
      Differential Revision: D20052057
      
      fbshipit-source-id: 2f1b3135ff84242aa7ad38d3063ef9e260c3127c
      8fd9c637
    • Dan Melnic's avatar
      Use folly::sizedFree for the ext buffer · 9037e3ac
      Dan Melnic authored
      Summary: Use folly::sizedFree for the ext buffer
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19934204
      
      fbshipit-source-id: 63662ab547f15addc7cdb249704964dfc70ca1f3
      9037e3ac
    • Chad Austin's avatar
      enable SharedMutex benchmarks on macOS · 8bf79388
      Chad Austin authored
      Summary:
      Instead of using a Linux-specific API for random numbers, use
      std::minstd_rand. It's not precisely identical, but probably
      sufficient for these tests.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D20039048
      
      fbshipit-source-id: 5ace1a0552f995a48b37e4fa2209394f1b28ca84
      8bf79388
    • Widagdo Setiawan's avatar
      Fix signed/unsigned mismatch in json.cpp · 8583f02b
      Widagdo Setiawan authored
      Summary: Fix signed/unsigned mismatch in json.cpp
      
      Reviewed By: yfeldblum, jdonald
      
      Differential Revision: D19671088
      
      fbshipit-source-id: 4bc1f4111e0536aa22c7fd03a2a6a6d786b7cfc8
      8583f02b
    • Shrikrishna Khare's avatar
      SAI diag shell in OSS: python dep for FBOSS · 9d426db1
      Shrikrishna Khare authored
      Summary:
      The SAI diag shell implementation requires Python3.7.6.
      Previous diff in the stack added Python3.7.6 manifest.
      Make use of it to build diag shell and link with Python lib.
      
      Differential Revision: D20064315
      
      fbshipit-source-id: c855f8a9f554066e8150ce1d867828a84161961b
      9d426db1
    • Shrikrishna Khare's avatar
      fbcode_builder: getdeps: add Python3.7.6 manifest · 4a44929c
      Shrikrishna Khare authored
      Summary:
      As titled.
      
      FBOSS depends on Python3.7.6, subsequent diff in the stack adds Python3.7.6
      depedency for FBOSS.
      
      Differential Revision: D20064316
      
      fbshipit-source-id: 27b328dc25e326f3927ea6cb003fb7bb45732d61
      4a44929c