12 #ifndef THRILL_DATA_BLOCK_POOL_HEADER 13 #define THRILL_DATA_BLOCK_POOL_HEADER 25 #include <condition_variable> 44 static constexpr
bool debug =
false;
168 void RunTask(
const std::chrono::steady_clock::time_point& tp)
final;
206 std::unique_ptr<Data>
d_;
218 friend std::ostream&
operator << (std::ostream& os,
const PinCount& p);
234 : block_pool_(block_pool), size_(size) {
236 block_pool_.RequestInternalMemory(size);
246 block_pool_.ReleaseInternalMemory(size_);
259 #endif // !THRILL_DATA_BLOCK_POOL_HEADER ~BlockPool()
Checks that all blocks were freed.
Block combines a reference to a read-only ByteBlock and book-keeping information. ...
void ReleaseInternalMemory(size_t size)
size_t total_blocks() noexcept
Total number of allocated blocks of this block pool.
size_t max_total_bytes() noexcept
Maximum total number of bytes allocated in blocks of this block pool.
void AdviseFree(size_t size)
std::pair< size_t, size_t > MaxMergeDegreePrefetch(size_t num_files)
void OnWriteComplete(ByteBlock *block_ptr, foxxll::request *req, bool success)
callback for async write of blocks during eviction
size_t hard_ram_limit() noexcept
Hard limit on amount of memory used for ByteBlock.
void DecBlockPinCount(ByteBlock *block_ptr, size_t local_worker_id)
Decrement a ByteBlock's pin count and possibly unpin it.
size_t pinned_blocks() noexcept
Total number of pinned blocks of this block pool.
A pinned / pin-counted pointer to a ByteBlock.
BlockPool(size_t workers_per_host=1)
Creates a simple BlockPool for tests: allows only one thread, enforces no memory limitations, never swaps to disk.
A non-pinned counting pointer to a ByteBlock.
static constexpr bool debug
mem::Manager mem_manager_
local Manager counting only ByteBlock allocations in internal memory.
PinRequestPtr PinBlock(const Block &block, size_t local_worker_id)
Pins a block by swapping it in if required.
void DestroyBlock(ByteBlock *block_ptr)
Destroys the block. Called by ByteBlockPtr's deleter.
size_t workers_per_host_
number of workers per host
void IncBlockPinCount(ByteBlock *block_ptr, size_t local_worker_id)
Increment a ByteBlock's pin count, requires the pin count to be > 0.
common::JsonLogger logger_
reference to HostContext's logger or a null sink
PinnedByteBlockPtr AllocateByteBlock(size_t size, size_t local_worker_id)
std::condition_variable cv_read_complete_
void OnReadComplete(PinRequest *read, foxxll::request *req, bool success)
callback for async read of blocks for pin requests
Pool to allocate, keep, swap out/in, and free all ByteBlocks on the host.
size_t workers_per_host() const
return number of workers per host
BlockPool & operator=(const BlockPool &)=delete
non-copyable: delete assignment operator
A ByteBlock is the basic storage units of containers like File, BlockQueue, etc.
size_t swapped_blocks() noexcept
Total number of swapped blocks.
RAII class for allocating memory from a BlockPool.
size_t writing_blocks() noexcept
Total number of blocks currently begin written.
foxxll::request_ptr EvictBlockLRU()
size_t total_bytes() noexcept
Total number of bytes allocated in blocks of this block pool.
common::JsonLogger & logger()
Returns logger_.
High-performance smart pointer used as a wrapping reference counting pointer.
friend std::ostream & operator<<(std::ostream &os, const PinCount &p)
make ostream-able
size_t reading_blocks() noexcept
Total number of blocks currently begin read from EM.
foxxll::request_ptr GetAnyWriting()
Return any currently being written block (for waiting on completion)
Object shared by allocators and other classes to track memory allocations.
size_t next_file_id()
return next unique File id
Request object encapsulating basic properties like file and offset.
JsonLogger is a receiver of JSON output objects for logging.
size_t unpinned_blocks() noexcept
Total number of unpinned blocks in memory of this block pool.
void IntIncBlockPinCount(ByteBlock *block_ptr, size_t local_worker_id)
Increment a ByteBlock's pin count - without locking the mutex.
void EvictBlock(ByteBlock *block_ptr)
BlockPoolMemoryHolder(BlockPool &block_pool, size_t size)
void RunTask(const std::chrono::steady_clock::time_point &tp) final
method called by ProfileThread.
std::mutex mutex_
locked before internal state is changed
std::unique_ptr< Data > d_
pimpl data structure
void RequestInternalMemory(size_t size)
ByteBlockPtr MapExternalBlock(const foxxll::file_ptr &file, uint64_t offset, size_t size)