Giter Club home page Giter Club logo

snmalloc's Introduction

snmalloc

snmalloc is a high-performance allocator. snmalloc can be used directly in a project as a header-only C++ library, it can be LD_PRELOADed on Elf platforms (e.g. Linux, BSD), and there is a crate to use it from Rust.

Its key design features are:

  • Memory that is freed by the same thread that allocated it does not require any synchronising operations.
  • Freeing memory in a different thread to initially allocated it, does not take any locks and instead uses a novel message passing scheme to return the memory to the original allocator, where it is recycled. This enables 1000s of remote deallocations to be performed with only a single atomic operation enabling great scaling with core count.
  • The allocator uses large ranges of pages to reduce the amount of meta-data required.
  • The fast paths are highly optimised with just two branches on the fast path for malloc (On Linux compiled with Clang).
  • The platform dependencies are abstracted away to enable porting to other platforms.

snmalloc's design is particular well suited to the following two difficult scenarios that can be problematic for other allocators:

  • Allocations on one thread are freed by a different thread
  • Deallocations occur in large batches

Both of these can cause massive reductions in performance of other allocators, but do not for snmalloc.

The implementation of snmalloc has evolved significantly since the initial paper. The mechanism for returning memory to remote threads has remained, but most of the meta-data layout has changed. We recommend you read docs/security to find out about the current design, and if you want to dive into the code docs/AddressSpace.md provides a good overview of the allocation and deallocation paths.

snmalloc CI snmalloc CI for Morello

Hardening

There is a hardened version of snmalloc, it contains

  • Randomisation of the allocations' relative locations,
  • Most meta-data is stored separately from allocations, and is protected with guard pages,
  • All in-band meta-data is protected with a novel encoding that can detect corruption, and
  • Provides a memcpy that automatically checks the bounds relative to the underlying malloc.

A more comprehensive write up is in docs/security.

Further documentation

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

snmalloc's People

Contributors

achamayou avatar amari avatar anakrish avatar ashamis avatar ashamis-ms avatar brvtalcake avatar davidchisnall avatar devnexen avatar eairpeter avatar ihaller avatar jblazquez avatar jumaffre avatar matajoh avatar mfelsche avatar microsoftopensource avatar mjp41 avatar msftgits avatar naville avatar nwf avatar nwf-msr avatar panekj avatar plietar avatar ricleite avatar rmn30 avatar ronorton avatar rschust avatar ryancinsight avatar saaramar avatar schrodingerzhu avatar theodus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snmalloc's Issues

Optionally use superpages on Windows

Windows can allocate superpages with VirtualAlloc2 and the MEM_LARGE_PAGES flag. This gives better TLB usage at the expense of some memory overhead. We should provide it as an option.

Add alignment to the surface API

Based on the work in #109 alignment with snmalloc can be implemented extremely efficiently: just two additional instructions, which can be optimised away if the alignment is known to be 1 at compile time.

We should expand the internal alloc functions to take an optional alignment parameter (defaulting to 1). This will be useful for scenarios in Project Verona, and will improve the Rust support in #109.

Integrating it into the internal alloc routines will allow for more efficient detecting corner cases such as zero size or zero alignment by pushing them onto the slow path. This will allow clients to not require checking if it can't be guaranteed by construction.

Currently the maximum alignment we support is SUPERSLAB_SIZE. This is sufficient for most applications, but allowing more would reduce unexpected behaviour. This requires fiddling with the large allocator.

Work items:

  • Expose alignment at the API level.
  • Enforce power of two alignment on large allocations.

How to adopt larger PAGE_SIZE?

I was trying to port snmalloc to a platform with larger page size; I spotted it seems that the OS_PAGE_SIZE is hard-coded. I tried changing the default value, however, alignment checking is failed then.

is there any instruction to follow to port this library to an environment with a larger PAGE_SIZE?

GCC 9 strange failure

GCC9 will yield error when compile target is static.

Compile with clang (static)

➜  build git:(master) ✗ CC=clang CXX=clang++ cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja
-- The C compiler identification is Clang 9.0.1
-- The CXX compiler identification is Clang 9.0.1
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Generating clangformat target using /usr/bin/clang-format
-- Configuring done
-- Generating done
-- Build files have been written to: /home/schrodinger/CLionProject/snmalloc/build
➜  build git:(master) ✗ ninja
[4/4] Linking C static library libsnmallocshim.a

Compile with GCC8 (static)

➜  build git:(master) ✗ CC=gcc-8 CXX=g++-8 cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/gcc-8
-- Check for working C compiler: /usr/bin/gcc-8 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++-8
-- Check for working CXX compiler: /usr/bin/g++-8 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Generating clangformat target using /usr/bin/clang-format
-- Configuring done
-- Generating done
-- Build files have been written to: /home/schrodinger/CLionProject/snmalloc/build
➜  build git:(master) ✗ ninja
[4/4] Linking C static library libsnmallocshim.a

Compile with GCC9 (static)

➜  build git:(master) ✗ ninja
[1/4] Building CXX object CMakeFiles/snmallocshim-1mib.dir/src/override/malloc.cc.o
FAILED: CMakeFiles/snmallocshim-1mib.dir/src/override/malloc.cc.o 
/usr/bin/c++  -DIS_ADDRESS_SPACE_CONSTRAINED -DSNMALLOC_EXPORT="__attribute__((visibility(\"default\")))" -I../src -O3 -DNDEBUG -fvisibility=hidden   -Wall -Wextra -Werror -Wundef -fno-exceptions -fno-rtti -g -ftls-model=initial-exec -fomit-frame-pointer -march=native -mcx16 -std=gnu++17 -MD -MT CMakeFiles/snmallocshim-1mib.dir/src/override/malloc.cc.o -MF CMakeFiles/snmallocshim-1mib.dir/src/override/malloc.cc.o.d -o CMakeFiles/snmallocshim-1mib.dir/src/override/malloc.cc.o -c ../src/override/malloc.cc
In file included from ../src/override/../mem/globalalloc.h:4,
                 from ../src/override/../mem/slowalloc.h:1,
                 from ../src/override/malloc.cc:1:
../src/override/../mem/alloc.h: In function 'void* for_rust_memalign(size_t, size_t)':
../src/override/../mem/alloc.h:978:13: error: array subscript 59 is above array bounds of 'snmalloc::FreeListHead [36]' [-Werror=array-bounds]
  978 |       auto& fl = small_fast_free_lists[sizeclass];
      |             ^~
../src/override/../mem/alloc.h:978:13: error: array subscript 59 is above array bounds of 'snmalloc::FreeListHead [36]' [-Werror=array-bounds]
cc1plus: all warnings being treated as errors
[2/4] Building CXX object CMakeFiles/snmallocshim.dir/src/override/malloc.cc.o
FAILED: CMakeFiles/snmallocshim.dir/src/override/malloc.cc.o 
/usr/bin/c++  -DSNMALLOC_EXPORT="__attribute__((visibility(\"default\")))" -I../src -O3 -DNDEBUG -fvisibility=hidden   -Wall -Wextra -Werror -Wundef -fno-exceptions -fno-rtti -g -ftls-model=initial-exec -fomit-frame-pointer -march=native -mcx16 -std=gnu++17 -MD -MT CMakeFiles/snmallocshim.dir/src/override/malloc.cc.o -MF CMakeFiles/snmallocshim.dir/src/override/malloc.cc.o.d -o CMakeFiles/snmallocshim.dir/src/override/malloc.cc.o -c ../src/override/malloc.cc
In file included from ../src/override/../mem/globalalloc.h:4,
                 from ../src/override/../mem/slowalloc.h:1,
                 from ../src/override/malloc.cc:1:
../src/override/../mem/alloc.h: In function 'void* for_rust_memalign(size_t, size_t)':
../src/override/../mem/alloc.h:978:13: error: array subscript 75 is above array bounds of 'snmalloc::FreeListHead [44]' [-Werror=array-bounds]
  978 |       auto& fl = small_fast_free_lists[sizeclass];
      |             ^~
../src/override/../mem/alloc.h:978:13: error: array subscript 75 is above array bounds of 'snmalloc::FreeListHead [44]' [-Werror=array-bounds]
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.

Compile with GCC9 (shared)

➜  build git:(master) ✗ cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja                   
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Generating clangformat target using /usr/bin/clang-format
-- Configuring done
-- Generating done
-- Build files have been written to: /home/schrodinger/CLionProject/snmalloc/build
➜  build git:(master) ✗ ninja
[4/4] Linking C shared library libsnmallocshim.so

AddressSpaceManager::reserve sometimes always asks for the smallest possible block?

In the case that AddressSpaceManager::reserve cannot satisfy a request from its cache and the underlying PAL supports highly-aligned allocations, the requested block size is taken to be the smallest permitted by the PAL:

if constexpr (pal_supports<AlignedAllocation, Pal>)
{
block_size = Pal::minimum_alloc_size;
block = static_cast<Pal*>(this)->template reserve_aligned<false>(
block_size);

This allocation is then inserted into the AddressSpaceManager's cache

add_range(block, block_size);

and then an attempt is made to return a chunk of the originally requested size, with commentary suggesting that it cannot fail

// still holding lock so guaranteed to succeed.
res = remove_block(bits::next_pow2_bits(size));

This seems... fishy, since the PALs that support AlignedAllocation have minimum_alloc_size of 4KiB or 64KiB, well below the typical 1MiB (or 16MiB) of a Superslab.

Replace ABA primitives with LL/SC emulation?

CHERI builds primarily on RISC platforms, specifically MIPS and RISC V, which have native LL/SC support. AFAICT, MIPS R4K promises relatively strong LL/SC operation (permitting loads and stores from the core having done the LL); RISC V promises little but presumably real implementations will also be relatively strong. Anyway, on these platforms, I think ds/aba.h is more of a hindrance than a help; the sole user, ds/mpmcstack.h is forced to phrase its operations in terms of CAS and so will always require ABA protection. While the existing non-X86 paths in ds/aba.h optimistically fall back to just a pointer-sized CAS, this fails to deliver effective ABA protection

I am unsure what the correct answer is, but I think, at least broadly, that mpmcstack should be rewritten in terms of a LL/SC primitive that can be provided by some platform-specific code. I haven't come up with a better answer than something like this, tho', which isn't great, so other thoughts are more than welcome. Notably, this approach, I think, relies very, very heavily on the compiler's ability to inline to produce good code.

  template<typename T, Construction c = RequiresInit>
  class LLSC
  {
    /* Cmp defined as in existing ds/aba */
  private:
   Cmp value;

  public:
    inline bool llsc(std::function<bool, T*> f, bool* out)
    {
      T t;
      // Load link t from this, or load t and the generation counter
      *out = f(&t);
      if (*out)
      {
        // Store conditional or CAS2 with incremented generation counter
      }
      else
      {
        return true; // will cause exit from calling loop, which can look at *out
      }
    }
  }

Replacing the pagemap

The current pagemap on Windows has several conditionals on the critical path of deallocation. This is due to it checking for initialisation as it goes. This also leads to less optimal codegen for combining the fast and slow paths after checking the pagemap.

We can implement a page map that has no conditionals on the fast path if each level has a default initialisation. I was experimenting with making a type safe multi-level tree that is pre-initialised.

#include <type_traits>
#include <atomic>
#include <cstdlib>

  static constexpr size_t block_size = 65536;

  template <typename T, size_t total_entries, void* alloc_block()>
  class Node
  {
  public:
    static constexpr bool is_leaf = (total_entries * sizeof(T)) <= block_size;

    /**
     * Calculate the entries that are stored at this level of the tree.
     *
     * `TT` is used to allow the change of representation from T at the bottom level
     * to pointers at higher levels.
     * `entries` is used to say how many entries are required at this level.
     **/
    template <typename TT, size_t entries>
    static constexpr size_t calc_entries()
    {
      if constexpr (entries * sizeof(TT) <= block_size)
      { 
        return entries;
      }
      else
      {
        constexpr size_t next = (entries * sizeof(TT)) / block_size;
        return calc_entries<void*, next>();
      }
    }

    /// The number of elements at this level of the tree.
    static constexpr size_t entries = calc_entries<T, total_entries>();
    /// The number of entries each sub entry should contain.
    static constexpr size_t sub_entries = total_entries / entries;

    using SubT = Node<T, sub_entries, alloc_block>;

    /**
     * Type of entries in the tree, these are either the leaf entries
     * or the pointers to the next level down.
     */
    struct Ptr
    {
      std::conditional_t<is_leaf, T, SubT*> value;

      constexpr static std::conditional_t<is_leaf, T, SubT*> init()
      {
        if constexpr (is_leaf)
        {
          return T();
        }
        else
        {
          return (SubT::original());
        }
      }

      constexpr Ptr() noexcept : value(init()) {}

      Ptr(std::conditional_t<is_leaf, T, SubT*> v) noexcept : value(v) {}
    };


#if !defined(_MSC_VER) || defined(__clang__)
    // The address used for default address for this level in the tree.
    inline static Node original_block{};
#endif

    constexpr static Node* original()
    {
#if defined(_MSC_VER) && !defined(__clang__)
      // The address used for default address for this level in the tree.
      // MSVC does not support the `inline static` of the self type.
      constexpr static Node original_block{};
#endif
      return const_cast<Node*>(&original_block);
    };

#if !defined(_MSC_VER) || defined(__clang__)
    // The address used for the lock at for this level in the tree.
    inline static Node lock_block{};
#endif
    constexpr static Node* lock()
    {
#if defined(_MSC_VER) && !defined(__clang__)
      // The address used for the lock at for this level in the tree.
      // MSVC does not support the `inline static` of the self type.
      constexpr static Node lock_block{};
#endif
      return const_cast<Node*>(&lock_block);
    };

    constexpr Node() noexcept {}

    /// Data store for this level of the tree.
    std::atomic<Ptr> array[entries];

    /// Get element at this index.
    T get(size_t index)
    {
      if constexpr (is_leaf)
      {
        return array[index].load().value;
      }
      else
      {
        return (array[index / sub_entries].load().value)->get(index % sub_entries);
      }
    }

    /// Set element at this index.
    void set(size_t index, T v)
    {
      if constexpr (is_leaf)
      {
        array[index] = Ptr(v);
      }
      else
      {
        auto next = array[index / sub_entries].load().value;
        if ((next != SubT::original()) && (next != SubT::lock()))
        {
          array[index / sub_entries].load().value->set(index % sub_entries, v);
          return;
        }
        set_slow(index, v);
      }
    }

    __attribute__((noinline))
    void set_slow(size_t index, T v)
    {
      auto expected = Ptr(SubT::original());
      if (array[index / sub_entries].compare_exchange_strong(expected, Ptr(SubT::lock())))
      {
        // Allocate new node
        void* new_block = alloc_block();
        // Initialise the block
        auto new_block_typed = new (new_block) SubT();
        // Unlock node
        array[index / sub_entries].store(Ptr(new_block_typed));
      }
      else
      {
        while (array[index / sub_entries].load().value == SubT::lock())
        {
          //Aal::pause();
        }
      }
      array[index / sub_entries].load().value->set(index % sub_entries, v);
    }
  };

  void* alloc_block()
  {
    return malloc(block_size);
  }

  Node<uint8_t, 1ULL << 24, alloc_block> tree {};

  extern "C" uint8_t get(size_t c) { return tree.get(c); }
  extern "C" void set(size_t c, uint8_t v) { tree.set(c,v); }

This generates great ASM (haven't actually tested it yet). I was just looking at integrating this into snmalloc, but there are two challenges.

  • struct PagemapConfig and its uses
  • page_for_address

I think for the PagemapConfig it should be something like:

    static constexpr PagemapConfig config = {
      2, false, sizeof(uintptr_t), GRANULARITY_BITS, sizeof(T), BLOCK_SIZE};

Update the version, and add a new field for the block size, though I don't actually know if it is necessary to expose that detail. This new implementation degenerates to the flat map if the block_size is equal to the total_entries * sizeof(T), so by exposing block_size the second field is redundant.

I think page_for_address only every exposes the page containing the T, and we have always made that part of the pagemap if we return it.

@davidchisnall, can you check my understanding before I work on the integration.

Add back off strategy for large reservations

In the POSIX and Windows PALs, if aligned allocation isn't provided we reserve a large amount of memory, so that we can perform alignment work in the AddressSpaceManager. However, if the large reservation fails, then the system will determine out-of-memory.

The PALs should attempt to reduce the size of reservation in the failure case, so that the program can continue working if possible.

slab free list not properly terminated?

I've spent a while chasing what seems to be a bug in the slab state machine, but I'm not sure.

The case in question is that a slab has evolved, from its initial, empty state, to full (without deallocs in the interim), to having one entry free and, so, on the free list and used as the inter-slab link. In this latter state, an allocation request arrives to discover that the free list is populated, so it fetches what it believes to be the next value from the free entry and populates meta.head accordingly. Unfortunately, because this entry was the slab link, that read has not produced a valid successor index for the free list, and so Metaslab::debug_slab_invariant correctly screams that the slab is full without satisfying Metaslab::is_full.

I believe the fix to have Slab::alloc check, when (head & 1) == 0, whether meta.link and meta.head are equal. If so, no read from the slab is necessary and alloc should immediately invoke meta.set_full() (possibly setting meta.head = 1 beforehand to avoid the assert therein, or remove the assert). If not, then it should read the successor head index as now.

Does that seem reasonable? I don't fully understand, if this analysis is not wildly off the mark, why this isn't tickled in native builds, just CHERI, but tickled it is.

Investigate Windows Commit charge for snmalloc

@aganea has enabled snmalloc, mimalloc, and rpmalloc to be the allocator for lld-link. He has benchmarked this with performing ThinLTO on a clang build. The results taken from https://reviews.llvm.org/D71786 are

Allocator Wall clock Page ranges commited/decommited Total touched pages Peak Mem
Windows 10 version 2004 38 min 47 sec 14.9 GB
mimalloc 2 min 22 sec 1,449,501 174,3 GB 19,8 GB
rpmalloc 2 min 15 sec 270,796 45,9 GB 31,9 GB
snmalloc 2 min 19 sec 102,839 47,0 GB 42,0 GB

The time is pretty comparable, but this shows snmalloc on Windows as committing considerably more memory than other allocators.

Experiments to try

  • Different "chunk" size, 16MiB versus 1MiB.
  • Sub chunk, commit/decommit operations

Track slab with bump pointer in a new per allocator structure

With #65 we now use a queue of slabs for selecting free lists. The queue is also how we pick up the bump pointer, this means we are not really benefiting from the bump ptr.

We should have a separate per allocator per size class structure for the slab, we are currently bump allocating from. This would reduce the memory usage and allow us to simplify the data in the meta slab, and would remove some conditionals on the slower paths.

We could just store the pages that have been bump allocated in the meta slab, i.e. just require 4bits.

func-fixed_region is not built correctly

When running revions after e240dd2 with -O2 and USE_SNMALLOC_STATS enabled and on a Linux amd64 box, func-fixed_region-16 crashes (but func-fixed_region-1 does not). The tail of the output under gdb is

Allocated object 0x7fffea02b530
Allocated object 0x7fffea02b5a0
GlobalStats, DumpID, AllocatorID, Remote freed, Remote posted, Remote received, Superslab pop, Superslab push, Superslab fresh, Segments
BucketedStats, DumpID, AllocatorID, Size group, Size, Current count, Max count, Total Allocs, Current Slab bytes, Max Slab bytes, Total slab allocs, Average Slab Usage, Average wasted space

Program received signal SIGSEGV, Segmentation fault.
snmalloc::FlatPagemap<24ul, unsigned char>::get (p=140737119453312, this=<optimised out>)
    at /home/nwf20/cheri/mainline/snmalloc/src/override/../mem/pagemap.h:360
360	      return top[p >> SHIFT].load(std::memory_order_relaxed);

The backtrace is... well, fairly full of POSIX and C++ dragons:

#0  snmalloc::FlatPagemap<24ul, unsigned char>::get (p=140737119453312, this=<optimised out>)
    at /home/nwf20/cheri/mainline/snmalloc/src/override/../mem/pagemap.h:360
#1  snmalloc::SuperslabMap<snmalloc::GlobalPagemap>::get (p=140737119453312, this=<optimised out>)
    at /home/nwf20/cheri/mainline/snmalloc/src/override/../mem/alloc.h:135
#2  snmalloc::Allocator<snmalloc::MemoryProviderStateMixin<snmalloc::PALLinux>, snmalloc::SuperslabMap<snmalloc::GlobalPagemap>, true, &snmalloc::lazy_replacement>::dealloc (this=0x7fffe8004000, p=0x7fffea030080)
    at /home/nwf20/cheri/mainline/snmalloc/src/override/../mem/alloc.h:465
#3  operator delete (p=0x7fffea030080) at /home/nwf20/cheri/mainline/snmalloc/src/override/new.cc:41
#4  0x0000000000403451 in __gnu_cxx::new_allocator<char>::deallocate (__p=0x7fffea030080 "Average wasted space", 
    this=<optimised out>) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/ext/new_allocator.h:125
#5  std::allocator_traits<std::allocator<char> >::deallocate (__p=0x7fffea030080 "Average wasted space", __a=..., 
    __n=<optimised out>) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/alloc_traits.h:462
#6  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy (this=<optimised out>, 
    __size=<optimised out>)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/basic_string.h:226
#7  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose (this=<optimised out>)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/basic_string.h:221
#8  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (this=<optimised out>)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/basic_string.h:647
#9  snmalloc::AllocStats<75ul, 24ul>::print<snmalloc::Allocator<snmalloc::MemoryProviderStateMixin<snmalloc::PALPlainMixin<snmalloc::PALOpenEnclave> >, snmalloc::SuperslabMap<snmalloc::GlobalPagemap>, true, &snmalloc::lazy_replacement> > (
    this=0x7fffffffb360, o=..., dumpid=0, allocatorid=0) at /home/nwf20/cheri/mainline/snmalloc/src/mem/allocstats.h:329
#10 0x000000000040225c in snmalloc::ThreadAllocExplicitTLSCleanup::print_stats ()
    at /home/nwf20/cheri/mainline/snmalloc/src/mem/threadalloc.h:259
#11 0x00007ffff6ec9041 in __run_exit_handlers (status=0, listp=0x7ffff7271718 <__exit_funcs>, 
    run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
#12 0x00007ffff6ec913a in __GI_exit (status=<optimised out>) at exit.c:139
#13 0x00007ffff6ea7b9e in __libc_start_main (main=0x400f50 <main()>, argc=1, argv=0x7fffffffe6b8, init=<optimised out>, 
    fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffe6a8) at ../csu/libc-start.c:344
#14 0x0000000000400e4a in _start ()

We're printing out statistics from the atexit() handler (frame 10) and we're trying to run the C++ string destructor (frame 8), which is being routed through the snmalloc-intercepted operator delete (frame 3). This allocator believes its memory provider's PAL to be PALLinux, and the GlobalPagemap seems to be a FlatPagemap, looking at frame 1.

What's going on is that in this test fixed_region.cc contains #define OPEN_ENCLAVE thereby making Pal PALPlainMixin<PALOpenEnclave> and DefaultPal PALLinux. Thus, when the test calls ThreadAlloc::get(), the global allocator type is going to be one with the OpenEnclave PAL. So far so good, I suppose. However, src/override/new.cc is built separately, and therefore does not see OPEN_ENCLAVE being asserted, and so, horrors, it believes that Pal and DefaultPal are both PALLinux, and so will build code assuming that allocators use flat page maps, even when, as we have just observed above, the global allocator is initialized by someone else and has the wrong type.

I think that func-fixed_region should be changed so that both its main file and new.cc are in agreement that PALOpenEnclave is the correct thing to build all allocators around.

func-two_alloc_types doesn't trip over this perhaps because it happens that its main.cc does not define OPEN_ENCLAVE and so will construct the global pool around PALLinux, in agreement with new.cc and, moreover, the name mangling ensures that alloc1 and alloc2 have different ThreadAlloc pools. The calls to snmalloc_pagemap_global_get do not ensure that the two allocators' pagemaps have equal layout (and in fact, they don't): the pagemap config is overwritten prior to the assert within this function, which therefore always passes. Perhaps what was meant was something like

  SNMALLOC_EXPORT void* SNMALLOC_NAME_MANGLE(snmalloc_pagemap_global_get)(
    PagemapConfig const** config)
  {
    if (config)
    {
      assert( *config == NULL ||
        decltype(snmalloc::global_pagemap)::cast_to_pagemap(
          &snmalloc::global_pagemap, *config) == &snmalloc::global_pagemap);
      *config = &decltype(snmalloc::global_pagemap)::config;
    }
    return &snmalloc::global_pagemap;
  }

which does not pass in func-two_alloc_types (with c = NULL; added before the first call so that it's initialized).

Android Support

I open this issue just to provide some information about android cross compile:

First thing is that, android-ndk do not have backtrace, hence, we need some workaround like chromium.

Second, there is a little difference of the malloc prototype:

SNMALLOC_EXPORT size_t SNMALLOC_NAME_MANGLE(malloc_usable_size)(const void* ptr) 
{
    return Alloc::alloc_size(const_cast<void*>(ptr));
}

With the above changes, I successfully cross compiled for android.

Android (5900059 based on r365631c) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 207d7abc1a2abf3ef8d4301736d6a7ebc224a290) (based on LLVM 9.0.8svn)
Target: aarch64-unknown-linux-android29
Thread model: posix
InstalledDir: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin

It is extremely hard to find a test environment to check whether the allocator is really working, but if you want to have a try, the above workarounds can be useful.

Build more efficient statistics for Release builds

The statistics code has not been maintained during several refactors. This needs addressing.

  • Tests need adding to check the statistics are correct for the amount of allocations and deallocations.
  • All functional tests should build with statistics switched on.
  • Fast path needs to maintain statistics approximately. Whenever a free list is grabbed, then we will consider all the elements allocated in the statistics. To regain accurate statistics, we will need to empty the allocator local free lists.

Once addressed, we should be able to close #79 #80 #82.

memcpy of a non-trivial class lead to compile error on GCC 9.0

In a pr to snmalloc-rs, we can spot that on GCC>=8 the -Wclass-memaccess will lead to an compilation error.
A possible workaround is:

#if !defined(__clang__) && defined(__GNUC__)
#if __GNUC__ >= 8
#define GCC_WARNING_ADJUST
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#endif
      memcpy(allocated, &local, sizeof(MemoryProviderStateMixin<PAL>));
#ifdef GCC_WARNING_ADJUST
#pragma GCC diagnostic pop
#undef GCC_WARNING_ADJUST
#endif

Since we are using -Werror, if we do not filter clang and lower versions of GCC, -Wclass-memaccess will not be recognized and lead to another error.

Crash on realloc

Hello, I'm seeing a 100% crash in snmalloc's realloc function, in malloc.cc, L92. The crash is caused by the sz being larger than the size initially allocated. We're trying to (re)allocate a large buffer:

llvm-mc.exe!realloc(void * ptr=0x0000023244000000, unsigned __int64 size=0x00000000027fffff)

In malloc.cc, L82, Alloc::alloc_size(ptr); finds sz to be 0x0000000002000000 bytes. However the caller knows the buffer is 0x013fffff. So we end up crashing on rep movsb while copying the buffer to the new location.
I can see alloc_size(..) returning at alloc.h, L500, ie. return 1ULL << size; where size is 25.

I haven't investigated any further. I am at git checkout a43773c. I'm trying to integrate snmalloc in LLVM to compare it with other modern allocators. Currently half a dozen tests are failing because of this. Any suggestions? I can provide with a repro if needed.

OpenEnclave: Compile errors on ARM

When building snmalloc for use within enclaves, we get the following compile error on ARM:

export CCACHE_CPP2=true && /usr/bin/ccache /usr/bin/aarch64-linux-gnu-g++ -I3rdparty/optee/libutee/liboeutee -g -Wall -Werror -Wpointer-arith -Wconversion -Wextra -Wno-missing-field-initializers -fno-strict-aliasing -Wno-type-limits -I/home/anakrish/openenclave_qemu/sdk/include -I/home/anakrish/openenclave_qemu/sdk/3rdparty/libcxx/libcxx/include -I/home/anakrish/openenclave_qemu/build/output/include/openenclave/libc -Wno-conversion -ftls-model=local-exec -nostdinc++ -fPIE -ffreestanding -DARM64=1 -D__LP64__=1 -mstrict-align -nostdinc -nostdlib -nodefaultlibs -nostartfiles -fno-builtin-memcpy -fno-builtin-memset -funwind-tables -fpie -fPIC -gdwarf -fno-exceptions -fvisibility=hidden -std=c++14 -std=c++17 -MD -MT 3rdparty/snmalloc/CMakeFiles/oesnmalloc.dir/allocator.cpp.o -MF 3rdparty/snmalloc/CMakeFiles/oesnmalloc.dir/allocator.cpp.o.d -o 3rdparty/snmalloc/CMakeFiles/oesnmalloc.dir/allocator.cpp.o -c /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/allocator.cpp
In file included from /home/anakrish/openenclave_qemu/sdk/3rdparty/libcxx/libcxx/include/ostream:140:0,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/libcxx/libcxx/include/istream:164,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/libcxx/libcxx/include/iostream:40,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/../aal/aal_arm.h:15,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/../aal/aal.h:104,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/bits.h:8,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/helpers.h:3,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/./snmalloc/src/override/../mem/globalalloc.h:3,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/./snmalloc/src/override/../mem/slowalloc.h:1,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/./snmalloc/src/override/malloc.cc:1,
from /home/anakrish/openenclave_qemu/sdk/3rdparty/snmalloc/allocator.cpp:30:
/home/anakrish/openenclave_qemu/sdk/3rdparty/libcxx/libcxx/include/locale: In function ‘_Tp std::__1::__num_get_signed_integral(const char*, const char*, std::__1::ios_base::iostate&, int)’:
/home/anakrish/openenclave_qemu/sdk/3rdparty/libcxx/libcxx/include/locale:740:26: error: there are no arguments to ‘strtoll_l’ that depend on a template parameter, so a declaration of ‘strtoll_l’ must be available [-fpermissive]
long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
^~~~~~~~~

The error seems to be due to the use of <iostream> in aal_arm.h:

#include <iostream>

Removing iostream and replacing it with stdint.h fixes the compilation errors.
Can we avoid a dependency on iostreams?

Duplication in Azure Pipelines CI script.

The Azure Pipelines CI script has a lot of code duplication. A small amount of conditional phases and more use of matrix could probably shrink this file in half.

Consider supporting snmalloc in Ubuntu 16.04 (GCC 5.4.0)

snmalloc does not compile with the default GCC (5.4.0) on Ubuntu 16.04. This is due to the use of specific C++17 features like if constexpr.
As part of PR openenclave/openenclave@efd9311, I had to disable snmalloc build on Ubuntu 16.04 when the compiler is GCC.

Consider supporting default compilers of slightly older platforms like Ubuntu 16.04. That would make adopting snmalloc easier.

PAL / Decreasing code rewrite

Actually PAL for Mac (and possibly later on Haiku) could benefit code lines decrease by having a template argument more for the anonymous map ID.

Improve SIMD memcpy on windows?

I saw an interesting issue at mimalloc: microsoft/mimalloc#201.

It seems that on Windows memcpy does not invoke SIMD instructions by default. I remember that musl memcpy does not use SIMD directly either, though it is written in a way that makes the compiler feel happy to optimize.

There are three cases of memcpy in snmalloc. Therefore, perhaps writing memcpy using SIMD instructions directly on some platforms may result in a better performance.

Possible broken tests

I came across these compilation errors in the tests while I was trying the Rust build with VS2019. I didn't have more time to dig into the issue so documenting it here.

C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build>cmake  .. "-G" "Visual Studio 16 2019" "-Thost=x64" "-Ax64" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_C_FLAGS= -nologo -MD -Brepro" "-DCMAKE_C_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS_RELEASE= -nologo -MD -Brepro"
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- snmalloc: Using Windows 10 APIs
CMake Warning at CMakeLists.txt:54 (message):
  Not generating clangformat target, no clang-format tool found
Call Stack (most recent call first):
  CMakeLists.txt:244 (clangformat_targets)


-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/build

C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build>cd ..

C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc>mkdir build

C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc>cd build

C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build>cmake  .. "-G" "Visual Studio 16 2019" "-Thost=x64" "-Ax64" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_C_FLAGS= -nologo -MD -Brepro" "-DCMAKE_C_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS_RELEASE= -nologo -MD -Brepro"
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.24.28314.0
-- The CXX compiler identification is MSVC 19.24.28314.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- snmalloc: Using Windows 10 APIs
-- Adding test: perf-contention-1
-- Single threaded test: perf-contention-1
-- Adding test: perf-contention-16
-- Single threaded test: perf-contention-16
-- Adding test: perf-external_pointer-1
-- Single threaded test: perf-external_pointer-1
-- Adding test: perf-external_pointer-16
-- Single threaded test: perf-external_pointer-16
-- Adding test: perf-singlethread-1
-- Single threaded test: perf-singlethread-1
-- Adding test: perf-singlethread-16
-- Single threaded test: perf-singlethread-16
-- Adding test: func-fixed_region-1
-- Single threaded test: func-fixed_region-1
-- Adding test: func-fixed_region-16
-- Single threaded test: func-fixed_region-16
-- Adding test: func-malloc-1
-- Adding test: func-malloc-16
-- Adding test: func-memory-1
-- Single threaded test: func-memory-1
-- Adding test: func-memory-16
-- Single threaded test: func-memory-16
-- Adding test: func-release-rounding-1 only for release configs
-- Adding test: func-release-rounding-16 only for release configs
-- Adding test: func-sizeclass-1
-- Adding test: func-sizeclass-16
-- Adding test: func-statistics-1
-- Adding test: func-statistics-16
-- Adding test: func-two_alloc_types-1
-- Single threaded test: func-two_alloc_types-1
-- Adding test: func-two_alloc_types-16
-- Single threaded test: func-two_alloc_types-16
CMake Warning at CMakeLists.txt:54 (message):
  Not generating clangformat target, no clang-format tool found
Call Stack (most recent call first):
  CMakeLists.txt:242 (clangformat_targets)


-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_BUILD_TYPE


-- Build files have been written to: C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/build
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build>cmake --build .
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  fixed_region.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-fixed_region-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(437):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(const void *)' [C:\Users\caca\projects\snmalloc-rs
\snmalloc-sys\snmalloc\build\func-fixed_region-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\func\fixed_region\fixed_region.cc(38): me
ssage : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(const void *)' being compiled [C:\Users\caca\proje
cts\snmalloc-rs\snmalloc-sys\snmalloc\build\func-fixed_region-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-fixed_region-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-fixed_region-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  fixed_region.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-fixed_region-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(437):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(const void *)' [C:\Users\caca\projects\snmalloc-rs
\snmalloc-sys\snmalloc\build\func-fixed_region-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\func\fixed_region\fixed_region.cc(38): me
ssage : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(const void *)' being compiled [C:\Users\caca\proje
cts\snmalloc-rs\snmalloc-sys\snmalloc\build\func-fixed_region-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-fixed_region-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-fixed_region-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  malloc.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-malloc-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-malloc-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-malloc-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-malloc-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-malloc-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  malloc.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-malloc-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-malloc-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-malloc-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-malloc-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-malloc-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  memory.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-memory-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-memory-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-memory-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-memory-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-memory-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  memory.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-memory-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-memory-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-memory-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-memory-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-memory-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  rounding.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-release-rounding-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-release-rounding-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-release-rounding-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-release-rounding-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-release-rounding-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  rounding.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-release-rounding-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-release-rounding-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-release-rounding-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-release-rounding-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-release-rounding-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  sizeclass.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-sizeclass-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-sizeclass-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-sizeclass-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-sizeclass-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-sizeclass-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  sizeclass.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-sizeclass-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-sizeclass-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-sizeclass-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-sizeclass-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-sizeclass-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  stats.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-statistics-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-statistics-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-statistics-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-statistics-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-statistics-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  stats.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-statistics-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-statistics-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-statistics-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-statistics-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-statistics-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  alloc1.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
  alloc2.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
  main.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(437):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(const void *)' [C:\Users\caca\projects\snmalloc-rs
\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\func\two_alloc_types\main.cc(51): message
 : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basi
c_ostream<char,std::char_traits<char>>::operator <<(const void *)' being compiled [C:\Users\caca\projects\s
nmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-1.vcxproj]
  Generating Code...
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  alloc1.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
  alloc2.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\../ds/csv.h(44): message : see reference t
o function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std
::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snm
alloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
  main.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(437):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(const void *)' [C:\Users\caca\projects\snmalloc-rs
\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\func\two_alloc_types\main.cc(51): message
 : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basi
c_ostream<char,std::char_traits<char>>::operator <<(const void *)' being compiled [C:\Users\caca\projects\s
nmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(444,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\func-two_alloc_types-16.vcxproj]
  Generating Code...
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  contention.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\perf-contention-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\perf-contention-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test/usage.h(39): message : see reference to f
unction template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::c
har_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snmall
oc-sys\snmalloc\build\perf-contention-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-contention-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-contention-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  contention.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\perf-contention-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\perf-contention-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test/usage.h(39): message : see reference to f
unction template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::c
har_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\projects\snmalloc-rs\snmall
oc-sys\snmalloc\build\perf-contention-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-contention-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-contention-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  externalpointer.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(354,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\perf-external_pointer-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(347):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(__int64)' [C:\Users\caca\projects\snmalloc-rs\snma
lloc-sys\snmalloc\build\perf-external_pointer-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\perf\external_pointer\externalpointer.cc(
67): message : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>
> &std::basic_ostream<char,std::char_traits<char>>::operator <<(__int64)' being compiled [C:\Users\caca\pro
jects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\sizeclasstable.h(32): message : see refere
nce to class template instantiation 'snmalloc::ModArray<23,uint16_t>' being compiled [C:\Users\caca\project
s\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(354,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  externalpointer.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(354,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\perf-external_pointer-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(347):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(__int64)' [C:\Users\caca\projects\snmalloc-rs\snma
lloc-sys\snmalloc\build\perf-external_pointer-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\perf\external_pointer\externalpointer.cc(
67): message : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>
> &std::basic_ostream<char,std::char_traits<char>>::operator <<(__int64)' being compiled [C:\Users\caca\pro
jects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\sizeclasstable.h(32): message : see refere
nce to class template instantiation 'snmalloc::ModArray<31,uint16_t>' being compiled [C:\Users\caca\project
s\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(354,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-external_pointer-16.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  singlethread.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\perf-singlethread-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\perf-singlethread-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\perf\singlethread\singlethread.cc(13): me
ssage : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\p
rojects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-1.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\sizeclasstable.h(32): message : see refere
nce to class template instantiation 'snmalloc::ModArray<23,uint16_t>' being compiled [C:\Users\caca\project
s\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-1.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-1.vcxproj]
  Building Custom Rule C:/Users/caca/projects/snmalloc-rs/snmalloc-sys/snmalloc/CMakeLists.txt
  singlethread.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: error C2220: the following warning is treated as an error [C:\Users\caca\projects\snmalloc-rs\snmalloc-sy
s\snmalloc\build\perf-singlethread-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(365):
message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' [C:\Users\caca\projects\snmallo
c-rs\snmalloc-sys\snmalloc\build\perf-singlethread-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\test\perf\singlethread\singlethread.cc(13): me
ssage : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std:
:basic_ostream<char,std::char_traits<char>>::operator <<(unsigned __int64)' being compiled [C:\Users\caca\p
rojects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(638):
message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being
 compiled [C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-16.vcxproj]
C:\Users\caca\projects\snmalloc-rs\snmalloc-sys\snmalloc\src\mem\sizeclasstable.h(32): message : see refere
nce to class template instantiation 'snmalloc::ModArray<31,uint16_t>' being compiled [C:\Users\caca\project
s\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-16.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include\ostream(372,1)
: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\sefe
rnan\projects\snmalloc-rs\snmalloc-sys\snmalloc\build\perf-singlethread-16.vcxproj]

Performance regression

Before #178

redis sn_79ca9 8.984 56332 3.58 0.85 0 303

after

redis sn_c899e 11.345 56172 4.78 0.87 0 304

This perf regressions needs fixing.

debug_check_empty useless after message queue changes

Bisecting reveals that eb4e28e, while it does remove the special case, breaks tests like func-memory that expect to be able to test that there are no outstanding allocations, becuase every allocator will be nonempty, having message queue stubs in place. The fix, I think, is to move the test for emptiness into the main loop, testing for emptiness between alloc->message_queue().destroy() and alloc->init_message_queue(); the count must be reset to zero at the top of the main loop.

Provide option to disable -march=native

The option -march=native enables the compiler to specify code to the current machines CPU capabilities with Clang and GCC. This improves performance.

However, if the build and deployment machine are different then this option should not be used as the build machine may have features such as AVX512., which are not supported on the target machine.

We should provide an option to specify the target architecture features.

Options

  1. Provide options is disable -march=native
  2. Provide option to specify AVX, AVX2, AVX512, and -march=native
  3. Something else?

@davidchisnall, @nwf, @SchrodingerZhu any thoughts on what we should do here? The option will also need exposing through the Rust Crate.

Looking at the codegen, -march=native doesn't make much difference and does not affect the fast paths. So I would lean towards option, 1. This will allow us to build the fast code for benchmarking, and if someone needs something more specific we can add it later.

Make PAL capable of producing back traces.

In #88, we implemented enough backtrace to flush out some CI failures for Windows. This should be refactored.

  • We should always call Pal::error instead of abort.
  • Assert should be refactored to call Pal::error in the failure case.
  • In some configurations Pal::error should produce a backtrace.
  • The Pal on Windows should account for running in headless CI, and stop generating dialog boxes.

PALOpenEnclave::reserve should the loop condition be inverted?

The reserve function is currently implemented thus:

void* old_base = oe_base;
void* next_base;
auto end = __oe_get_heap_end();
do
{
auto new_base = old_base;
next_base = pointer_offset(new_base, size);
if (next_base > end)
error("Out of memory");
} while (oe_base.compare_exchange_strong(old_base, next_base));

The loop condition is currently:
while (oe_base.compare_exchange_strong(old_base, next_base)).

Should the condition instead be negated as:
while ( ! oe_base.compare_exchange_strong(old_base, next_base))
so that the loop immediately terminates after a successful update of oe_base?

MinGW support

Currently, the project does not support MinGW.
With the following changes, it can compile with MinGW:

  1. CmakeLists.txt: at about line 74, add a branch AMD64 (quite strange but 'amd64' does not work).
  2. pal_windows.h: add some macros
    #  ifndef _MSC_VER
    #  include <cstdio>
    #  endif
    #  ifndef NOMINMAX
    #  define NOMIXMAX
    #  endif
  3. test/usage.h
    #  ifndef NOMINMAX
    #  define NOMIXMAX
    #  endif

The project compiles but all test fails. Is there any plan to improve the support?

Lazy TLS initialization breaks stats counting

Bisection reveals that b8a5d7f breaks the idea that stat counters don't go negative. In particular, adding assert(sizeclass[sc].count.current > 0); to sizeclass_dealloc (and applying the fix for #79) will cause at least func-malloc to fail on that commit and after. The problem is that small_alloc's call to stats().sizeclass_alloc happen before the check that we're on the fast path, and so apply to the stub global allocator's stat structure. This does not appear to be a problem in medium_alloc or large_alloc, as the replacement path will have tail-called before attempting to update the stub's stats structure.

Compile-time fixes for Clang 10

Hello,
Would you mind applying these fixes to make the codebase compile with Clang 10 please?
Many thanks!

diff --git a/src/ds/aba.h b/src/ds/aba.h
index 21950ff..60dcc2f 100644
--- a/src/ds/aba.h
+++ b/src/ds/aba.h
@@ -121,6 +121,7 @@ namespace snmalloc
       }
 
       Cmp(const Cmp&) = delete;
+      Cmp(Cmp&&) = default;
     };
 
     // This method is used in Verona
diff --git a/src/ds/helpers.h b/src/ds/helpers.h
index b479011..8f5b83c 100644
--- a/src/ds/helpers.h
+++ b/src/ds/helpers.h
@@ -14,7 +14,7 @@ namespace snmalloc
   class Singleton
   {
     inline static std::atomic_flag flag;
-    inline static std::atomic<bool> initialised = false;
+    inline static std::atomic<bool> initialised{};
     inline static Object obj;
 
   public:
diff --git a/src/ds/mpscq.h b/src/ds/mpscq.h
index d5d5161..a397354 100644
--- a/src/ds/mpscq.h
+++ b/src/ds/mpscq.h
@@ -14,7 +14,7 @@ namespace snmalloc
       std::is_same<decltype(T::next), std::atomic<T*>>::value,
       "T->next must be a std::atomic<T*>");
 
-    std::atomic<T*> back = nullptr;
+    std::atomic<T*> back{};
     T* front = nullptr;
 
   public:
@@ -72,10 +72,10 @@ namespace snmalloc
         SNMALLOC_ASSERT(front);
         std::atomic_thread_fence(std::memory_order_acquire);
         invariant();
-        return std::pair(first, true);
+        return std::pair<T*, bool>(first, true);
       }
 
-      return std::pair(nullptr, false);
+      return std::pair<T*, bool>(nullptr, false);
     }
   };
 } // namespace snmalloc
diff --git a/src/mem/alloc.h b/src/mem/alloc.h
index c58015b..4f8aed8 100644
--- a/src/mem/alloc.h
+++ b/src/mem/alloc.h
@@ -240,6 +240,9 @@ namespace snmalloc
     template<size_t size>
     void dealloc(void* p)
     {
+      if (p == nullptr)
+        return;
+
 #ifdef USE_MALLOC
       UNUSED(size);
       return free(p);
@@ -280,6 +283,9 @@ namespace snmalloc
      */
     SNMALLOC_FAST_PATH void dealloc(void* p, size_t size)
     {
+      if (p == nullptr)
+        return;
+
 #ifdef USE_MALLOC
       UNUSED(size);
       return free(p);
@@ -302,6 +308,9 @@ namespace snmalloc
 
     SNMALLOC_SLOW_PATH void dealloc_sized_slow(void* p, size_t size)
     {
+      if (p == nullptr)
+        return;
+
       if (size == 0)
         return dealloc(p, 1);
 
@@ -325,6 +334,9 @@ namespace snmalloc
      */
     SNMALLOC_FAST_PATH void dealloc(void* p)
     {
+      if (p == nullptr)
+        return;
+
 #ifdef USE_MALLOC
       return free(p);
 #else
diff --git a/src/mem/pagemap.h b/src/mem/pagemap.h
index fc3da85..e658cd3 100644
--- a/src/mem/pagemap.h
+++ b/src/mem/pagemap.h
@@ -188,7 +188,7 @@ namespace snmalloc
       {
         PagemapEntry* value = get_node<create_addr>(e, result);
         if (unlikely(!result))
-          return std::pair(nullptr, 0);
+          return std::pair<Leaf*, size_t>(nullptr, 0);
 
         shift -= BITS_PER_INDEX_LEVEL;
         ix = (static_cast<size_t>(addr) >> shift) & ENTRIES_MASK;
@@ -208,11 +208,11 @@ namespace snmalloc
       Leaf* leaf = reinterpret_cast<Leaf*>(get_node<create_addr>(e, result));
 
       if (unlikely(!result))
-        return std::pair(nullptr, 0);
+        return std::pair<Leaf*, size_t>(nullptr, 0);
 
       shift -= BITS_FOR_LEAF;
       ix = (static_cast<size_t>(addr) >> shift) & LEAF_MASK;
-      return std::pair(leaf, ix);
+      return std::pair<Leaf*, size_t>(leaf, ix);
     }
 
     template<bool create_addr>
diff --git a/src/mem/pooled.h b/src/mem/pooled.h
index 71f8d91..f044a77 100644
--- a/src/mem/pooled.h
+++ b/src/mem/pooled.h
@@ -14,7 +14,7 @@ namespace snmalloc
     friend class MPMCStack;
 
     /// Used by the pool for chaining together entries when not in use.
-    std::atomic<T*> next = nullptr;
+    std::atomic<T*> next{};
     /// Used by the pool to keep the list of all entries ever created.
     T* list_next;
     std::atomic_flag in_use = ATOMIC_FLAG_INIT;
diff --git a/src/mem/remoteallocator.h b/src/mem/remoteallocator.h
index 4c1f906..6d8ae55 100644
--- a/src/mem/remoteallocator.h
+++ b/src/mem/remoteallocator.h
@@ -19,7 +19,7 @@ namespace snmalloc
     union
     {
       Remote* non_atomic_next;
-      std::atomic<Remote*> next = nullptr;
+      std::atomic<Remote*> next{};
     };
 
     alloc_id_t allocator_id;
diff --git a/src/mem/slowalloc.h b/src/mem/slowalloc.h
index f2fcba1..0ab1169 100644
--- a/src/mem/slowalloc.h
+++ b/src/mem/slowalloc.h
@@ -63,6 +63,6 @@ namespace snmalloc
    */
   inline SlowAllocator get_slow_allocator()
   {
-    return SlowAllocator{};
+    return {};
   }
 } // namespace snmalloc
diff --git a/src/pal/pal_consts.h b/src/pal/pal_consts.h
index 538f90d..fe9a38d 100644
--- a/src/pal/pal_consts.h
+++ b/src/pal/pal_consts.h
@@ -78,7 +78,7 @@ namespace snmalloc
     /**
      * List of callbacks to notify
      */
-    std::atomic<PalNotificationObject*> callbacks = nullptr;
+    std::atomic<PalNotificationObject*> callbacks{};
 
   public:
     /**
diff --git a/src/pal/pal_windows.h b/src/pal/pal_windows.h
index ba7fcea..8015827 100644
--- a/src/pal/pal_windows.h
+++ b/src/pal/pal_windows.h
@@ -17,7 +17,7 @@
 #  ifdef NTDDI_WIN10_RS5
 #    if (NTDDI_VERSION >= NTDDI_WIN10_RS5) && \
       (WINVER >= _WIN32_WINNT_WIN10) && !defined(USE_SYSTEMATIC_TESTING)
-#      define PLATFORM_HAS_VIRTUALALLOC2
+//#      define PLATFORM_HAS_VIRTUALALLOC2
 #    endif
 #  endif

ds/bits contains decidedly not bit-like things

pause(), tick(), tickp(), halt_out_of_order(), benchmark_time_start(), and benchmark_time_end() really seem like they belong somewhere else, probably within the PAL. Is there a reason they're here instead?

Make Lazy decommit on Windows Asynchronous

Lazy decommit occurs on Windows once a low-memory notification has been received, and then any thread ends up calling into the large allocator. The decommit, is only decommiting large chunks of memory held in global datastructures, not in thread local data structures.

If an application is idle, when the low-memory notification is received nothing would happen. Can we make the call-back actually perform the lazy-decommit. The lock-free data structures are thread safe, so this seems like it would be a win, and only a small code change.

On Windows this seems like it would be sensible. But not sure about other platforms we might want to support. @davidchisnall do you have any thoughts on this?

Compilation failed on Windows with error C2280

Hi

I have included the snmalloc rust crate in my project. However, I get the below error during cargo build.
snmalloc rust version = 0.2.13
Windows 10 version 2004
CMake version 3.17.3

error: failed to run custom build command for `snmalloc-sys v0.2.13`

Caused by:
  process didn't exit successfully: `D:\app\target\debug\build\snmalloc-sys-3931a9a4e61262c7\build-script-build` (exit code: 101)
--- stdout
running: "cmake" "C:\\Users\\kapil\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\snmalloc-sys-0.2.13\\snmalloc" "-G" "Visual Studio 16 2019" "-Thost=x64" "-Ax64" "-DSNMALLOC_RUST_SUPPORT=ON" "-DCMAKE_CXX_FLAGS_RELEASE=/MD /O2 /Ob2 /DNDEBUG" "-DCMAKE_C_FLAGS_RELEASE=/MD /O2 /Ob2 /DNDEBUG" "-DCMAKE_INSTALL_PREFIX=D:\\app\\target\\debug\\build\\snmalloc-sys-9f20bc6fd3595a00\\out" "-DCMAKE_C_FLAGS= -nologo -MD -Brepro" "-DCMAKE_CXX_FLAGS= -nologo -MD -Brepro" "-DCMAKE_ASM_FLAGS= -nologo -MD -Brepro" "-DCMAKE_ASM_FLAGS_RELEASE= -nologo -MD -Brepro" "-DCMAKE_BUILD_TYPE=Release"
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is MSVC 19.26.28806.0
-- The CXX compiler identification is MSVC 19.26.28806.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CONST_QUALIFIED_MALLOC_USABLE_SIZE
-- Performing Test CONST_QUALIFIED_MALLOC_USABLE_SIZE - Success
-- snmalloc: Using Windows 10 APIs
-- Adding test: perf-contention-1
-- Single threaded test: perf-contention-1
-- Adding test: perf-contention-16
-- Single threaded test: perf-contention-16
-- Adding test: perf-external_pointer-1
-- Single threaded test: perf-external_pointer-1
-- Adding test: perf-external_pointer-16
-- Single threaded test: perf-external_pointer-16
-- Adding test: perf-low_memory-1
-- Single threaded test: perf-low_memory-1
-- Single threaded test: perf-low_memory-1
-- Adding test: perf-low_memory-16
-- Single threaded test: perf-low_memory-16
-- Single threaded test: perf-low_memory-16
-- Adding test: perf-singlethread-1
-- Single threaded test: perf-singlethread-1
-- Adding test: perf-singlethread-16
-- Single threaded test: perf-singlethread-16
-- Adding test: func-first_operation-1
-- Adding test: func-first_operation-16
-- Adding test: func-fixed_region-1
-- Single threaded test: func-fixed_region-1
-- Adding test: func-fixed_region-16
-- Single threaded test: func-fixed_region-16
-- Adding test: func-malloc-1
-- Adding test: func-malloc-16
-- Adding test: func-memory-1
-- Single threaded test: func-memory-1
-- Adding test: func-memory-16
-- Single threaded test: func-memory-16
-- Adding test: func-release-rounding-1 only for release configs
-- Adding test: func-release-rounding-16 only for release configs
-- Adding test: func-sizeclass-1
-- Adding test: func-sizeclass-16
-- Adding test: func-statistics-1
-- Adding test: func-statistics-16
-- Adding test: func-thread_alloc_external-1
-- Adding test: func-thread_alloc_external-16
-- Adding test: func-two_alloc_types-1
-- Single threaded test: func-two_alloc_types-1
-- Adding test: func-two_alloc_types-16
-- Single threaded test: func-two_alloc_types-16
-- Configuring done
-- Generating done
-- Build files have been written to: D:/app/target/debug/build/snmalloc-sys-9f20bc6fd3595a00/out/build
running: "cmake" "--build" "." "--target" "snmallocshim-rust" "--config" "Release" "--"
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule C:/Users/kapil/.cargo/registry/src/github.com-1ecc6299db9ec823/snmalloc-sys-0.2.13/snmalloc/CMakeLists.txt
  rust.cc
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\alloc.h(516): error C2280: 'snmalloc::Remote::Remote(void)': attempting to reference a deleted function [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\remoteallocator.h(36): message : compiler has generated 'snmalloc::Remote::Remote' here [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\remoteallocator.h(36,3): message : 'snmalloc::Remote::Remote(void)': function was implicitly deleted because 'snmalloc::Remote' has a variant data member 'snmalloc::Remote::next' with a non-trivial default constructor [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\remoteallocator.h(22): message : see declaration of 'snmalloc::Remote::next' [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\alloc.h(516): message : while compiling class template member function 'snmalloc::Allocator<bool snmalloc::needs_initialisation(void *),void *snmalloc::init_thread_allocator(snmalloc::function_ref<void *(void *)>),snmalloc::GlobalVirtual,snmalloc::DefaultChunkMap<snmalloc::GlobalPagemap>,true>::RemoteList::RemoteList(void)' [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\override\rust.cc(39): message : see reference to function template instantiation 'snmalloc::Allocator<bool snmalloc::needs_initialisation(void *),void *snmalloc::init_thread_allocator(snmalloc::function_ref<void *(void *)>),snmalloc::GlobalVirtual,snmalloc::DefaultChunkMap<snmalloc::GlobalPagemap>,true>::RemoteList::RemoteList(void)' being compiled [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\alloc.h(543): message : see reference to class template instantiation 'snmalloc::Allocator<bool snmalloc::needs_initialisation(void *),void *snmalloc::init_thread_allocator(snmalloc::function_ref<void *(void *)>),snmalloc::GlobalVirtual,snmalloc::DefaultChunkMap<snmalloc::GlobalPagemap>,true>::RemoteList' being compiled [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\alloc.h(644): message : see reference to class template instantiation 'snmalloc::Allocator<bool snmalloc::needs_initialisation(void *),void *snmalloc::init_thread_allocator(snmalloc::function_ref<void *(void *)>),snmalloc::GlobalVirtual,snmalloc::DefaultChunkMap<snmalloc::GlobalPagemap>,true>::RemoteCache' being compiled [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\../ds/mpmcstack.h(14): message : see reference to class template instantiation 'snmalloc::Allocator<bool snmalloc::needs_initialisation(void *),void *snmalloc::init_thread_allocator(snmalloc::function_ref<void *(void *)>),snmalloc::GlobalVirtual,snmalloc::DefaultChunkMap<snmalloc::GlobalPagemap>,true>' being compiled [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\pool.h(28): message : see reference to class template instantiation 'snmalloc::MPMCStack<T,snmalloc::PreZeroed>' being compiled [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
          with
          [
              T=snmalloc::Alloc
          ]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\globalalloc.h(14): message : see reference to class template instantiation 'snmalloc::Pool<Alloc,MemoryProvider>' being compiled [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]
          with
          [
              Alloc=snmalloc::Alloc,
              MemoryProvider=snmalloc::GlobalVirtual
          ]
C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\snmalloc-sys-0.2.13\snmalloc\src\mem\globalalloc.h(191): message : see reference to class template instantiation 'snmalloc::AllocPool<snmalloc::GlobalVirtual,snmalloc::Alloc>' being compiled [D:\app\target\debug\build\snmalloc-sys-9f20bc6fd3595a00\out\build\snmallocshim-rust.vcxproj]

--- stderr
CMake Warning at CMakeLists.txt:64 (message):
  Not generating clangformat target, no clang-format tool found
Call Stack (most recent call first):
  CMakeLists.txt:288 (clangformat_targets)


CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_ASM_FLAGS
    CMAKE_ASM_FLAGS_RELEASE


thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.44\src\lib.rs:885:5
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.44\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print_fmt
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\sys_common\backtrace.rs:78
   2: std::sys_common::backtrace::_print::{{impl}}::fmt
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\sys_common\backtrace.rs:59
   3: core::fmt::write
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libcore\fmt\mod.rs:1052
   4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\io\mod.rs:1428
   5: std::sys_common::backtrace::_print
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\sys_common\backtrace.rs:62
   6: std::sys_common::backtrace::print
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\sys_common\backtrace.rs:49
   7: std::panicking::default_hook::{{closure}}
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panicking.rs:204
   8: std::panicking::default_hook
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panicking.rs:224
   9: std::panicking::rust_panic_with_hook
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panicking.rs:470
  10: std::panicking::begin_panic_handler
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panicking.rs:378
  11: std::panicking::begin_panic_fmt
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panicking.rs:332
  12: cmake::fail
             at C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.44\src\lib.rs:885
  13: cmake::run
             at C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.44\src\lib.rs:863
  14: cmake::Config::build
             at C:\Users\kapil\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.44\src\lib.rs:769
  15: build_script_build::main
             at .\build.rs:71
  16: std::rt::lang_start::{{closure}}<()>
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\src\libstd\rt.rs:67
  17: std::rt::lang_start_internal::{{closure}}
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\rt.rs:52
  18: std::panicking::try::do_call<closure-0,i32>
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panicking.rs:303
  19: panic_unwind::__rust_maybe_catch_panic
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libpanic_unwind\lib.rs:86
  20: std::panicking::try
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panicking.rs:281
  21: std::panic::catch_unwind
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\panic.rs:394
  22: std::rt::lang_start_internal
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\/src\libstd\rt.rs:51
  23: std::rt::lang_start<()>
             at /rustc/8aa9d2014f4e5258f83b907e8431c59a33acdae7\src\libstd\rt.rs:67
  24: main
  25: invoke_main
             at d:\A01\_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  26: __scrt_common_main_seh
             at d:\A01\_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  27: BaseThreadInitThunk
  28: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed

OpenEnclave: Compilation fails with -nostdinc due to cpuid.h inclusion

cpuid.h is not available within the enclave and compiling with -nostdinc results in the following:

Building CXX object 3rdparty/snmalloc/CMakeFiles/oesnmalloc.dir/allocator.cpp.o
cd /home/anakrish/work/repo2/build/3rdparty/snmalloc && export CCACHE_CPP2=true && /usr/bin/ccache /usr/bin/clang++-7 -I/home/anakrish/work/repo2/build/output/include/openenclave/libcxx -I/home/anakrish/work/repo2/build/output/include/openenclave/libc -g -O0 -mllvm -x86-speculative-load-hardening -Wall -Werror -Wpointer-arith -Wconversion -Wextra -Wno-missing-field-initializers -fno-strict-aliasing -Wno-type-limits -mxsave -I/home/anakrish/work/repo2/include -I/home/anakrish/work/repo2/3rdparty/libcxx/libcxx/include -I/home/anakrish/work/repo2/3rdparty/musl/musl/include -I/home/anakrish/work/repo2/build/output/include/openenclave/libc -Wno-conversion -Wno-macro-redefined -ftls-model=local-exec -nostdinc -nostdinc++ -fPIE -ffreestanding -mcx16 -fno-exceptions -fvisibility=hidden -std=c++14 -std=c++17 -o CMakeFiles/oesnmalloc.dir/allocator.cpp.o -c /home/anakrish/work/repo2/3rdparty/snmalloc/allocator.cpp
In file included from /home/anakrish/work/repo2/3rdparty/snmalloc/allocator.cpp:30:
In file included from /home/anakrish/work/repo2/3rdparty/snmalloc/./snmalloc/src/override/malloc.cc:1:
In file included from /home/anakrish/work/repo2/3rdparty/snmalloc/./snmalloc/src/override/../mem/slowalloc.h:1:
In file included from /home/anakrish/work/repo2/3rdparty/snmalloc/./snmalloc/src/override/../mem/globalalloc.h:3:
In file included from /home/anakrish/work/repo2/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/helpers.h:3:
In file included from /home/anakrish/work/repo2/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/bits.h:8:
In file included from /home/anakrish/work/repo2/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/../aal/aal.h:131:
/home/anakrish/work/repo2/3rdparty/snmalloc/./snmalloc/src/override/../mem/../ds/../aal/aal_x86.h:7:12: fatal error: 'cpuid.h' file not found

Optimising small allocations

Problem

The current design of snmalloc means that to perform a small allocation, we need to follow the following chain.

  1. Follow small_classes[sc], which points to the head of doubly linked list nodes for slabs with free space of this sizeclass.
  2. Calculate the meta-slab that is associated to this doubly linked list node.
  3. Read and modify the data in this meta-slab.

Based on profiling this may be costly. It is certainly creating a fairly long chain of instructions to get to the allocation.

Proposal

We should investigate if we can keep more metadata in small_classes[sc]. If we kept, a slab pointer, free list, and a used count. Then we could allocate directly from that first cache line.
This slab pointer to the active block could be independent of the head pointer to the Slablink.

Deallocations, should go to the per slab meta data, and then free lists could be pulled from meta-slabs into the small_classes[sc]. Effectively, the union of the small_classes data, and the meta slabs would form the actual free list.

There are complications, the bump ptr would need handling specially. If we separate the bump pointer and free list in the meta slab to be separate fields, then we could just pull free lists, and if we run out of space, bump allocate a page worth of free list values, to reduce the number of times we touch the metaslab on allocation.

A second complication is that we cannot determine if the active block is empty as the used count purely in the meta-slab is not enough. If the meta-slab has a zero used we could, can check if this is the active slab and then move the used count from small_classes[sc] into the meta-slab. If it is still, zero used, then we need to return this slab, and update the active slab.

This issues is up-for-grabs as I don't have enough time to actually experiment with this. If you want to have a go, please add a comment.

malloc_history equivalent

The Darwin malloc implementation has a feature (enabled by an environment variable) that records, for each allocation or deallocation event:

  • The size of the allocation.
  • The address of the allocation.
  • The thread ID for the [de]allocation call.
  • A stack trace at the [de]allocation site.

This makes it possible for after a crash to determine where an allocation originated and where it was freed.

Implementing similar functionality in snmalloc (ideally using ifunc logic to replace the malloc / free functions at load time) could reuse some of the compressed stack trace logic from the LLVM sanitisers.

Implicit mutex around GlobalPlaceholder

d56201e introduces a static field for the global pagemap, and this gets wrapped with __cxa_guard_acquire and __cxa_guard_release, introducing a dependency on libstdc++. I suspect, but am not quite sure, that this was unintentional?

Benchmarking and mimalloc

Based on mimalloc's design we have managed to dramatically improve the performance on snmalloc.

We should

  • Rerun our benchmarking infrastructure to compare
    • snmalloc submitted to ISMM
    • snmalloc current master
    • mimalloc
  • Fully document the ideas, we adopted from the mimalloc paper, and how they impacted performance.

@daanx, @davidchisnall, @plietar, @sylvanc

func-malloc test leaks objects

func-malloc test has always leaked objects since its inception; its
test_realloc(our_malloc(size), (size_t)-1, ENOMEM, true); drops the allocation on the floor.

Refactor Pal and LargeAlloc interaction.

In #212, we built a simple power of two allocator for Open Enclave that is used so that the rest of the system does not have to overallocate to get the required alignment. This is great for improving the heap size on OE, but is bad in that the code is only tested on one platform.

The code is useful on platforms that don't support aligned allocation, as it prevents the need to overallocate and trim, which can lead to fragmentation.

I want to propose the following refactor

Pals

Pals have a minimum allocation size, Pal::min_alloc_size.

Pals provide one of two interfaces for reserving memory, the caller must guarantee to provide a request for at least Pal::min_alloc_size.

  • std::pair<void*, size_t> reserve_at_least(size_t size) - provide a natural amount of memory for this platform, could reserve GiB or even TiB, on platforms that don't support aligned allocation. On OE, this would return the entire heap range, and nullptr for all subsequent calls
  • void* reserve_aligned(size_t size) where size is a power of two. It is guaranteed to be aligned to the size.

Power of two allocator

Using the code from #212, we implement a layer on top of this, that can allocate any power of two size with natural alignment.

void* reserve(size_t size)

This code is single-threaded in the same way as in #212. All allocation sizes are supported from the smallest up (e.g. 1, 2, 4, 8, ...). This means that the power_two_allocator can be used to fulfil allocation requests from the AllocPool and PageMap where it does not use bss, and the LargeAllocator.

The Power of two allocator, like the Pal, does not support a way to return reserved memory.

The implementation will need to use the code from #212 on platforms that do not support aligned allocation, and for allocations below the min_alloc_size on platforms that do support aligned allocation.

This is effectively half of a buddy allocator that we use for carving up address space.

Benefits

  • This code change will simplify a few corner cases around initialisation. The large allocator can depend on this, so its MPMCStacks don't need copying.
  • It makes the Pal's simpler, and lets the Pal decide how to over allocate memory.
  • Simplify the cross process shared memory use case as the Pal would just provide the entire shared address range. microsoft/verona#140
  • We can simplify the LargeAllocator to not perform alloc_chunk as that will just go to the power of two allocator.
  • This leads to fewer different code paths across platforms reducing maintenance and testing costs.
  • Also has the advantage that reserved space below the SuperslabSize alignment can be used for allocating the meta-data.

Costs

  • Time probably a few days of work to get this improvement.

Adding Rust Support

I am trying to bind snmalloc to rust to have a comprehensive malloc-bench (WIP).

Basically, I have already created several bindings: snmalloc,snmalloc-sys, snmallocator.

Yet, there is a issue to provide efficient realloc with alignment. I added one following the code in malloc.h, but I do not know whether it is sound and safe. So I guess I need some guidance here.

decomitting mpmcstack elements

As noted by the comment in ds/mpmcstack.h pop(), it's unsafe to decommit memory used for stack nodes. Presumably this means that snmalloc can't discard large slab headers, even if it discards the rest of the heap? Are there other bits of memory that are pinned as a result? If there's quite a bit, should something like hazard pointers or urcu synchronization be deployed here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.