LLDB  mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Pool Class Reference
Collaboration diagram for Pool:
Collaboration graph
[legend]

Classes

struct  PoolEntry
 

Public Types

typedef llvm::BumpPtrAllocatorImpl< llvm::MallocAllocator, AllocatorSlabSize, SizeThreshold, AllocatorGrowthDelayAllocator
 
typedef llvm::StringMap< StringPoolValueType, AllocatorStringPool
 
typedef llvm::StringMapEntry< StringPoolValueTypeStringPoolEntryType
 

Public Member Functions

StringPoolValueType GetMangledCounterpart (const char *ccstr) const
 
const char * GetConstCString (const char *cstr)
 
const char * GetConstCStringWithLength (const char *cstr, size_t cstr_len)
 
const char * GetConstCStringWithStringRef (const llvm::StringRef &string_ref)
 
const char * GetConstCStringAndSetMangledCounterPart (llvm::StringRef demangled, const char *mangled_ccstr)
 
const char * GetConstTrimmedCStringWithLength (const char *cstr, size_t cstr_len)
 
size_t MemorySize () const
 

Static Public Member Functions

static StringPoolEntryTypeGetStringMapEntryFromKeyData (const char *keyData)
 
static size_t GetConstCStringLength (const char *ccstr)
 

Public Attributes

const typedef char * StringPoolValueType
 

Static Public Attributes

static const size_t AllocatorSlabSize = 4096
 The default BumpPtrAllocatorImpl slab size. More...
 
static const size_t SizeThreshold = AllocatorSlabSize
 
static const size_t AllocatorGrowthDelay = 1
 Every Pool has its own allocator which receives an equal share of the ConstString allocations. More...
 

Protected Member Functions

uint8_t hash (const llvm::StringRef &s) const
 

Protected Attributes

std::array< PoolEntry, 256 > m_string_pools
 

Detailed Description

Definition at line 30 of file ConstString.cpp.

Member Typedef Documentation

◆ Allocator

typedef llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, AllocatorSlabSize, SizeThreshold, AllocatorGrowthDelay> Pool::Allocator

Definition at line 60 of file ConstString.cpp.

◆ StringPool

typedef llvm::StringMap<StringPoolValueType, Allocator> Pool::StringPool

Definition at line 62 of file ConstString.cpp.

◆ StringPoolEntryType

typedef llvm::StringMapEntry<StringPoolValueType> Pool::StringPoolEntryType

Definition at line 63 of file ConstString.cpp.

Member Function Documentation

◆ GetConstCString()

const char* Pool::GetConstCString ( const char *  cstr)
inline

Definition at line 89 of file ConstString.cpp.

Referenced by lldb_private::ConstString::SetCString().

◆ GetConstCStringAndSetMangledCounterPart()

const char* Pool::GetConstCStringAndSetMangledCounterPart ( llvm::StringRef  demangled,
const char *  mangled_ccstr 
)
inline

◆ GetConstCStringLength()

static size_t Pool::GetConstCStringLength ( const char *  ccstr)
inlinestatic

Definition at line 70 of file ConstString.cpp.

Referenced by lldb_private::ConstString::GetLength().

◆ GetConstCStringWithLength()

const char* Pool::GetConstCStringWithLength ( const char *  cstr,
size_t  cstr_len 
)
inline

◆ GetConstCStringWithStringRef()

const char* Pool::GetConstCStringWithStringRef ( const llvm::StringRef &  string_ref)
inline

Definition at line 101 of file ConstString.cpp.

◆ GetConstTrimmedCStringWithLength()

const char* Pool::GetConstTrimmedCStringWithLength ( const char *  cstr,
size_t  cstr_len 
)
inline

◆ GetMangledCounterpart()

StringPoolValueType Pool::GetMangledCounterpart ( const char *  ccstr) const
inline

Definition at line 80 of file ConstString.cpp.

Referenced by lldb_private::ConstString::GetMangledCounterpart().

◆ GetStringMapEntryFromKeyData()

static StringPoolEntryType& Pool::GetStringMapEntryFromKeyData ( const char *  keyData)
inlinestatic

Definition at line 66 of file ConstString.cpp.

◆ hash()

uint8_t Pool::hash ( const llvm::StringRef &  s) const
inlineprotected

Definition at line 175 of file ConstString.cpp.

◆ MemorySize()

size_t Pool::MemorySize ( ) const
inline

Definition at line 164 of file ConstString.cpp.

Referenced by lldb_private::ConstString::StaticMemorySize().

Member Data Documentation

◆ AllocatorGrowthDelay

const size_t Pool::AllocatorGrowthDelay = 1
static

Every Pool has its own allocator which receives an equal share of the ConstString allocations.

This means that when allocating many ConstStrings, every allocator sees only its small share of allocations and assumes LLDB only allocated a small amount of memory so far. In reality LLDB allocated a total memory that is N times as large as what the allocator sees (where N is the number of string pools). This causes that the BumpPtrAllocator continues a long time to allocate memory in small chunks which only makes sense when allocating a small amount of memory (which is true from the perspective of a single allocator). On some systems doing all these small memory allocations causes LLDB to spend a lot of time in malloc, so we need to force all these allocators to behave like one allocator in terms of scaling their memory allocations with increased demand. To do this we set the growth delay for each single allocator to a rate so that our pool of allocators scales their memory allocations similar to a single BumpPtrAllocatorImpl.

Currently we have 256 string pools and the normal growth delay of the BumpPtrAllocatorImpl is 128 (i.e., the memory allocation size increases every 128 full chunks), so by changing the delay to 1 we get a total growth delay in our allocator collection of 256/1 = 256. This is still only half as fast as a normal allocator but we can't go any faster without decreasing the number of string pools.

Definition at line 57 of file ConstString.cpp.

◆ AllocatorSlabSize

const size_t Pool::AllocatorSlabSize = 4096
static

The default BumpPtrAllocatorImpl slab size.

Definition at line 33 of file ConstString.cpp.

◆ m_string_pools

std::array<PoolEntry, 256> Pool::m_string_pools
protected

Definition at line 185 of file ConstString.cpp.

◆ SizeThreshold

const size_t Pool::SizeThreshold = AllocatorSlabSize
static

Definition at line 34 of file ConstString.cpp.

◆ StringPoolValueType

const typedef char* Pool::StringPoolValueType

Definition at line 61 of file ConstString.cpp.


The documentation for this class was generated from the following file: