1. 27 Feb, 2020 1 commit
    • 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
  2. 26 Feb, 2020 4 commits
  3. 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
  4. 24 Feb, 2020 10 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
    • Maged Michael's avatar
      Add indicators of process phases · 7414a33e
      Maged Michael authored
      Summary:
      Add function `get_process_phase` that returns indicators of process phases:
      - `ProcessPhase::Init`: Not all global variables may have been initialized.
      - `ProcessPhase::Regular`: All globals have been initialized and have not been destroyed.
      - `ProcessPhase::Exit`: Some globals may have been destroyed.
      
      Add function `set_process_phases` and calls to it from `folly::init` and `common/init/Init.cpp` wherever `SingletonVault::singleton()->registrationComplete` is called.
      
      Will add calls to `set_process_phases` in separate diffs to other places that call `registrationComplete ` directly.
      
      See Section 6.9.3 Start and termination [basic.start] of the C++ Standard Working Draft [N4849](https://github.com/cplusplus/draft/releases/download/n4849/n4849.pdf).
      
      In general this addition is useful for simplifying cases of dependence on the existence of certain globals during main, where it is safe to ignore such globals at shutdown.
      For example, the destructor of `hazptr_obj_cohort` normally needs to access the default `hazptr_domain`, but it is safe to skip that access at shutdown.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19567170
      
      fbshipit-source-id: a44cbd3301aa9dc77a1e992922403635a3ff6552
      7414a33e
    • Lukas Piatkowski's avatar
      mononoke: make mononoke_types OSS-buildable · 75b2e2f4
      Lukas Piatkowski authored
      Summary: (Note: this ignores all push blocking failures!)
      
      Reviewed By: farnz
      
      Differential Revision: D19948740
      
      fbshipit-source-id: 9d0cfc4ccbcb3c08bb969f23229ed3096470fa86
      75b2e2f4
    • Giuseppe Ottaviano's avatar
      Move F14 fallbacks to separate headers · 594f484b
      Giuseppe Ottaviano authored
      Summary:
      Having the fallbacks in the public header files makes searching for classes/methods cumbersome, and some people have mistakenly assumed that F14 classes inherit from `unordered_*` because they landed on the wrong line.
      
      In addition, when the fallback implementation is used, any compilation errors will come from the `*Fallback.h` files, making it clear that the main implementation is not being selected.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19926873
      
      fbshipit-source-id: 492b0c252f33c0cbbf3c22dae38fa0bd63825f72
      594f484b
  5. 23 Feb, 2020 2 commits
    • Giuseppe Ottaviano's avatar
      Use sized deallocation in small_vector when possible · 0266f281
      Giuseppe Ottaviano authored
      Summary: Capacity is known in almost all the modes (except when it's inferred from `malloc_usable_size`, which is probably something we should not do in the first place), so we can easily plug in sized deallocation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19976657
      
      fbshipit-source-id: cb03f7107195af614514645c88d12ac4999dea53
      0266f281
    • Misha Shneerson's avatar
      rootid should be unique · d0f956f5
      Misha Shneerson authored
      Summary:
      rootid is the thing we use to correlate running Thrift requests with a folly::RequestContext. The problem is that today rootid is unique only for active requests but not unique throughout the lifetime of the process - as a consequence we see some subtle bugs like mistakenly attributing threads to already finished requests. The root cause of rootid collisions is that default implementation of rootid is just an address of folly::RequestContext - so once request finishes the address is reused.
      
      The solution suggested here is to assign rootids explicitly when folly::RequestContext is set for the request. To construct such rootid we pack two counters:
      * 12 MSB are dedicated to an ID of Cpp2Worker (should be more than enough)
      * 51 LSB are dedicated to a running counter within Cpp2Worker.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D20036950
      
      fbshipit-source-id: 76687db12a32f33c82ce86accb4cdaab3e981458
      d0f956f5
  6. 22 Feb, 2020 3 commits
    • Luca Niccolini's avatar
      Async UDP Socket: socket options · 54c6d875
      Luca Niccolini authored
      Summary:
      generic API for setting socket options on a UDP socket
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yangchi
      
      Differential Revision: D19763927
      
      fbshipit-source-id: d1a7720b04c24592e98c6e30c93c26e650ccd0b0
      54c6d875
    • Luca Niccolini's avatar
      delete folly::AsyncSocket::OptionMap/OptionKey/emptyOptionMap aliases · 549476f0
      Luca Niccolini authored
      Summary: delete the folly::AsyncSocket::OptionMap/OptionKey/emptyOptionMap aliases
      
      Reviewed By: yangchi
      
      Differential Revision: D19963346
      
      fbshipit-source-id: 6beae0961a82d12efd4d784ec390031d9445cd2b
      549476f0
    • Luca Niccolini's avatar
      move AsyncSocket::OptionMap into SocketOptionMap (base) · 44a7106b
      Luca Niccolini authored
      Summary: base diff to move AsyncSocket::OptionMap into SocketOptionMap. folly only changes and an alias for previous usages of AsyncSocket::OptionMap
      
      Reviewed By: yangchi
      
      Differential Revision: D19961899
      
      fbshipit-source-id: fab060cc73409c77ea07ced663fbd0ee15a35be7
      44a7106b
  7. 21 Feb, 2020 2 commits
  8. 20 Feb, 2020 2 commits
    • Dan Melnic's avatar
      Use sdallocx for IOBuf::releaseStorage · 7ec006ed
      Dan Melnic authored
      Summary: Use sdallocx for IOBuf::releaseStorage
      
      Reviewed By: marksantaniello
      
      Differential Revision: D19925485
      
      fbshipit-source-id: 142276fb64e570e10bfd0b6e22d8c83b204d1c2b
      7ec006ed
    • Dan Melnic's avatar
      Add FOLLY_CLANG_DISABLE_WARNING for Unistd.h · 12c92eaa
      Dan Melnic authored
      Summary:
      Add FOLLY_CLANG_DISABLE_WARNING for Unistd.h
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19652177
      
      fbshipit-source-id: 1fcc3bb65c3b0d73870e599f9fc0463c6836cf9b
      12c92eaa
  9. 19 Feb, 2020 5 commits
    • Chad Austin's avatar
      enable lz4 in the getdeps build of rocksdb · 6156dc3d
      Chad Austin authored
      Summary:
      The Buck build of RocksDB supports LZ4, so if an Eden instance's
      object cache ends up compressed with LZ4 compression, the opensource
      getdeps build cannot open it. Enable LZ4 in the open source getdeps
      build of rocksdb.
      
      Reviewed By: pkaush
      
      Differential Revision: D19961878
      
      fbshipit-source-id: 9a4f37e12bd2b40a0c5dcf2dd1684876886fae26
      6156dc3d
    • TJ Yin's avatar
      Replace folly::Optional::clear() by reset() · 95c7d18c
      TJ Yin authored
      Reviewed By: yfeldblum
      
      Differential Revision: D19953637
      
      fbshipit-source-id: c2135fc24084b7bba0c9d6fc978c8b6c8f9943d4
      95c7d18c
    • Ter Chrng Ng's avatar
      Revert D19848850: Add missing libraries back to ovrsource · 19f6ae0d
      Ter Chrng Ng authored
      Differential Revision:
      D19848850
      
      Original commit changeset: 21e61529d8b9
      
      fbshipit-source-id: c490eb0024a4cda830389a359ee2631615345f2d
      19f6ae0d
    • Nick Cooper's avatar
      Improve blockingWait test · f29e87cf
      Nick Cooper authored
      Summary: Previously if the loop simply failed to execute the test could pass, add some minor changes to ensure control flow is as required.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D19960864
      
      fbshipit-source-id: 5a437d9e7d3b7c249cbf999fe7ea5eecfe668658
      f29e87cf
    • Andrew Gallagher's avatar
      Add some missing includes · 0d305cb1
      Andrew Gallagher authored
      Summary: Missing includes which break modular builds.
      
      Reviewed By: igorsugak, luciang
      
      Differential Revision: D19738860
      
      fbshipit-source-id: 97a0329f3e558309ca87f4dd7be8dd96e9ba09a8
      0d305cb1
  10. 18 Feb, 2020 3 commits
    • Nick Cooper's avatar
      folly::coro::blockingWait should gracefully handle cases with thrown exceptions · 19910c37
      Nick Cooper authored
      Summary:
      If the waited upon object throws an exception when blockingWait is called within a fiber context this can cause a SIGABT as it is not permissible to yield (due to the inner baton) in an exception context.
      
      To fix this, instead capture the exception and permit destruction to occur outside of exception handling.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D19951124
      
      fbshipit-source-id: cf1bf9a62557147863390132f551d08e20c02c2d
      19910c37
    • Ter Chrng Ng's avatar
      Add missing libraries back to ovrsource · c9e346af
      Ter Chrng Ng authored
      Summary: It was originally disabled to let test pass in ovrsource, they are now passing, enabling them back
      
      Reviewed By: pranjalssh
      
      Differential Revision: D19848850
      
      fbshipit-source-id: 21e61529d8b9f519b4c8cbf4787c8e3f28b99bb1
      c9e346af
    • Dan Melnic's avatar
      Add folly::sizedFree · 8bc1252f
      Dan Melnic authored
      Summary:
      Add folly::sizedFree
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: ot
      
      Differential Revision: D19944311
      
      fbshipit-source-id: b5b1a648a180662fe838237c3c3b153e42fe0617
      8bc1252f
  11. 16 Feb, 2020 1 commit
    • Orvid King's avatar
      Support u8 as char8_t in StringPiece literals · cae89fc3
      Orvid King authored
      Summary: In C++20, u8 prefixed strings are typed as `char8_t` not `char`, so we need to support that in `StringPiece`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19822967
      
      fbshipit-source-id: c3441ba718b40f0781766d4a80c3432b4514a35c
      cae89fc3
  12. 15 Feb, 2020 1 commit
  13. 14 Feb, 2020 4 commits
    • Shai Szulanski's avatar
      Add coro::toSemiFuture · 64fc8458
      Shai Szulanski authored
      Summary:
      Currently the best way to get an eager SemiFuture from an AsyncGenerator is
        folly::coro::co_invoke(
            [&]()
                -> folly::coro::Task<folly::coro::AsyncGenerator<T&&>::NextResult> {
              co_return co_await gen.next();
            })
            .scheduleOn(&ex)
            .start();
      which is very verbose. This diff adds helpers to make this a simple function call.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D19835473
      
      fbshipit-source-id: f6e7e72cad0e0596df375d2662c87d4412536c03
      64fc8458
    • Zhengxu Chen's avatar
      Make thrift metadata available across fbcode oss builds. · 0b5752df
      Zhengxu Chen authored
      Summary: There are downstream oss builds showing build failure caused by introduction of metadata. We want to make them proceed to build so we won't get errors in CI.
      
      Reviewed By: iahs
      
      Differential Revision: D19900007
      
      fbshipit-source-id: 4201448f7980b53e407fd2bc1c74ed4ffa8e18c1
      0b5752df
    • Nathan Bronson's avatar
      fix missing eraseInto overload for key with permissive constructor · 6aa06e7f
      Nathan Bronson authored
      Summary:
      If a key type has a templated constructor that can implicitly
      accept const_iterator, then a call to erase or eraseInto with a non-const
      iterator results in an ambiguous overload. This diff adds an extra
      overload of eraseInto to avoid the ambiguity, as well as adding unit
      tests that cover the rare corner case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D19809069
      
      fbshipit-source-id: 499849da2d6ad64070b13eb0a9ed86a3d49ad9b0
      6aa06e7f
    • Nathan Bronson's avatar
      add eraseInto to F14 maps · 10abef97
      Nathan Bronson authored
      Summary:
      It's useful to be able to move the key and value
      out of a hash table as that entry is being erased. Since
      std::unordered_map's extract API isn't implementable for hash tables
      that perform bulk allocation, we expose similar functionality via
      F14{Fast,Value,Vector,Node}Map::eraseInto.  eraseInto gives a key_type&&
      and mapped_type&& to the specified callback, allowing it to move them
      elsewhere before the underlying value_type is destroyed.
      
      The keen observer will note that there is no way to move the key out
      of a std::pair<key_type const,mapped_type> without relying on undefined
      behavior. We already rely on this form of UB to avoid copying keys during
      rehash, and perform it only when we have total control over the lifecycle
      of the object and the memory backing the value_type.
      
      eraseInto was previously implemented for F14 sets.
      
      Reviewed By: shixiao
      
      Differential Revision: D19777644
      
      fbshipit-source-id: 9904224af2c6e51abeadae62cc5e66f7bf4b1ae7
      10abef97