Commit Graph

15 Commits

Author SHA1 Message Date
David Chisnall
eefc9e49c5 Fix some duplicate inline warnings. 2019-07-05 11:39:01 +01:00
David Chisnall
b8a5d7fca9 Lazily initialise TLS on slow paths.
Copying an idea from mimalloc, initialise the TLS variable to a global
allocator that doesn't own any memory and then lazily check when we hit
a slow path (which we always do when using the global allocator, because
it doesn't own any memory) if we are the global allocator and replace
it.

There is a slight complication compared to mimalloc's version of this
idea.  Snmalloc collects outgoing messages and it's possible for the
first operation in a thread to be a free of memory allocated by a
different thread.  We address this by initialising the queues with a
size value indicating that they are full and then do the lazy check when
about to insert a message that would make a queue full.  This will then
trigger lazy creation of an allocator.

Global initialisation doesn't work for the fake allocator, so skip most
of its constructor.
2019-07-05 09:41:32 +01:00
Matthew Parkinson
eb4e28e8d0 CR Feedback
Removed stub from message queue, and use an actual allocation.
2019-07-02 14:08:05 +01:00
Matthew Parkinson
621b7e6b9a Clang format. 2019-07-02 10:51:18 +01:00
Matthew Parkinson
3c7d122dea Add macro for ASSUME and FAST_PATH/SLOW_PATH
Fixes GCC warning that was incorrect using an ASSUME.

Made fast path and slow path Macros so we can add additional attributes.
2019-07-01 14:35:36 +01:00
Matthew Parkinson
830b06a616 Add a couple of likely annotations. 2019-07-01 14:24:03 +01:00
Matthew Parkinson
b8bcfc0798 Made the statistics print atexit
Fixed some statistics and made them automatically print atexit.
2019-05-16 11:43:44 +01:00
Matthew Parkinson
48416e3241 CR Feedback 2019-05-14 21:16:11 +01:00
Matthew Parkinson
e5d617c5fb Improve TLS performance
Refactor fast and slow paths to improve inlining
and codegen.
2019-05-14 21:16:11 +01:00
David Chisnall
5c197e4ae4 [NFC] More checks, comments on end of namespace braces. 2019-04-30 09:46:01 +01:00
David Chisnall
4bafca9be7 [NFC] Automatic fixes from clang-tidy. 2019-04-29 11:33:07 +01:00
Matthew Parkinson
37afe9d079 Clang format 2019-04-29 11:02:47 +01:00
Matthew Parkinson
4faf9f3bee Use fewer header files
Removing some includes to reduce the code that is dragged in.
2019-04-29 11:02:47 +01:00
theodus
e2190f376f Fix typo in threadalloc.h 2019-01-16 09:22:01 +00:00
Matthew Parkinson
4f9d991449 Initial commit of snmalloc
History squashed from internal development.

Internal history has commit hash:
  e27a0e485c44a5003a802de2661ce3b21e120316
2019-01-15 14:17:55 +00:00