AFIO  v2.00 late alpha
afio_v2_xxx::utils::page_allocator< T > Class Template Reference

An STL allocator which allocates large TLB page memory.If the operating system is configured to allow it, this type of memory is particularly efficient for doing large scale file i/o. This is because the kernel must normally convert the scatter gather buffers you pass into extended scatter gather buffers as the memory you see as contiguous may not, and probably isn't, actually be contiguous in physical memory. Regions returned by this allocator may be allocated contiguously in physical memory and therefore the kernel can pass through your scatter gather buffers unmodified. More...

#include "utils.hpp"

Classes

struct  rebind
 

Public Types

using value_type = T
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 
using propagate_on_container_move_assignment = std::true_type
 
using is_always_equal = std::true_type
 

Public Member Functions

template<class U >
 page_allocator (const page_allocator< U > &) noexcept
 
size_type max_size () const noexcept
 
pointer address (reference x) const noexcept
 
const_pointer address (const_reference x) const noexcept
 
pointer allocate (size_type n, const void *=nullptr)
 
void deallocate (pointer p, size_type n)
 
template<class U , class... Args>
void construct (U *p, Args &&... args)
 
template<class U >
void destroy (U *p)
 

Detailed Description

template<typename T>
class afio_v2_xxx::utils::page_allocator< T >

An STL allocator which allocates large TLB page memory.

If the operating system is configured to allow it, this type of memory is particularly efficient for doing large scale file i/o. This is because the kernel must normally convert the scatter gather buffers you pass into extended scatter gather buffers as the memory you see as contiguous may not, and probably isn't, actually be contiguous in physical memory. Regions returned by this allocator may be allocated contiguously in physical memory and therefore the kernel can pass through your scatter gather buffers unmodified.

A particularly useful combination with this allocator is with the page_sizes() member function of afio_dispatcher. This will return which pages sizes are possible, and which page sizes are enabled for this user. If writing a file copy routine for example, using this allocator with the largest page size as the copy chunk makes a great deal of sense.

Be aware that as soon as the allocation exceeds a large page size, most systems allocate in multiples of the large page size, so if the large page size were 2Mb and you allocate 2Mb + 1 byte, 4Mb is actually consumed.


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