Commit Graph

686 Commits

Author SHA1 Message Date
daan
ee323aabac fix vs2017 build 2019-11-02 15:56:21 -07:00
daan
fd9d8c85ae change numa support on linux to use getcpu 2019-11-02 11:55:03 -07:00
daan
70748ee1ee fix missing semi colon 2019-11-02 10:39:09 -07:00
daan
a69016c33e improve and document numa support 2019-11-02 10:30:16 -07:00
daan
2c12d7f223 optimized numa calls; better Linux support 2019-11-01 22:01:52 -07:00
daan
57dd69265a normalize numa node 2019-11-01 20:30:01 -07:00
daan
2d10c78587 fix linux compilation 2019-11-01 20:19:00 -07:00
daan
3fadf4abaf initial numa awareness for regions 2019-11-01 20:01:08 -07:00
daan
a6499be074 initial numa support for arenas 2019-11-01 19:53:07 -07:00
daan
aaf01620f4 improve allocation of the huge OS page arena 2019-10-31 19:39:49 -07:00
daan
d36d04b4a6 add arena for huge page management 2019-10-31 15:35:10 -07:00
daan
8725a88fba fix assertion in debug secure mode 2019-10-30 15:22:40 -07:00
daan
4a4d74927c protect against double-free in multi-threaded free list 2019-10-30 14:53:21 -07:00
daan
6cf16b1201 fix reset error on windows when disabling eager commit option 2019-10-30 14:32:28 -07:00
daan
b052d3b731 enable double free and heap corruption detection in debug mode 2019-10-28 15:54:33 -07:00
daan
87bdfbb9b6 use more conservative retire strategy 2019-10-28 14:12:06 -07:00
daan
081e2d1eb6 fix statistics display 2019-10-28 13:43:42 -07:00
daan
28d4ec4c5a fix statistics accounting of huge pages 2019-10-28 13:14:14 -07:00
daan
5dfdc092b5 improve windows warning message 2019-10-28 12:26:57 -07:00
daan
25246070ae fix double free check in secure = 4 mode; inline _mi_ptr_cookie 2019-10-19 08:34:18 -07:00
daan
2affdbbd2e stronger secure mode when defining MI_SECURE=4: checks for double free, corrupted free list, and invalid pointer frees. Performance is impacted but not too much -- more perf testing is needed 2019-10-18 18:11:04 -07:00
daan
fdfa6ed260 fix warnings at high warning level in msvc 2019-10-17 16:56:57 -07:00
daan
5de851a84d update page_flags to have more portable definition 2019-10-17 16:48:16 -07:00
daan
93b4281b82 ensure randomized huge page start address in 1GiB aligned 2019-10-17 12:35:35 -07:00
daan
454bc67338 increase delayed output buffer to 32k 2019-10-17 12:14:15 -07:00
daan
26c27fbf58 use uint8_t bit fields, and improve portability of page_flags type 2019-10-17 12:07:26 -07:00
Johannes Schindelin
0fd0122c0a Avoid compiler warning when casting the result of GetProcAddress()
It is most unfortunate that the return type of `GetProcAddress()` is
`FARPROC` (which is essentially `intptr_t(*)(void)): this type cannot
be cast by GCC without warnings to anything but the generic function
pointer type `void(*)(void)`.

Let's work around that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-10-17 20:43:18 +02:00
Johannes Schindelin
5bd8ea2e4f Repeat mi_decl_allocator in functions' definitions
Quite a few functions are declared with that attribute, and VS 2019
complains if the definition does not repeat it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-10-17 20:43:18 +02:00
daan
08d83cc33d disallow regular allocation from the huge reserved area 2019-10-17 09:24:57 -07:00
daan
a96c90db5d remove old windows overriding method 2019-10-17 09:22:23 -07:00
daan
480f7683a9 cleanup delayed output 2019-10-12 10:42:04 -07:00
Daan Leijen
5e9b37dc4e add delayed output buffer 2019-10-12 10:21:42 -07:00
daan
1de6c22b49 remove incorrect region_count comment 2019-09-17 18:07:32 -07:00
daan
5744f90882 remove thread init/done verbose messages 2019-09-17 17:35:20 -07:00
daan
60efb62155 make secure a build option only 2019-09-17 17:31:42 -07:00
daan
d72b5350e3 fix error code on mprotect failure 2019-09-17 17:31:25 -07:00
daan
adf8e30eda ensure large page privileges are acquired on windows when calling reserve_huge_os_pages 2019-09-14 15:23:28 -07:00
daan
24777f6a91 limit aligned allocation to power-of-two alignment 2019-09-11 17:49:28 -07:00
daan
050e7cedf4 roll back commit 0aec6d93 on alignment >= size as it breaks assertions in tensorflow 2019-09-11 15:48:44 -07:00
Daan Leijen
1909cfb346 refine mi_os_good_alloc_size and use it for huge pages (to ensure realloc is bounded as in #153 2019-09-10 13:26:51 -07:00
Daan Leijen
d278c26c0e round huge page sizes into 12.5% increments (issue #153) 2019-09-10 07:54:31 -07:00
daan
ce81af1119 use mi_is_power_of_two when possible (pr #118) 2019-09-09 08:12:50 -07:00
daan
b104e434e4 fix volatile declaration on function 2019-09-09 08:07:35 -07:00
daan
23155c5d71 add recursion guard to deferred callback 2019-09-09 08:02:41 -07:00
daan
e227341f5b fix mi_collect being called with empty heap (issue #150) 2019-09-09 07:54:36 -07:00
daan
7b63bc4211 add alignment check to aligned_alloc for C11 compliance 2019-09-07 12:02:22 -07:00
daan
0aec6d9302 don't align to sizes greater than than the allocation size 2019-09-07 12:01:54 -07:00
daan
b241910810 don't allocate more than PTRDIFF_MAX on aligned allocations 2019-09-07 11:52:21 -07:00
daan
f2f7c8d0e9 fix volatile declaration on function pointer 2019-09-07 09:18:29 -07:00
daan
89858ab791 improve page_free_extend performance slightly; do not maintain expensive statistics in release mode 2019-09-06 16:48:48 -07:00
daan
47fc73d694 fix c++ compilation; make default output non-atomic 2019-09-06 11:51:22 -07:00
daan
f38fcf79eb ensure addresses of large aligned allocations are randomized 2019-09-06 09:19:26 -07:00
Jakub Szymanski
1a7b1783fa changed strategy to reduce contention for region search and vs2019 project fix 2019-09-05 08:13:52 -07:00
daan
2be3208734 add wrap-around for large aligned allocations on Windows and Linux 2019-09-04 21:03:00 -07:00
daan
e73982c4cf better alignment for large and huge pages inside a segment 2019-09-04 18:42:37 -07:00
daan
3bbc047ba6 reserve huge pages returns actual number of pages reserved 2019-09-04 12:26:02 -07:00
daan
6c43ae2bde add later thread-done invokation; add mi_is_redirected call 2019-09-04 12:00:41 -07:00
daan
3c563816c0 read regions count on every loop iteration 2019-09-03 18:25:01 -07:00
daan
aea21486dd fix regions_count tracking in case of concurrent region allocations 2019-09-03 18:20:56 -07:00
daan
a6a956c589 add back zero initialized re-allocation 2019-09-03 10:57:39 -07:00
daan
7a91368108 pass page to block_zero_init and extend to block_size 2019-09-03 10:11:24 -07:00
daan
739d11313c fix commit zero on windows 2019-09-02 14:53:22 -07:00
daan
d1bd1644d5 support zero-initialized memory detection 2019-09-02 13:16:52 -07:00
daan
31726c6554 fix type; fix comment 2019-09-02 10:18:34 -07:00
daan
d6e35ffd83 Merge branch 'dev' into dev-exp 2019-09-02 10:10:08 -07:00
daan
783ae72743 Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev 2019-09-02 09:53:30 -07:00
daan
e874844562 update redirection to include fixes for x86 2019-09-01 12:18:29 -07:00
daan
ab5af8fdad merge from dev 2019-08-30 14:38:28 -07:00
daan
9fc726619a guard against passing stdin/stderr as output 2019-08-30 14:37:04 -07:00
daan
86ee1722f5 in verbose mode, list all options at startup 2019-08-30 14:34:46 -07:00
daan
f35f643508 merge from dev 2019-08-29 09:52:22 -07:00
daan
7bf12c7b5f make output function configurable; remove <stdio.h> from standard includes 2019-08-29 09:42:50 -07:00
daan
4819d3f78f expose mi_stats_merge function 2019-08-29 09:01:00 -07:00
daan
4b39c0b06e fix eager_delay test, and allow large OS pages even without eager commit enabled 2019-08-29 07:55:57 -07:00
daan
64c1d6de86 fix mi_likely branch that was marked as unlikely 2019-08-29 07:50:35 -07:00
daan
e8c7505853 only set has_aligned flag if really necessary 2019-08-29 07:49:40 -07:00
daan
154fd471a1 fix comparison warning 2019-08-29 07:48:15 -07:00
daan
d381fcd9fa rename lazy to eager_commit_delay 2019-08-28 12:09:23 -07:00
daan
9af51506a6 track commit and is_large status more precisely 2019-08-28 11:58:30 -07:00
David Carlier
3903a10e93 FreeBSD (and possibly NetBSD) build fix. 2019-08-28 07:17:58 +00:00
daan
a551f3abc4 more precise commit statistics 2019-08-27 18:08:03 -07:00
daan
18e02c3766 try allocating non-eager segments in non-fixed memory 2019-08-27 17:02:56 -07:00
daan
23b5593af6 Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev 2019-08-27 16:40:47 -07:00
David Carlier
b72a2d9659 macOS: anonymous page ID make it as env var. 2019-08-27 19:17:41 +01:00
daan
db8d443ae6 track more precisely if memory is fixed or committed 2019-08-26 22:45:26 -07:00
daan
eea093000a graceful fallback for huge page allocation on Linux 2019-08-26 13:47:52 -07:00
daan
3d8c331a1c search regions always from the lowest index 2019-08-26 12:41:59 -07:00
daan
8b06ab1e49 fix check on gigabyte alignment of huge os pages on windows 2019-08-26 12:41:35 -07:00
daan
a654732d99 merge from dev new atomics 2019-08-26 12:30:03 -07:00
daan
2c19388bcf initialize mimalloc options at process load 2019-08-26 11:44:41 -07:00
daan
7ce9c02fd4 make cas weak use release memory order; improve free assembly 2019-08-26 08:20:26 -07:00
daan
5c7c106d62 strengthen some atomic operations for weak memory models 2019-08-26 08:11:58 -07:00
daan
2159c22415 fix atomic declaration on windows 2019-08-25 23:06:18 -07:00
daan
baabc77503 use proper atomic initialization macros 2019-08-25 23:02:41 -07:00
daan
e8664001f7 Use standard _Atomic declarations and clean up atomic operations 2019-08-25 22:59:12 -07:00
daan
6e360d34ee fix 1GB huge page flag on Linux 2019-08-25 13:15:26 -07:00
daan
23c35f4aba merge from dev 2019-08-25 13:07:07 -07:00
daan
b86c851cca put segment cache behind an option and disable by default 2019-08-25 12:35:14 -07:00
daan
038e8fd7d6 reduce retire size 2019-08-25 12:10:18 -07:00
daan
c3c6401633 merge from master; fix windows environment reading 2019-08-25 11:36:34 -07:00
daan
7972b64a82 resolve race on option initialization 2019-08-25 11:18:16 -07:00
daan
a431d80fc3 better object sizes for large objects 2019-08-25 10:20:03 -07:00
daan
23812cc0ac do not keep a queue of huge pages and free them directly 2019-08-24 15:45:14 -07:00
daan
d04d379f66 fix merge conflicts 2019-08-23 21:44:07 -07:00
daan
d3224d0bba Merge branch 'dev' into dev-win 2019-08-23 21:42:32 -07:00
daan
6c6fcad242 remove threadid from pages and keep page flags separate (cherry picked) 2019-08-23 21:42:24 -07:00
daan
15552eba79 ensure volatile declaration for abandoned_next field 2019-08-23 21:39:27 -07:00
daan
25ea9cf142 on windows use 4TiB area for aligned allocation 2019-08-23 21:38:45 -07:00
daan
acde83543f remove threadid from pages and keep page flags separate 2019-08-23 14:08:00 -07:00
daan
b511309709 ensure volatile declaration for abandoned_next field 2019-08-23 13:44:43 -07:00
daan
a1c5218ff5 use 4TiB area on windows 64-bit for aligned allocation 2019-08-23 11:33:06 -07:00
daan
5d3bf1c844 don't commit or reset in huge OS pages 2019-08-23 11:22:35 -07:00
daan
71121a7457 Merge branch 'dev-win' into dev-exp 2019-08-21 11:12:25 -07:00
daan
e7bd8c5d14 merge with dev-win 2019-08-21 11:11:40 -07:00
Jakub Szymanski
ee475fd8cd add warning when no avaiable mem 2019-08-21 11:11:36 -07:00
Daan Leijen
13ca6a088b Merge branch 'dev' into dev-win 2019-08-21 08:11:26 -07:00
Daan Leijen
311794b296 remove debug statement 2019-08-21 08:11:16 -07:00
Daan Leijen
12257e5bc1 fix thread-id reset on page abandonment 2019-08-21 08:09:28 -07:00
Daan Leijen
cc6d14c55b fix thread-id reset on page abandonment 2019-08-21 08:06:40 -07:00
daan
b005f7cdbf Merge branch 'dev' into dev-win 2019-08-20 09:46:05 -07:00
daan
ff88361329 lower block size for keeping retired pages 2019-08-20 09:45:50 -07:00
daan
d81b800e12 optimize stat counter increase 2019-08-20 08:58:53 -07:00
daan
86d4ded831 Merge branch 'dev' into dev-exp 2019-08-20 08:27:46 -07:00
daan
a5071eb510 Merge branch 'dev' into dev-win 2019-08-20 07:50:03 -07:00
daan
03d994648a better option interface: option_enable, option_disable, and option_set_enabled 2019-08-20 07:47:50 -07:00
daan
7a2e0df5ea merge from dev 2019-08-20 07:37:46 -07:00
daan
1e0cd575a5 do not export DllEntry on windows 2019-08-20 07:06:53 -07:00
daan
d52e4039b6 remove the reset_discards option 2019-08-20 07:06:11 -07:00
daan
79487dbedf add checks for right option order 2019-08-20 06:58:51 -07:00
daan
29e73dec22 Merge branch 'dev' into dev-win 2019-08-19 21:25:09 -07:00
daan
8c795cc37d remove test statement 2019-08-19 21:24:38 -07:00
daan
05631ebfc4 Merge branch 'dev' into dev-win 2019-08-19 21:23:04 -07:00
daan
d2324f1c2a always check large_os_pages enabled option so it can be changed during the running of the program 2019-08-19 21:22:24 -07:00
daan
48a7d64bdd if region overcommitting due to contention save it to a further slot 2019-08-19 21:20:24 -07:00
daan
2066e2797d don't allow allocations larger than PTRDIFF_MAX, issue #121 2019-08-19 19:29:27 -07:00
daan
74299646bb fix heap cookie and random order on initialization (issue #131) 2019-08-19 19:22:13 -07:00
daan
b46bacc180 fix absorb heap (issue #132) 2019-08-19 19:19:09 -07:00
daan
82e1b40166 Merge branch 'master' into dev 2019-08-19 19:13:25 -07:00
daan
a8b24472cb use 1GiB huge pages on windows when reserving upfront 2019-08-19 18:16:12 -07:00
daan
0e639addb0 add environment option to reserve huge pages upfront 2019-08-19 14:14:50 -07:00
daan
5b2f4184b3 Merge branch 'dev' into dev-exp 2019-08-19 11:37:39 -07:00
daan
741f37e1f0 always check large_os_pages enabled option so it can be changed during the running of the program 2019-08-19 11:17:00 -07:00
daan
42dedb00ec initial implementation of mi_os_reserve_huge_pages 2019-08-19 11:10:06 -07:00
daan
61ebaaa403 Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev 2019-08-19 08:10:11 -07:00
Daan Leijen
367fb046ec Merge branch 'dev' into dev-win 2019-08-16 18:40:56 -07:00
Daan Leijen
069c26dbab fix small object size check in mi_segment_page_alloc 2019-08-16 18:40:30 -07:00
daan
6d11e59250 fix to avoid potential linear behavior in page collect 2019-08-14 07:46:38 -07:00
David Carlier
b0003cb101 linux build correction
MAP_HUGE_2MB is linux specific and the related header
is not automatically included.
2019-08-14 15:07:13 +01:00
daan
d3375f2bac fix assertion in mi_free_size 2019-08-12 13:50:41 -07:00
daan
ab53da679e Merge branch 'dev' into dev-exp 2019-08-12 13:43:29 -07:00
daan
178ea0840c roll back commit #72d8608 to avoid spin lock contention on region allocation 2019-08-12 13:40:19 -07:00
daan
113a3cc1a2 Merge branch 'dev' into dev-exp 2019-08-12 09:20:16 -07:00
daan
8ca79b5359 Hide MEM_EXTENDED_PARAMETER to compile on older SDK's 2019-08-12 08:58:22 -07:00
daan
8b2194c160 merge from master 2019-08-12 15:50:21 -07:00
JeanMiK
3f43cbe6a1 Fix C++ signature of function mi_is_in_heap_region
Original code did not compile with MI_USE_CXX=ON as function
mi_is_in_heap_region was declared noexcept through macro mi_attr_noexcept
but defined without specification, i.e. implicitly with noexception(false)

Just adding the macro in the definition is enough to fix the issue
(tested with gcc 8.3.5)
2019-08-12 12:43:01 +02:00
daan
63d4d2ad9c Merge branch 'dev' into dev-exp 2019-08-12 01:59:31 -07:00
daan
648f535c80 improve support for transparent huge pages on Linux (pr #115) 2019-08-11 18:23:31 -07:00
daan
f35c2c5201 improve message printing from redirection module 2019-08-11 16:38:58 -07:00
daan
0c912445c4 Merge branch 'dev' into dev-exp 2019-08-11 14:46:53 -07:00
daan
feb7b2c160 improve bit range skipping in region search 2019-08-11 13:49:12 -07:00
daan
3a75a9d5be use bit-scan instruction to speed up region search 2019-08-11 13:03:00 -07:00
daan
0fd898315c per thread region search index 2019-08-11 12:15:13 -07:00
daan
2e924150ae further layout improvement for msvc code generation 2019-08-11 11:30:24 -07:00
daan
7b105c4810 improve layout of page for x64 2019-08-11 10:31:00 -07:00
daan
2c1da9d194 fix scalar initialization of page flags 2019-08-11 09:03:52 -07:00
daan
d71e67b689 Merge branch 'dev' into dev-exp 2019-08-11 09:00:39 -07:00
daan
3a171624bd Merge branch 'master' into dev 2019-08-11 08:59:38 -07:00
daan
a73daf1804 avoid mod operation in region allocation and limit extension 2019-08-11 08:54:32 -07:00
daan
756f4b2724 improve bit scanning code in region allocation 2019-08-11 08:48:19 -07:00
daan
6435887657 add comment on wait strategy in region allocation 2019-08-11 08:18:51 -07:00
daan
f5902a7a82 ensure webassembly allocation sizes are page aligned 2019-08-11 08:06:17 -07:00
daan
a1384bff72 avoid atomic read on aligned allocation on Linux 2019-08-11 08:00:10 -07:00
daan
dbe010f2d4 add huge and giant stats; increase bins 2019-08-10 20:51:37 -07:00
daan
737b05cc25 remove unused fields from OS thread local data 2019-08-10 17:50:27 -07:00
daan
ed785253bf restructure the page flags to use explicit masks 2019-08-10 17:48:00 -07:00
daan
74a5c17178 update order of options; make eager_region_commit 0 on windows by default 2019-08-10 15:44:55 -07:00
daan
2fee6f98d7 Merge branch 'master' into dev 2019-08-10 15:23:43 -07:00
daan
2b9e3ed01b merge from dev-win 2019-08-10 15:19:04 -07:00
daan
78a70ada2e Fix option reading even when preloading on Windows 2019-08-10 15:17:40 -07:00
daan
d9cbc457b8 Merge branch 'dev-win' into dev-exp 2019-08-10 15:11:51 -07:00
daan
6f3bc87dcd merge from dev 2019-08-10 10:26:46 -07:00
daan
8ae2492eee fix arguments for the heap visitor function, issue #124 2019-08-10 10:14:01 -07:00
Daan
5b4c4ac959
Merge pull request #117 from devnexen/darwin_anon_monitor
darwin, tracking anonymous page lifetime.
2019-08-10 09:58:35 -07:00
daan
ccc78302bf fix double assignment (#125, by @ebudai) 2019-08-10 09:53:00 -07:00
daan
3d9d70bce0 add new redirection module; fix environment reading at preloading 2019-08-10 09:39:36 -07:00
daan
7b16aa9302 remove accidental commit of different size bins experiment 2019-08-09 11:22:38 -07:00
daan
442bad9190 add good-fit for allowing larger blocks in smaller segments 2019-08-09 11:18:38 -07:00
daan
5e56b40fe6 improve page flags handling 2019-08-08 17:18:49 -07:00
daan
de57686dac Merge branch 'dev-win' of https://github.com/microsoft/mimalloc into dev-win 2019-08-08 15:23:27 -07:00
daan
6596e970a5 move in_full and has_aligned into page threadid for a single test in mi_free 2019-08-08 15:23:18 -07:00
daan
55778d2fe4 improved stats 2019-08-08 11:36:13 -07:00
daan
56778fe7d2 split normal and secure extend in a separate routine 2019-08-06 18:57:53 -07:00
Jakub Szymanski
0e8241c140 change from MIMALLOC_OVERRIDE to MIMALLOC_DISABLE_OVERRIDE 2019-07-30 10:36:00 -07:00
David Carlier
82ab9b4bd6 tracking anonymous page lifetime on macOS.
this platform allows to tag them per application up to 255.
2019-07-27 23:05:05 +01:00
daan
bbf97fa02d merge from 'dev-exp'; add support for MIMALLOC_OVERRIDE environment variable 2019-07-26 12:06:15 -07:00
daan
613d0c1993 merge 095a87b 2019-07-23 18:00:07 -07:00
daan
095a87be2e add recursion guard for overriding in windows 2019-07-23 17:57:27 -07:00
daan
3d6feead60 add heap region check to cfree 2019-07-23 15:54:47 -07:00
daan
dd79b662f8 restore to old-style windows override; fix debug mode 2019-07-23 15:51:08 -07:00
daan
fa5dc17621 fix merge conflicts 2019-07-23 15:09:54 -07:00
daan
a022049705 remove old comment 2019-07-23 15:00:13 -07:00
daan
189ad0f81d small optimizations, use bitwise aligne 2019-07-23 15:00:13 -07:00
daan
66b8c37ab3 ensure C++ compilation on windows 2019-07-23 15:00:13 -07:00
daan
0b4d74a566 merge 2019-07-23 15:00:13 -07:00
daan
b611c7fb34 use atomic ops to guard large page tries on windows 2019-07-23 15:00:13 -07:00
daan
7b7c36c8c7 use hinted address to mmap to reduce mmap calls 2019-07-23 14:59:57 -07:00
Jim Huang
b5e26bedb1 Enforce strict include-what-you-use policy
The include-what-you-use (IWYU) policy is beneficial to faster
compilation and fewer recompilations. Many build tools, such as GNU make,
provide a mechanism for automatically figuring out what .h files a .cc
file depends on. These mechanisms typically look at #include lines. When
unnecessary #includes are listed, the build system is more likely to
recompile in cases where it is not necessary.

With the enforcement, header file <include/mimalloc.h> no longer
includes <stdlib.h>.

Reference:
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md
2019-07-23 14:59:57 -07:00
daan
65037d051b improved debug warning for freeing invalid pointers 2019-07-23 14:59:57 -07:00
daan
2eb607d03f re-add missing thread_init needed when running in debug mode 2019-07-23 14:59:57 -07:00
Jim Huang
28b874129a Avoid using strlen function in loop 2019-07-23 14:59:57 -07:00
Jim Huang
3e9c953eea Add branch prediction hint for mi_option_get
mi_option_get is called frequently in stress tests, and the patch adds
extra hint to the compiler to emit instructions that will cause branch
prediction to favour the "likely" side of a jump instruction.
2019-07-23 14:59:49 -07:00
caixiangyue
7266e7006a fix typo 2019-07-23 14:59:49 -07:00
daan
46b11fa0a4 add comment about large pages 2019-07-23 14:59:49 -07:00
daan
6ca8b3fd89 remove old comment 2019-07-22 21:25:57 -07:00
daan
f0530b6a83 small optimizations, use bitwise aligne 2019-07-22 20:51:12 -07:00
daan
7c26ce9280 ensure C++ compilation on windows 2019-07-22 10:27:14 -07:00
daan
80e09ef44e merge from dev 2019-07-22 10:16:59 -07:00
daan
e90938fb4b merge 2019-07-22 10:10:45 -07:00
daan
7555260759 Merge branch 'jserv-include-what-you-use' into dev 2019-07-22 10:07:03 -07:00
daan
959d9289b1 merge and improve to upper case in options 2019-07-22 10:06:45 -07:00
Daan
80400c9946
Merge pull request #111 from jserv/avoid-strlen-in-loop
Avoid using strlen function in loop
2019-07-22 09:51:02 -07:00
Daan
cf8f46c263
Merge pull request #110 from jserv/options-branch-predict-hints
Add branch prediction hint for mi_option_get
2019-07-22 09:49:44 -07:00
daan
272a8e03e4 use atomic ops to guard large page tries on windows 2019-07-21 17:13:36 -07:00
daan
069f52523f use hinted address to mmap to reduce mmap calls 2019-07-21 17:08:09 -07:00
Jim Huang
1e27cef873 Enforce strict include-what-you-use policy
The include-what-you-use (IWYU) policy is beneficial to faster
compilation and fewer recompilations. Many build tools, such as GNU make,
provide a mechanism for automatically figuring out what .h files a .cc
file depends on. These mechanisms typically look at #include lines. When
unnecessary #includes are listed, the build system is more likely to
recompile in cases where it is not necessary.

With the enforcement, header file <include/mimalloc.h> no longer
includes <stdlib.h>.

Reference:
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md
2019-07-22 04:54:14 +08:00
daan
df33efb19a improved debug warning for freeing invalid pointers 2019-07-21 13:09:34 -07:00
daan
40cb631683 re-add missing thread_init needed when running in debug mode 2019-07-21 13:03:51 -07:00
Jim Huang
c382c72cf2 Avoid using strlen function in loop 2019-07-21 22:30:42 +08:00
Jim Huang
1ffa48cc61 Add branch prediction hint for mi_option_get
mi_option_get is called frequently in stress tests, and the patch adds
extra hint to the compiler to emit instructions that will cause branch
prediction to favour the "likely" side of a jump instruction.
2019-07-21 21:42:00 +08:00
daan
f0de0b6f68 remove old windows override code 2019-07-19 09:33:14 -07:00
daan
2ac2c6a1c3 fix format of error messages 2019-07-19 09:27:32 -07:00
daan
fcd0253ac9 limit number of error messages to 10 2019-07-19 09:27:14 -07:00
daan
dd5fa88c45 check better for valid pointers in free in debug mode 2019-07-19 09:26:51 -07:00
caixiangyue
a215049b4a fix typo 2019-07-19 16:23:14 +08:00
daan
fd6fd23470 make eager-region-commit false by default on windows 2019-07-18 21:48:58 -07:00
daan
8dad858888 update to correct project settings for visual studio 2019-07-18 21:41:28 -07:00
daan
93c8a5b693 full overriding api supported 2019-07-18 21:12:40 -07:00
daan
306a542336 add mimalloc-override header file and use C++ compilation with msvc 2019-07-18 20:28:29 -07:00
daan
12e0a04052 compile as C++ under msvc 2019-07-18 19:52:29 -07:00
daan
c228ecefd8 update for new dynamic direction on windows 64-bit 2019-07-18 18:59:32 -07:00
daan
f646cc925d add is_in_heap_region function 2019-07-17 15:37:36 -07:00
daan
7b5ba96e8e merge from dev 2019-07-15 18:58:04 -07:00
daan
72d8608333 avoid thread over-allocation on initial region allocations 2019-07-15 17:35:43 -07:00
daan
7ea9cf8d1f add region collection 2019-07-15 14:53:03 -07:00
daan
89bdcd43b2 fix bit search index 2019-07-15 14:33:15 -07:00
daan
08e0f14c2a document experimental options 2019-07-15 14:32:54 -07:00
daan
ea9dbd1036 set better default options for performance 2019-07-15 13:19:26 -07:00
daan
0196622fff Merge branch 'dev' into dev-exp 2019-07-15 11:10:12 -07:00
Daan
ad45dbf0e5
Merge pull request #32 from jedisct1/wasm
Port to WebAssembly
2019-07-15 11:03:46 -07:00
Daan
60e9d3f69d
Merge pull request #81 from devnexen/mac_large_page_2mb
initial support of 2MB pages on Mac
2019-07-15 10:56:53 -07:00
daan
bd6abd2463 add comment about large pages 2019-07-15 10:07:23 -07:00
daan
76a5adfbfe Merge branch 'dev' into dev-win 2019-07-15 10:04:55 -07:00
daan
d706109b35 don't decommit/reset parts of a region when using large os pages 2019-07-15 10:04:43 -07:00
daan
beef7a8c70 Merge branch 'dev' into dev-exp 2019-07-15 09:47:09 -07:00
daan
7ba6192dd5 always pass commit flag to large page allocation on windows 2019-07-15 09:46:58 -07:00
daan
08c873c250 Merge branch 'dev' into dev-exp 2019-07-14 20:35:01 -07:00
daan
4e855988b4 Merge branch 'dev' into dev-win 2019-07-14 20:34:05 -07:00
daan
c4426e1555 add sized delete to windows override 2019-07-14 20:28:33 -07:00
daan
461b8aed80 more complete C++ support for compliance and performance 2019-07-14 19:56:33 -07:00
Frank Denis
9129ab0f64 Port to WebAssembly 2019-07-15 02:22:41 +02:00
daan
8dc0b5345b Merge branch 'dev' into dev-exp 2019-07-14 16:50:38 -07:00
daan
c5da02788f Merge branch 'dev' into dev-win 2019-07-14 16:50:18 -07:00
daan
49ceb4d018 refactor delayed_free code 2019-07-14 16:48:53 -07:00
daan
5ad2effb39 use standard compliant compilation of the thread_free atomic field 2019-07-14 16:20:27 -07:00
daan
2cf419c9bc Merge branch 'master' into dev 2019-07-14 14:50:39 -07:00
daan
adf65a100e be less aggressive in page reuse to reduce memory footprint 2019-07-14 14:13:47 -07:00
daan
672506a3b3 merged with dev-win 2019-07-14 12:57:47 -07:00
daan
f93a49446f Merge branch 'dev' into dev-win 2019-07-14 12:55:52 -07:00
daan
e60a5db908 fix cache eviction of smaller segments 2019-07-14 12:52:58 -07:00
daan
89b7ffa8ed link DiscardVirtualMemory dynamically as it is not supported on every windows 2019-07-13 08:12:16 -07:00
daan
84a292538c merge with medium pages 2019-07-12 20:39:29 -07:00
daan
a927c07de9 merge medium pages 2019-07-12 20:27:56 -07:00
daan
42cf5e1580 reintroduce support for medium size pages 2019-07-12 20:11:39 -07:00
linkwk7
d4eabf33b6 Fix typo in comments 2019-07-12 22:05:07 +08:00
daan
8a6b474fa0 merge from dev 2019-07-11 16:32:11 -07:00
daan
a932e43650 experiment with larger small pages 2019-07-11 15:44:37 -07:00
daan
9e9208eae8 Merge branch 'dev' into dev-win 2019-07-11 15:22:09 -07:00
daan
1fdb4b288f more eager handling of non-local frees 2019-07-11 15:21:57 -07:00
daan
1377b26b0a Merge branch 'dev' into dev-win 2019-07-11 13:31:02 -07:00
daan
72a39c0bb1 initial fix for delayed freeing of huge pages transferred between threads 2019-07-11 13:30:40 -07:00
daan
f844665c9f merge from dev-win 2019-07-10 22:57:37 -07:00
daan
c555e09504 Merge branch 'dev' into dev-win 2019-07-10 22:48:20 -07:00
daan
da0fb1e53f merge dev-win 2019-07-10 20:50:32 -07:00
daan
6deea16d2d add segment count to internal statistics 2019-07-10 19:54:46 -07:00
daan
ef4359b272 fix abondoned segment counter, and free list adding 2019-07-10 16:33:49 -07:00
daan
b80b0837ab Merge branch 'dev-win' into dev-exp 2019-07-10 07:50:26 -07:00
daan
5b6f4ecc12 fix compilation warning 2019-07-10 07:50:04 -07:00
daan
224951695a enable non eager commit 2019-07-10 07:24:56 -07:00
daan
46a9e51f74 enable non eager-commit flag 2019-07-10 07:17:21 -07:00
daan
a6c5e2cffd Merge branch 'master' into dev 2019-07-09 23:49:29 -07:00
daan
95afe453f4 fix compilation warning on windows, issue #94 2019-07-09 23:49:12 -07:00
daan
d8c47bfed2 ensure commit of reused cached segments 2019-07-09 23:37:59 -07:00
daan
3192ca4682 merge with dev-win 2019-07-09 23:34:17 -07:00
daan
3009a7b1fe support non- eager_commit; on larson reduces commit charge 10x, but other benchmarks often see no improvement 2019-07-09 21:34:56 -07:00
daan
2ef1f1df94 Merge branch 'dev' into dev-win 2019-07-09 21:05:30 -07:00
daan
09195b6a5f add commit charge statistics on windows 2019-07-09 21:05:09 -07:00
daan
873d07d89d merge with dev 2019-07-09 20:44:58 -07:00
daan
ad9db3a633 fix leak of huge segments in caches 2019-07-09 20:35:07 -07:00
daan
ee3f2059dc fix leak in segment cache freeing 2019-07-09 20:32:54 -07:00
daan
0314373d93 add reset_decommit, reset_discard options; maintain more statistics 2019-07-09 20:24:00 -07:00
daan
2cfdbc2cbb fix leak in segment cache freeing 2019-07-09 20:22:53 -07:00
daan
129149977d Merge branch 'dev' into dev-exp 2019-07-08 17:45:04 -07:00
daan
76023ca45f fix path max in realpath on unix (pr #69) 2019-07-08 17:43:10 -07:00
daan
8203f3dcfa add full heap aligned allocation api (issue #52); remove rezalloc (issue #63); add mi_version 2019-07-08 17:17:07 -07:00
daan
4d22ff6d03 Merge branch 'dev' into dev-exp 2019-07-08 15:45:50 -07:00
daan
d656f3e339 merge with master 2019-07-08 15:45:37 -07:00
daan
493dfc4b82 merge with dev 2019-07-08 15:42:42 -07:00
daan
56bdb2c2f3 add more const declarations (pr #79) 2019-07-08 12:00:59 -07:00
daan
7f0137a617 Fix compilation error with MSVC C++ 2019-07-07 21:59:53 -07:00
daan
7e743dfb58 fix C++ compilation warnings with VisualStudio 2017 2019-07-07 18:52:12 -07:00
daan
c3528203b5 fix compilation with C++, fix overrides in C++ to adhere to the spec (issue #26) 2019-07-07 18:11:21 -07:00
daan
dd59a917ce Expose mi prefixed public standard implementations of various posix, unix, and c++ allocation functions. See issue #75 2019-07-07 13:44:33 -07:00
David Carlier
a192d6893e initial support of 2MB pages on Mac 2019-07-05 20:05:04 +01:00
daan
b40fe5178a fix static object linking 2019-07-04 14:56:58 -07:00
daan
983c96a238 Merge branch 'dev' into dev-exp 2019-07-04 14:46:53 -07:00
daan
5ff037f8f8 add capability to override multiple entry points in windows dynamic override; and stop patching msvcrt, just crtbase 2019-07-04 12:06:15 -07:00
daan
74dc95c1d6 fix crash triggered in release mode with windows dynamic overriding 2019-07-04 12:04:56 -07:00
daan
3039dbfcdd for windows dynamic override, add standard api override and stop patching new/delete (for now) 2019-07-04 09:29:33 -07:00
daan
6abdc5f5a3 do not enable verbose by default in the debug build; add trace messages for verbose level 2 2019-07-04 09:28:22 -07:00
daan
069208b184 Possible fix to windows dynamic override calling register onexit directly 2019-07-03 19:47:44 -07:00
daan
663769c512 merge dev branch 2019-07-03 18:12:55 -07:00
Ernesto Castellotti
8c2f52dee8
Suppressed the new GCC 9 -Wmissing-attributes warnings
With the new release of the GCC 9 compiler the operation of -Wmissing-attributes warnings has also been extended to aliases: this causes a warnings if the alias has less attributes than its target.

This warnings does not actually indicate a problem in the mimalloc code and you could safely ignore it by adding "-Wno-missing-attributes" to the CFLAGS, however I was not going to use a "hack" to hide the warning when compiling alloc-override .c

So this patch solves the problem simply by using an attribute (present only in GCC> = 9) that copies the attributes of another function, since this attribute is exclusive only for GCC 9 (or later) I had to use a simple precompiler instruction to add the "copy" attribute only with GCC 9.
2019-07-04 00:21:15 +02:00
daan
c3a5f84ad3 rewrite of low-level OS (aligned) allocation to better handle large pages and aligned allocation 2019-07-03 14:52:32 -07:00
daan
7b4f3591f0 fix dynamic override when both msvcrt and ucrtbase are loaded in any order using priorities 2019-07-03 14:23:30 -07:00
daan
9390642879 fix windows dynamic malloc overried when both ucrtbase and msvcrt are loaded; also fix virtualalloc2 on 32-bit 2019-07-03 13:00:43 -07:00
daan
158705815e fix aligned_ensured bug, trie inc bug, stats in the OS module 2019-07-03 00:16:27 -07:00
daan
10a29f17c8 more conservative shrinking of memory 2019-07-02 22:49:12 -07:00
daan
cec3c4f9ff merge in dev branch 2019-07-02 17:28:15 -07:00
daan
5c0ffe9865 merge back changes to OS module from 'dev-exp' 2019-07-02 17:17:03 -07:00
daan
8cb36c62e6 merge with dev branch 2019-07-02 16:44:35 -07:00
daan
42efe51184 Merge branch 'master' into dev 2019-07-02 16:22:55 -07:00
Daan
f06931ba7e
Merge pull request #65 from devnexen/mi_mmap_prot_max_support
Using BSD new PROT_MAX mmap to block page address wider promotions
2019-07-02 16:21:13 -07:00
daan
b0ceb4a44c forward strdup, strndup, and realpath too 2019-07-02 15:56:01 -07:00
daan
b3f533167b Merge branch 'master' into dev 2019-07-02 15:52:26 -07:00
daan
7dc3a5a18e Merge branch 'master' into dev 2019-07-02 15:44:48 -07:00
daan
04b1fd7b8d Fix macro spelling 2019-07-02 12:57:12 -07:00
daan
4326bda2c7 Fix main heap cookie on macOS 2019-07-02 12:53:53 -07:00
daan
aeff1db32b Fixing interpose on macOS 2019-07-02 12:49:28 -07:00
Daan
825d00a001
Merge branch 'master' into indent-override 2019-07-02 09:03:32 -07:00
daan
d35fc6cdc4 PR#66 by kickunderscore to ensure consistent small block alignment 2019-07-02 08:46:50 -07:00
daan
06bcea1761 Initial commit of separate memory region layer and improved large OS pages support, see 'memory.c' 2019-07-02 07:23:24 -07:00
David Carlier
bed746d7d6 Using BSD new PROT_MAX mmap to block page address wider promotions 2019-07-01 06:56:16 +00:00
Jim Huang
2347a65fe0 Clarify the comment about Linux distributions
Red Hat Linux was discontinued by Red Hat in 2003. It would make sense
to address glibc-based Linux distributions rather than Red Hat Linux.

Reference: https://en.wikipedia.org/wiki/Red_Hat_Linux
2019-06-30 01:17:13 +08:00
Jim Huang
329a494783 Make forwarding macros friendly to indentation or style checkers
Indention programs such as clang-format usually rely on the occurrence
of statement terminator, otherwise they are likely confused. The revised
forwarding macros do not contain semicolons character, which is friendly
to indentation or style checkers.
2019-06-30 01:06:13 +08:00
daan
d6901558cd enable large OS page support on Windows 2019-06-28 22:35:57 -07:00
daan
6eaf387891 Add support for aligned allocation on Windows using VirtualAlloc2 2019-06-28 19:48:30 -07:00
daan
d2a2508af3 fix overly restrictive assertion 2019-06-27 13:34:14 -07:00
daan
1e636c45da add check for overflowing size allocation 2019-06-27 13:33:28 -07:00
daan
12d756e7b2 fix page count of heap when absorbing 2019-06-27 13:32:44 -07:00
daan
36826a96c9 add power-of-two check to posix_memalign, pr #56 2019-06-27 13:29:00 -07:00