Add FIFO behaviour for unchecked code.

Consuming available slabs in LIFO order makes predicting address reuse harder
but appears to have performance implications.  Condition this on CHECK_CLIENT
and instead use FIFO order on !CHECK_CLIENT builds.
This commit is contained in:
Matthew Parkinson
2021-10-22 16:12:59 +01:00
committed by Matthew Parkinson
parent 4987a19fe9
commit cec015f296
3 changed files with 94 additions and 29 deletions

View File

@@ -292,7 +292,13 @@ namespace snmalloc
struct MetaslabCache
{
SeqQueue<Metaslab> queue;
#ifdef SNMALLOC_CHECK_CLIENT
SeqSet<Metaslab> available;
#else
// This is slightly faster in some cases,
// but makes memory reuse more predictable.
SeqSet<Metaslab, true> available;
#endif
uint16_t unused = 0;
uint16_t length = 0;
};