"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/include/hoard/hoardheap.h" between
Hoard-3.12.tar.gz and Hoard-3.13.tar.gz

About: The Hoard memory allocator is a drop-in replacement for malloc() that can improve application performance, especially for multithreaded programs running on multiprocessors (hint: newer releases now part of the HeapLayers package).

hoardheap.h  (Hoard-3.12):hoardheap.h  (Hoard-3.13)
// -*- C++ -*- // -*- C++ -*-
/* /*
The Hoard Multiprocessor Memory Allocator The Hoard Multiprocessor Memory Allocator
www.hoard.org www.hoard.org
Author: Emery Berger, http://www.cs.umass.edu/~emery Author: Emery Berger, http://www.emeryberger.com
Copyright (c) 1998-2012 Emery Berger Copyright (c) 1998-2018 Emery Berger
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 39 skipping to change at line 39
#define HOARD_HOARDHEAP_H #define HOARD_HOARDHEAP_H
#include <assert.h> #include <assert.h>
#include "heaplayers.h" #include "heaplayers.h"
using namespace HL; using namespace HL;
// The minimum allocation grain for a given object - // The minimum allocation grain for a given object -
// that is, we carve objects out of chunks of this size. // that is, we carve objects out of chunks of this size.
#define SUPERBLOCK_SIZE 65536 //#define SUPERBLOCK_SIZE 65536
#define SUPERBLOCK_SIZE (1UL << 21)
//#define SUPERBLOCK_SIZE (256*1048576)
//#define SUPERBLOCK_SIZE (512*1048576)
//#define SUPERBLOCK_SIZE (1024UL*1048576)
// The number of 'emptiness classes'; see the ASPLOS paper for details. // The number of 'emptiness classes'; see the ASPLOS paper for details.
#define EMPTINESS_CLASSES 8 #define EMPTINESS_CLASSES 8
// Hoard-specific layers // Hoard-specific layers
#include "thresholdheap.h" #include "thresholdheap.h"
#include "hoardmanager.h" #include "hoardmanager.h"
#include "addheaderheap.h" #include "addheaderheap.h"
#include "threadpoolheap.h" #include "threadpoolheap.h"
#include "redirectfree.h" #include "redirectfree.h"
#include "ignoreinvalidfree.h" #include "ignoreinvalidfree.h"
#include "conformantheap.h" #include "conformantheap.h"
#include "hoardsuperblock.h" #include "hoardsuperblock.h"
#include "hoardsuperblockheader.h"
#include "lockmallocheap.h" #include "lockmallocheap.h"
#include "alignedsuperblockheap.h" #include "alignedsuperblockheap.h"
#include "alignedmmap.h" #include "alignedmmap.h"
#include "globalheap.h" #include "globalheap.h"
#include "thresholdsegheap.h" #include "thresholdsegheap.h"
#include "geometricsizeclass.h" #include "geometricsizeclass.h"
// Note from Emery Berger: I plan to eventually eliminate the use of // Note from Emery Berger: I plan to eventually eliminate the use of
// the spin lock, since the right place to do locking is in an // the spin lock, since the right place to do locking is in an
skipping to change at line 93 skipping to change at line 100
#endif #endif
namespace Hoard { namespace Hoard {
class MmapSource : public AlignedMmap<SUPERBLOCK_SIZE, TheLockType> {}; class MmapSource : public AlignedMmap<SUPERBLOCK_SIZE, TheLockType> {};
// //
// There is just one "global" heap, shared by all of the per-process heaps. // There is just one "global" heap, shared by all of the per-process heaps.
// //
typedef GlobalHeap<SUPERBLOCK_SIZE, EMPTINESS_CLASSES, MmapSource, TheLockType > typedef GlobalHeap<SUPERBLOCK_SIZE, HoardSuperblockHeader, EMPTINESS_CLASSES, MmapSource, TheLockType>
TheGlobalHeap; TheGlobalHeap;
// //
// When a thread frees memory and causes a per-process heap to fall // When a thread frees memory and causes a per-process heap to fall
// below the emptiness threshold given in the function below, it // below the emptiness threshold given in the function below, it
// moves a (nearly or completely empty) superblock to the global heap. // moves a (nearly or completely empty) superblock to the global heap.
// //
class hoardThresholdFunctionClass { class hoardThresholdFunctionClass {
public: public:
skipping to change at line 121 skipping to change at line 128
U < A - 2S && U < EMPTINESS_CLASSES-1/EMPTINESS_CLASSES * A U < A - 2S && U < EMPTINESS_CLASSES-1/EMPTINESS_CLASSES * A
*/ */
auto r = ((EMPTINESS_CLASSES * u) < ((EMPTINESS_CLASSES-1) * a)) && ((u < a - (2 * SUPERBLOCK_SIZE) / objSize)); auto r = ((EMPTINESS_CLASSES * u) < ((EMPTINESS_CLASSES-1) * a)) && ((u < a - (2 * SUPERBLOCK_SIZE) / objSize));
return r; return r;
} }
}; };
class SmallHeap; class SmallHeap;
typedef HoardSuperblock<TheLockType, SUPERBLOCK_SIZE, SmallHeap> SmallSuperblo // typedef Hoard::HoardSuperblockHeader<TheLockType, SUPERBLOCK_SIZE, SmallHe
ckType; ap> HSHeader;
typedef HoardSuperblock<TheLockType, SUPERBLOCK_SIZE, SmallHeap, Hoard::HoardS
uperblockHeader> SmallSuperblockType;
// //
// The heap that manages small objects. // The heap that manages small objects.
// //
class SmallHeap : class SmallHeap :
public ConformantHeap< public ConformantHeap<
HoardManager<AlignedSuperblockHeap<TheLockType, SUPERBLOCK_SIZE, MmapSource> , HoardManager<AlignedSuperblockHeap<TheLockType, SUPERBLOCK_SIZE, MmapSource> ,
TheGlobalHeap, TheGlobalHeap,
SmallSuperblockType, SmallSuperblockType,
EMPTINESS_CLASSES, EMPTINESS_CLASSES,
TheLockType, TheLockType,
hoardThresholdFunctionClass, hoardThresholdFunctionClass,
SmallHeap> > SmallHeap> >
{}; {};
class BigHeap; class BigHeap;
typedef HoardSuperblock<TheLockType, SUPERBLOCK_SIZE, BigHeap> BigSuperblockTy typedef HoardSuperblock<TheLockType,
pe; SUPERBLOCK_SIZE,
BigHeap,
Hoard::HoardSuperblockHeader>
BigSuperblockType;
// The heap that manages large objects. // The heap that manages large objects.
#if 0 #if 0
// Old version: slow and now deprecated. Returns every large object // Old version: slow and now deprecated. Returns every large object
// back to the system immediately. // back to the system immediately.
typedef ConformantHeap<HL::LockedHeap<TheLockType, typedef ConformantHeap<HL::LockedHeap<TheLockType,
AddHeaderHeap<BigSuperblockType, AddHeaderHeap<BigSuperblockType,
SUPERBLOCK_SIZE, SUPERBLOCK_SIZE,
skipping to change at line 209 skipping to change at line 221
ThreadPoolHeap<N, NH, Hoard::PerThreadHoardHeap>, ThreadPoolHeap<N, NH, Hoard::PerThreadHoardHeap>,
Hoard::BigHeap> > > Hoard::BigHeap> > >
{ {
public: public:
enum { BIG_OBJECT = Hoard::BigObjectSize }; enum { BIG_OBJECT = Hoard::BigObjectSize };
HoardHeap() { HoardHeap() {
enum { BIG_HEADERS = sizeof(Hoard::BigSuperblockType::Header), enum { BIG_HEADERS = sizeof(Hoard::BigSuperblockType::Header),
SMALL_HEADERS = sizeof(Hoard::SmallSuperblockType::Header)}; SMALL_HEADERS = sizeof(Hoard::SmallSuperblockType::Header)};
HL::sassert<(BIG_HEADERS == SMALL_HEADERS)> ensureSameSizeHeaders; static_assert(BIG_HEADERS == SMALL_HEADERS,
ensureSameSizeHeaders = ensureSameSizeHeaders; "Headers must be the same size.");
} }
}; };
} }
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
#endif #endif
 End of changes. 8 change blocks. 
10 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)