Граф коммитов

114 Коммитов

Автор SHA1 Сообщение Дата
David Chisnall 66cec23b23 Initial cut at a lazy decommit strategy.
This does not deallocate memory until the OS tells us that we are short
on memory, then tries to decommit all of the cached chunks (except for
the first page, used for the linked lists).

Nowhere near enough testing to commit to master yet!
2019-02-25 11:27:53 +00:00
Matthew Parkinson 7a9ce97166 Clangformat 2019-02-20 17:36:39 +01:00
Matthew Parkinson 9104f81285 Remove Undefined preprocessor behaviour 2019-02-20 17:36:39 +01:00
Matthew Parkinson 98dd9573c7 Fix ifdef 2019-02-20 17:36:39 +01:00
David Chisnall 4830bd4021 Check for an SDK version before enabling VirtualAlloc2.
This is mainly to keep the CI system happy: it's using an old SDK
because the new version of cl.exe doesn't work with cmake...
2019-02-20 17:36:39 +01:00
David Chisnall 2ee3ba59ee Use VirtualAlloc2 on Windows.
The newer API (Windows 10 and newer) allows the allocator to ask for
strongly aligned memory.

This is enabled only if the `WINVER` macro is set to target Windows 10
or newer.  There is now a CMake option to target older versions of
Windows, so we can test both code paths.

The Azure Pipelines config now includes a test of the compatibility
version.  This runs only the release build, because it's mainly there as
a sanity check - 99% of the code is the same as the default Windows
config.
2019-02-20 17:36:39 +01:00
Matthew Parkinson 6ec84856df
Merge pull request #28 from Microsoft/mpscq
Updated to match documentation.
2019-02-19 16:22:00 +00:00
Matthew Parkinson 9940fbd363 Fixed typo. 2019-02-19 15:44:23 +00:00
Matthew Parkinson d588e8ecb1 Updated to match documentation. 2019-02-19 15:00:55 +00:00
Matthew Parkinson ccccd686fb
Merge pull request #16 from Microsoft/Sizeclass
Simplified sizeclass calculations and added tests.
2019-02-19 13:07:08 +00:00
Matthew Parkinson aac2b9212e
Merge pull request #21 from plietar/smart-next
Place the next pointer at a different place on every object.
2019-02-19 09:04:23 +00:00
Paul Liétar ffe496dd18 Address review comments. 2019-02-18 21:29:32 +00:00
Paul Liétar 66400af419 Add a cache-friendly version of the tests.
This only tests CACHE_FRIENDLY_OFFSET=64, which is probably what we'll be using in the end.
2019-02-18 14:51:04 +00:00
Paul Liétar 4ac3421487 Place the next pointer at a different place on every object.
This limits the collision in cache buckets, especially for larger objects.
2019-02-18 14:22:50 +00:00
David Chisnall c47eed1922 Tweaks to end bounds checking.
Introduce a `OnePastEnd` option for the pointer immediately after the
end of the allocation.  This simplifies some of the logic in callers,
where they wants to say 'is base + length safe to use?'.

Also restructure some of the other logic somewhat.
2019-02-15 20:05:00 +01:00
Theo Butler 9a6b0aef1f
Merge pull request #23 from Microsoft/comment
Fix comment to represent current PAL API.
2019-02-15 13:42:59 -05:00
Matthew Parkinson 5e149b083f One more constexpr 2019-02-15 17:43:27 +00:00
Matthew Parkinson 8698f87018 Added some constexpr to some ifs. 2019-02-15 16:12:38 +00:00
Matthew Parkinson c02077a06a Bug fix in umul code for 32-bit Win 2019-02-15 14:36:47 +00:00
Matthew Parkinson e7d90966f6 Made the malloc tests run on Windows 2019-02-15 14:36:47 +00:00
Matthew Parkinson ac8e5e4e5b Fix comment to represent current PAL API. 2019-02-15 09:24:01 +00:00
Matthew Parkinson bf58015c25
Merge pull request #20 from Theodus/malloc-tests
Add malloc tests
2019-02-15 09:12:07 +00:00
Theo Butler a3fb2b9531 cleanup some tests 2019-02-14 22:31:45 -05:00
Theo Butler d2909eed0a Merge branch 'master' into malloc-tests 2019-02-14 22:30:48 -05:00
Theo Butler 90414f82f6
Merge pull request #22 from Microsoft/zero_bug
Pal zero bug alignment
2019-02-14 22:26:18 -05:00
Matthew Parkinson adeecfb0f1 Added bug fix to alignment of using. 2019-02-14 20:08:04 +00:00
Matthew Parkinson 8b9a525500 Added zero test at threshold. 2019-02-14 19:59:36 +00:00
Theo Butler c555bf7218 fix doc comments for notify_using 2019-02-13 17:15:06 -05:00
Matthew Parkinson 35803305f2
Merge pull request #19 from plietar/visibility
Make internal symbols hidden.
2019-02-13 21:50:00 +00:00
Theo Butler 057595a57e remove -1 check in calloc 2019-02-13 16:03:38 -05:00
Theo Butler 942313fec7 replace asserts with abort 2019-02-13 10:03:41 -05:00
Theo Butler 24ba068dce remove randomness from malloc tests 2019-02-13 08:42:51 -05:00
Theo Butler 0ff2301083 use malloc shim in malloc tests 2019-02-13 08:12:07 -05:00
Theo Butler e42551bb15 only build malloc tests on POSIX platforms 2019-02-12 22:05:36 -05:00
theodus a9615bc6aa mark variables unused in release build 2019-02-12 20:22:10 -05:00
Theo Butler f6497e6ee3 Add malloc tests 2019-02-12 19:50:15 -05:00
Paul Liétar 8d8761f248 Make internal symbols hidden.
Only the malloc/free/... interface is exported.

This allows all of C++'s weak ODR symbols to be resolved at
compile-time, rather than staying weak and resolved at load-time.

Since internal calls don't need to go through the PLT anymore, we get a
nice speedup, at least on small objects.
2019-02-12 23:27:42 +00:00
Matthew Parkinson a7f0695776
Merge pull request #17 from plietar/fix-align
Fix the condition on when to allocate a new block.
2019-02-12 13:10:53 +00:00
Paul Liétar 79b432ddab Fix the condition on when to allocate a new block.
Previously we would pretty much always allocate a new block for each
allocator, making them 16MiB aligned.
2019-02-12 12:47:22 +00:00
Matthew Parkinson e004641cec Added to comment. 2019-02-11 14:47:12 +00:00
Matthew Parkinson 9981bad9b5 clang format 2019-02-11 14:47:12 +00:00
Matthew Parkinson 1272078487 Simplified size class calculation
The rounding code can be integrated directly into the sizeclass code,
which means, the code paths can be simplified slightly.

The special case for zero mantissa bits is not required, as the compiler
generates the same code from the more complex path due to
eliminating dead code after folding the constant zero through.
2019-02-11 14:47:12 +00:00
Matthew Parkinson fdcad7feb4 Add test for sizeclass calculations 2019-02-11 14:47:12 +00:00
David Chisnall ccd8ec9b4f Disable rtti / exceptions on the non-Windows builds.
RTTI makes the binaries bigger, exceptions make life harder for
optimisers.  Neither are actually used.

This doesn't preclude anything #including snmalloc.h with RTTI enabled,
it just disables it in the shim libraries and tests.

The FreeBSD libc builds were already doing this with no ill effect.
2019-02-06 17:46:58 +00:00
Matthew Parkinson 2cd84c80b2 Build shim with 1MiB superslabs. 2019-02-06 17:08:47 +00:00
Matthew Parkinson 731757b29c
Merge pull request #13 from Microsoft/matt-refactor
Simplification around remote allocation
2019-02-06 11:25:07 +00:00
Matthew Parkinson f3897dd3e0 Code review feedback. 2019-02-05 16:57:09 +00:00
Matthew Parkinson 83c55fe5da Simplify remote allocator.
Don't store the sizeclass, as we can find it easily, and already are
going to touch though cache lines in the common case.
2019-02-05 13:27:19 +00:00
Matthew Parkinson 122a5de811 Refactor code to correctly handle low bits of allocator ID. 2019-02-05 13:11:55 +00:00
David Chisnall fc24b8be3d
Merge pull request #12 from Theodus/override
Avoid unnecessary allocation from realloc
2019-02-03 13:30:21 +00:00