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

582 Коммитов

Автор SHA1 Сообщение Дата
Matthew Parkinson 89ad538ccc Disable GCC warning. 2020-04-13 08:33:52 +01:00
Matthew Parkinson fe8b8a0891 Improved assume defines. 2020-04-13 08:33:52 +01:00
Matthew Parkinson cf9c2eb9d9
Addressing OE linking issues when built with GCC (#167)
* Use C++17 inline statics

This leads to better codegen in GCC, and fixes some linking issues in OE.

* Detect GCC and OE combination and fall-back to lock based ABA.

* clangformat
2020-04-10 13:49:39 +01:00
Paul Liétar c09b2468f9
Merge pull request #166 from microsoft/function_ref
Replace uses of std::function by function_ref.
2020-04-10 13:36:33 +02:00
Paul Liétar 6f697e06ef Add missing closing > 2020-04-10 12:54:09 +02:00
Paul Liétar 1ccb808a18 Fix clang-tidy warning and CR comments. 2020-04-10 12:36:36 +02:00
Paul Liétar 794a5912c7 Replace uses of std::function by function_ref. 2020-04-09 15:47:11 +02:00
Paul Liétar 89523a96bd
Add back the peek methods to ABA. (#165)
These are used by the Verona runtime.
2020-04-09 14:13:57 +01:00
Matthew Parkinson 74657d9dbc
Defensive code for alloc/dealloc during TLS teardown (#161)
* Defensive code for alloc/dealloc during TLS teardown

If an allocation or deallocation occurs during TLS teardown, then it is
possible for a new allocator to be created and then this is leaked. On
the mimalloc-bench mstressN benchmark this was observed leading to a
large memory leak.

This fix, detects if we are in the TLS teardown phase, and if so,
the calls to alloc or dealloc must return the allocator once they have
perform the specific operation.

Uses a separate variable to represent if a thread_local's destructor has
run already.  This is used to detect thread teardown to put the
allocator into a special slow path to avoid leaks.

* Added some printing first operation to track progress

* Improve error messages on posix

Flush errors, print assert details, and present stack traces.

* Detect incorrect use of pool.

* Clang format.

* Replace broken LL/SC implementation

LL/SC implementation was broken, this replaces it with
a locking implementation. Changes the API to support LL/SC
for future implementation on ARM.

* Improve TLS teardown.

* Make std::function fully inlined.

* Factor out PALLinux stack trace.

* Add checks for leaking allocators.

* Add release build of Windows Clang
2020-04-07 15:37:26 +01:00
Amaury Chamayou d87888096e
Add CI README, explaining how to update docker images (#162) 2020-04-03 08:27:50 +01:00
Matthew Parkinson 7bb00a7169
Add checks for deallocation with size (#160)
Ensure that the size deallocated with is the correct size. If the size
supplied is wrong, then internal invariants can break.
2020-04-02 07:04:52 +01:00
Matthew Parkinson 06eef5c4c5
Small changes (#159)
* Use NoZero for fresh pages
* MADV_DONTNEED only use for greater than a whole slab
* Simplify free list threading code
2020-04-02 07:04:03 +01:00
Matthew Parkinson d900e29424
Improve slow path performance for allocation (#143)
* Remote dealloc refactor.

* Improve remote dealloc

Change remote to count down to 0, so fast path does not need a constant.

Use signed value so that branch does not depend on addition.

* Inline remote_dealloc

The fast path of remote_dealloc is sufficiently compact that it can be
inlined.

* Improve fast path in Slab::alloc

Turn the internal structure into tail calls, to improve fast path.
Should be no algorithmic changes.

* Refactor initialisation to help fast path.

Break lazy initialisation into two functions, so it is easier to codegen
fast paths.

* Minor tidy to statically sized dealloc.

* Refactor semi-slow path for alloc

Make the backup path a bit faster.  Only algorithmic change is to delay
checking for first allocation. Otherwise, should be unchanged.

* Test initial operation of a thread

The first operation a new thread takes is special.  It results in
allocating an allocator, and swinging it into the TLS.  This makes
this a very special path, that is rarely tested.  This test generates
a lot of threads to cover the first alloc and dealloc operations.

* Correctly handle reusing get_noncachable

* Fix large alloc stats

Large alloc stats aren't necessarily balanced on a thread, this changes
to tracking individual pushs and pops, rather than the net effect
(with an unsigned value).

* Fix TLS init on large alloc path

* Add Bump ptrs to allocator

Each allocator has a bump ptr for each size class.  This is no longer
slab local.

Slabs that haven't been fully allocated no longer need to be in the DLL
for this sizeclass.

* Change to a cycle non-empty list

This change reduces the branching in the case of finding a new free
list. Using a non-empty cyclic list enables branch free add, and a
single branch in remove to detect the empty case.

* Update differences

* Rename first allocation

Use needs initialisation as makes more sense for other scenarios.

* Use a ptrdiff to help with zero init.

* Make GlobalPlaceholder zero init

The GlobalPlaceholder allocator is now a zero init block of memory.
This removes various issues for when things are initialised. It is made read-only
to we detect write to it on some platforms.
2020-03-31 09:17:53 +01:00
Matthew Parkinson ecef894525
Increase Remote batch size (#158)
* Increase Remote batch size

The remote batch size has not changed since the fast path optimisations.
The optimisations mean we are checking the queue considerably less
often, so the batch should be larger.  This has a dramatic improvement
on performance on a few of the mimalloc microbenchmarks.

It is set to 4096 as this should cover the worse case scenario of only
remote deallocation at 16 bytes for the 2^16 slab size.

* Fixes for Clang-10

Clang-10 outputs a warning for calling alignment intrinsic with an
alignment of 1. At add constexpr to handle this case.
2020-03-30 13:40:09 +01:00
Matthew Parkinson 77c453600b
OE fixes (#157)
* Only compile OE PAL if required.

* OE:reserve: Fix bug in loop.

* Handle out of memory by returning nullptr.
2020-03-25 08:10:39 +00:00
Alex 0a081cacd6
Readme update (#153) 2020-03-22 07:25:27 +00:00
Amaury Chamayou 60861eef44
CI for both arms (#151)
* Add another ARM
2020-03-20 09:17:38 +00:00
Amaury Chamayou e92fef6e63
ARM CI (#148)
* Add ARM setup

* Factor what can be into common scripts
2020-03-20 08:07:12 +00:00
Matthew Parkinson f301fdd2a0
Added SGX AAL. (#149) 2020-03-19 15:07:29 +00:00
Matthew Parkinson 4246d9a065
Workaround for QEMU behaviour. (#147)
* Fixes for ARM

* Workaround for QEMU behaviour.
2020-03-19 12:37:44 +00:00
Amaury Chamayou a6d6eecf22
Containerise Linux build (#145) 2020-03-19 09:28:06 +00:00
Matthew Parkinson f4de00cbca
Merge pull request #146 from microsoft/minor_bug_fixes
Minor bug fixes
2020-03-18 15:01:26 +00:00
Matthew Parkinson 0e1a7051f8 Improve constexpr failure case. 2020-03-18 14:49:34 +00:00
Matthew Parkinson 1352b28e82 Typo aarch64 2020-03-18 14:49:20 +00:00
Matthew Parkinson 0b278747c7 Pal_linux mprotect bug fix
When simulating decommit on Linux enable pages
before zeroing.
2020-03-18 14:49:02 +00:00
David Chisnall 8d33e1bb0f
Merge pull request #142 from devnexen/arm_aal_proposal
AAL, basic arm implementation proposal.
2020-03-17 12:37:40 +00:00
Matthew Parkinson 04909305aa
Update src/aal/aal_arm.h 2020-03-17 12:28:14 +00:00
David Carlier 55f1237df9 Few build tweaks. 2020-03-17 12:16:21 +00:00
David Carlier c6baa0baa3 using C++11 api instead for fallback call. 2020-03-17 10:08:17 +00:00
David Carlier e611b325ce Last tweaks 2020-03-16 18:59:51 +00:00
David Carlier 6b8650e4ce Using fallback when the (none)feature bit is present. 2020-03-13 16:46:16 +00:00
David Carlier e7f020cf76 implementations moved on the composer class. 2020-03-13 15:39:49 +00:00
David Carlier 2d4f2c3867 AAL, basic arm implementation proposal. 2020-03-13 08:09:14 +00:00
Amaury Chamayou 8e3efcb1dc
Assert not going through the PAL (#140)
* Assert not going through the PAL

* Make it more difficult to assert() accidentally
2020-03-11 15:58:44 +00:00
Amaury Chamayou 3911e2c4b5 Update the macOS image, since 10.13 is going out of support 2020-03-11 14:46:41 +00:00
Alex beb99ddc38
Extra helper functions for dllist (#139)
* More helpful functions for dllist
2020-03-11 10:07:29 +00:00
Matthew Parkinson 76eaf1adad
Remote dealloc refactor. (#138)
Improve remote dealloc

- Outline the slow path to improve code gen significantly

- Handle message queue only on slow path for remote dealloc.

- Change remote size to count down 0, so fast path does not need a constant.

- Use signed value so that branch does not depend on addition.
2020-03-10 08:12:57 +00:00
Matthew Parkinson 31da639f49
Merge pull request #137 from SchrodingerZhu/master
fix MinGW
2020-03-09 11:57:18 +00:00
SchrodingerZhu 8077c66a8e format bits 2020-03-08 22:50:34 +08:00
SchrodingerZhu 65de3c41bc fix mingw 2020-03-08 22:13:49 +08:00
Matthew Parkinson 51e919385f
Merge pull request #135 from achamayou/no_assert
replace assert with SNMALLOC_ASSERT
2020-03-04 19:35:41 +00:00
Matthew Parkinson b79448b6b5
Update src/ds/defines.h
Clang format
2020-03-04 17:59:13 +00:00
Matthew Parkinson 9dc689762c
Apply suggestions from code review 2020-03-04 17:44:54 +00:00
Amaury Chamayou acbcbce597 replace assert with SNMALLOC_ASSERT 2020-03-04 16:57:44 +00:00
Matthew Parkinson ef77bccfc2
Merge pull request #134 from microsoft/gcc8_warning
Address GCC8 warning
2020-03-03 11:29:42 +00:00
Matthew Parkinson 814f3ba289
Merge pull request #128 from microsoft/low-memory-async
Make Lazy Decomit asynchronous
2020-03-03 11:29:23 +00:00
Matthew Parkinson b756ca08a7 Address GCC8 warning
The bootstrapping allocator needs to perform a memcpy to bypass the
removed move constructors on std::atomic.  This is safe as there is no
concurrency at this point, but GCC is unhappy with this.

This commit moves CI to GCC8 and disables this warning for that line.
2020-03-01 20:48:03 +00:00
Matthew Parkinson d74976de26
Merge pull request #132 from microsoft/prerelease
Update documentation
2020-02-28 14:34:09 +00:00
Matthew Parkinson 040c878c6e Update documentation
The readme was considerably out of date, with the introduction
being over a year old.  This commit reflects the developments and
improvements in stabiity of snmalloc.
2020-02-28 09:03:41 +00:00
Matthew Parkinson 813367286e Make Lazy Decomit asynchronous
On platforms that support low-memory notifications register callbacks
that perform lazy decommit. This allows idle processes to return memory
to the OS. Without incurring the cost of constantly committing and
decommitting memory.

Code review and CI changes

* Fixed test to use a template to make constexpr magic work
* Factored out basic notification mechanism so can be reused on other
platforms.
2020-02-27 20:05:44 +00:00