Code Quality - inlining (#792)
* Inline lambdas for better codegen * Disable PreventFork in the freelist queue
This commit is contained in:
committed by
GitHub
parent
71e205fe17
commit
b49a42d9be
@@ -642,7 +642,7 @@ namespace snmalloc
|
|||||||
Allocator* alloc,
|
Allocator* alloc,
|
||||||
smallsizeclass_t sizeclass,
|
smallsizeclass_t sizeclass,
|
||||||
freelist::Iter<>* fl,
|
freelist::Iter<>* fl,
|
||||||
size_t size) -> void* {
|
size_t size) SNMALLOC_FAST_PATH_LAMBDA {
|
||||||
return alloc->small_refill<Conts, CheckInit>(sizeclass, *fl, size);
|
return alloc->small_refill<Conts, CheckInit>(sizeclass, *fl, size);
|
||||||
},
|
},
|
||||||
this,
|
this,
|
||||||
@@ -673,9 +673,9 @@ namespace snmalloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return self->handle_message_queue(
|
return self->handle_message_queue(
|
||||||
[](Allocator* self, size_t size) -> void* {
|
[](Allocator* self, size_t size) SNMALLOC_FAST_PATH_LAMBDA {
|
||||||
return CheckInit::check_init(
|
return CheckInit::check_init(
|
||||||
[self, size]() {
|
[self, size]() SNMALLOC_FAST_PATH_LAMBDA {
|
||||||
if (size > bits::one_at_bit(bits::BITS - 1))
|
if (size > bits::one_at_bit(bits::BITS - 1))
|
||||||
{
|
{
|
||||||
// Cannot allocate something that is more that half the size of
|
// Cannot allocate something that is more that half the size of
|
||||||
@@ -728,7 +728,7 @@ namespace snmalloc
|
|||||||
|
|
||||||
return Conts::failure(size);
|
return Conts::failure(size);
|
||||||
},
|
},
|
||||||
[](Allocator* a, size_t size) {
|
[](Allocator* a, size_t size) SNMALLOC_FAST_PATH_LAMBDA {
|
||||||
return alloc_not_small<Conts, CheckInitNoOp>(size, a);
|
return alloc_not_small<Conts, CheckInitNoOp>(size, a);
|
||||||
},
|
},
|
||||||
size);
|
size);
|
||||||
@@ -812,7 +812,7 @@ namespace snmalloc
|
|||||||
smallsizeclass_t sizeclass, freelist::Iter<>& fast_free_list, size_t size)
|
smallsizeclass_t sizeclass, freelist::Iter<>& fast_free_list, size_t size)
|
||||||
{
|
{
|
||||||
return CheckInit::check_init(
|
return CheckInit::check_init(
|
||||||
[this, size, sizeclass, &fast_free_list]() -> void* {
|
[this, size, sizeclass, &fast_free_list]() SNMALLOC_FAST_PATH_LAMBDA {
|
||||||
size_t rsize = sizeclass_to_size(sizeclass);
|
size_t rsize = sizeclass_to_size(sizeclass);
|
||||||
|
|
||||||
// No existing free list get a new slab.
|
// No existing free list get a new slab.
|
||||||
@@ -862,7 +862,7 @@ namespace snmalloc
|
|||||||
auto r = finish_alloc<Conts>(p, size);
|
auto r = finish_alloc<Conts>(p, size);
|
||||||
return ticker.check_tick(r);
|
return ticker.check_tick(r);
|
||||||
},
|
},
|
||||||
[](Allocator* a, size_t size) {
|
[](Allocator* a, size_t size) SNMALLOC_FAST_PATH_LAMBDA {
|
||||||
return a->small_alloc<Conts, CheckInitNoOp>(size);
|
return a->small_alloc<Conts, CheckInitNoOp>(size);
|
||||||
},
|
},
|
||||||
size);
|
size);
|
||||||
|
|||||||
@@ -104,13 +104,17 @@ namespace snmalloc
|
|||||||
invariant();
|
invariant();
|
||||||
freelist::Object::atomic_store_null(last, Key, Key_tweak);
|
freelist::Object::atomic_store_null(last, Key, Key_tweak);
|
||||||
|
|
||||||
// The following non-linearisable effect is normally benign,
|
// // The following non-linearisable effect is normally benign,
|
||||||
// but could lead to a remote list become completely detached
|
// // but could lead to a remote list become completely detached
|
||||||
// during a fork in a multi-threaded process. This would lead
|
// // during a fork in a multi-threaded process. This would lead
|
||||||
// to a memory leak, which is probably the least of your problems
|
// // to a memory leak, which is probably the least of your problems
|
||||||
// if you forked in during a deallocation.
|
// // if you forked in during a deallocation. We can prevent this
|
||||||
PreventFork pf;
|
// // with the following code, but it is not currently enabled as it
|
||||||
snmalloc::UNUSED(pf);
|
// // has negative performance impact.
|
||||||
|
// // An alternative would be to reset the queue on the child postfork
|
||||||
|
// // handler to ensure that the queue has not been blackholed.
|
||||||
|
// PreventFork pf;
|
||||||
|
// snmalloc::UNUSED(pf);
|
||||||
|
|
||||||
// Exchange needs to be acq_rel.
|
// Exchange needs to be acq_rel.
|
||||||
// * It needs to be a release, so nullptr in next is visible.
|
// * It needs to be a release, so nullptr in next is visible.
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ namespace snmalloc
|
|||||||
entropy,
|
entropy,
|
||||||
[this](
|
[this](
|
||||||
RemoteAllocator::alloc_id_t target_id,
|
RemoteAllocator::alloc_id_t target_id,
|
||||||
capptr::Alloc<RemoteMessage> msg) {
|
capptr::Alloc<RemoteMessage> msg) SNMALLOC_FAST_PATH_LAMBDA {
|
||||||
forward<allocator_size>(target_id, msg);
|
forward<allocator_size>(target_id, msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user