GithubHelp home page GithubHelp logo

emuradaisuke / memoryallocator.kanameshiki Goto Github PK

View Code? Open in Web Editor NEW
77.0 10.0 9.0 373 KB

Fast multi-threaded memory allocator

License: MIT License

C++ 95.50% C 1.89% Shell 2.08% Batchfile 0.53%
lock-free memory-allocator memory-allocation memory-management multithreading multi-threading cpp malloc malloc-library malloc-benchmarks

memoryallocator.kanameshiki's People

Contributors

emuradaisuke 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

memoryallocator.kanameshiki's Issues

Seg Fault in Cooperative(協調型) Kaname-Shiki

Hi, when I use Cooperative Kaname-Shiki in my own system, I get the following segmentation fault:

Thread 3 "multiplexer" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7870700 (LWP 23718)]
0x00007ffffdeb588e in KanameShiki::GlobalReserver::Alloc(unsigned long) () from /home/zzxx/repos/MemoryAllocator.KanameShiki/lib/libKanameShiki0_g.so
(gdb) bt
#0  0x00007ffffdeb588e in KanameShiki::GlobalReserver::Alloc(unsigned long) () from /home/zzxx/repos/MemoryAllocator.KanameShiki/lib/libKanameShiki0_g.so
#1  0x00007ffffdeb6111 in KanameShiki::LocalReserver::Alloc(unsigned long) () from /home/zzxx/repos/MemoryAllocator.KanameShiki/lib/libKanameShiki0_g.so
#2  0x00007ffffdeb6768 in KanameShiki::LocalCntx::NewCram(unsigned short, unsigned long) () from /home/zzxx/repos/MemoryAllocator.KanameShiki/lib/libKanameShiki0_g.so
#3  0x00007ffffdeb6ce4 in operator new(unsigned long) () from /home/zzxx/repos/MemoryAllocator.KanameShiki/lib/libKanameShiki0_g.so
#4  0x000000000818bcc7 in __gnu_cxx::new_allocator<nova::InstMessage>::allocate (this=0x7fffdfc46938, __n=32768) at /usr/include/c++/7/ext/new_allocator.h:111
#5  0x000000000818afa4 in std::allocator_traits<std::allocator<nova::InstMessage> >::allocate (__a=..., __n=32768) at /usr/include/c++/7/bits/alloc_traits.h:436
#6  0x0000000008189cc0 in std::_Vector_base<nova::InstMessage, std::allocator<nova::InstMessage> >::_M_allocate (this=0x7fffdfc46938, __n=32768) at /usr/include/c++/7/bits/stl_vector.h:172
#7  0x0000000008187e88 in std::vector<nova::InstMessage, std::allocator<nova::InstMessage> >::_M_fill_insert (this=0x7fffdfc46938, __position=non-dereferenceable iterator for std::vector, __n=32768, __x=...)
    at /usr/include/c++/7/bits/vector.tcc:505
#8  0x0000000008186032 in std::vector<nova::InstMessage, std::allocator<nova::InstMessage> >::resize (this=0x7fffdfc46938, __new_size=32768, __x=...) at /usr/include/c++/7/bits/stl_vector.h:712
#9 ...

Based on the information of the stack, the problem occurs when it tries to allocate memory for a std::vector.

Do you have any idea what the problem would be? By the way, it works quite well if I change to use Specialized type(特化型) Kaname-Shiki, or use TCMalloc or the default malloc.

benchmark sources

Hi Emura,

I am interested to possibly include your benchmarks in my benchmark suite (mimalloc-bench) but I could not find the sources of your benchmarks -- can you make them available?

All the best,
Daan

Static initialization

I made an allocator wrapper class template in order to use KanameShiki as an std::vector allocator. It works fine when dynamically allocating memory during runtime but fails if used during the static initialization on the program startup. E.g.:
inline static const std::vector<int, KanameShikiAlloc<int>> BAD_DAYS = { 20150322, 20140204 };
in a header file under Windows 10 using MSVC 2019.

Exception thrown: read access violation.
oReserver was 0xC.

test.exe!KanameShiki::LocalReserver::Segment::Alloc() Line 55	C++
 	test.exe!KanameShiki::LocalReserver::Alloc(unsigned __int64 s) Line 143	C++
 	test.exe!KanameShiki::LocalCntx::ReserverAlloc(unsigned __int64 s) Line 62	C++
 	test.exe!KanameShiki::LocalReserverAlloc(unsigned __int64 s) Line 127	C++
 	test.exe!KanameShiki::LocalPool::operator new(unsigned __int64 sThis, unsigned short o, const std::nothrow_t & __formal) Line 144	C++
 	test.exe!KanameShiki::LocalCntx::NewPool(unsigned short o) Line 86	C++
 	test.exe!KanameShiki::LocalCntx::Alloc(unsigned __int64 s) Line 72	C++
 	test.exe!KanameShiki::Alloc(unsigned __int64 s) Line 150	C++
 	test.exe!kanameAlloc<std::_Container_proxy>::allocate(unsigned __int64 n) Line 15	C++
 	[External Code]	
 	test.exe!`dynamic initializer for 'NConst::VOLAT_PERIODS''() Line 81	C++
 	test.exe!_initterm(void(*)() * first, void(*)() * last) Line 22	C++

For comparison, tcmalloc works fine in this case.

What seems to be happening is that mapRealm array is only initialized in the GlobalReserver constructor, so the program references a nullptr when trying to allocate memory.

Hint for Minimal Heap Size

Hi, KanameShiki is quite nice! I wonder if it's possible to specify a minimal heap size that KanameShiki should hold, so that KanameShiki will allocate memory accodingly in advance.

The problem is that my program suffers from high delay at the beginning and I found the reason was that the memory allocator needs to frequently ask the OS for more memory at the beginning. When the amount of memory is sufficient, the delay becomes small. Therefore, I am looking for a memory allocator where I can tell it a minimal heap size so that the allocator can ask the OS for that amount of memory in advance, to avoid future frequent interaction with the OS. It would be better that the minimal heap size can be adjusted anytime during execution.

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.