ned14 / nedmalloc

An EXTREMELY FAST portable thread caching malloc implementation written in C for multiple threads without lock contention based on dlmalloc. Optimised for x86 and x64. Compatible with C++. Can patch itself into existing binaries on Windows.
http://www.nedprod.com/programs/portable/nedmalloc/
Boost Software License 1.0
402 stars 77 forks source link

broken compilation when ENABLE_LARGE_PAGES enabled #12

Closed Gerilgfx closed 11 years ago

Gerilgfx commented 11 years ago

broken compilation, when ENABLE_LARGE_PAGES is enabled:

gethugepagesizet gethugepagesize = (gethugepagesize_t) dlsym(RTLD_DEFAULT, "gethugepagesize");

error: ‘RTLD_DEFAULT’ was not declared in this scope|

solution: include dlfcn.h should included on *nix to access these macros

(but only include this header, when ENABLE_LARGE_PAGES is enabled, since it causes extra linking dependency)

ned14 commented 11 years ago

Not sure how well this new code works - my test machine doesn't show huge page size in its /proc/meminfo, so it's a bit hard to test. Do let me know how it fares on your machine.

Gerilgfx commented 11 years ago

its not working, fread returns 0

ned14 commented 11 years ago

Ok, try it again.

Gerilgfx commented 11 years ago

now it works, but it seems my os neither supports this feature

cat /proc/meminfo MemTotal: 5864520 kB MemFree: 2686964 kB Buffers: 333252 kB Cached: 780968 kB SwapCached: 0 kB Active: 2028392 kB Inactive: 644352 kB Active(anon): 1558668 kB Inactive(anon): 24544 kB Active(file): 469724 kB Inactive(file): 619808 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 1172 kB Writeback: 0 kB AnonPages: 1558532 kB Mapped: 282704 kB Shmem: 24680 kB Slab: 111500 kB SReclaimable: 73236 kB SUnreclaim: 38264 kB KernelStack: 3264 kB PageTables: 32968 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 2932260 kB Committed_AS: 3405628 kB VmallocTotal: 34359738367 kB VmallocUsed: 310028 kB VmallocChunk: 34359425763 kB HardwareCorrupted: 0 kB AnonHugePages: 602112 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 1702464 kB DirectMap2M: 4325376 kB DirectMap1G: 0 kB

also, compiling with ENABLE_LARGE_PAGES makes this line to execute:

      printf("Hugepages=%u, size=%u\n", _hugepages, _hugepagesize);

however, i do not have DEBUG defined, and i have NDEBUG defined. maybe enabling ENABLE_LARGE_PAGES enables the debug somewhere? or there is a non-properly terminated ifdef in the code.

ned14 commented 11 years ago

Hopefully fixed now!