Skip to content

Commit

Permalink
* Rename file_buffer_allocator to page_allocator. Fixes issue #95 fro…
Browse files Browse the repository at this point in the history
…m review.
  • Loading branch information
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) committed Sep 8, 2015
1 parent d29a2d7 commit fcfe513
Show file tree
Hide file tree
Showing 23 changed files with 60 additions and 58 deletions.
4 changes: 0 additions & 4 deletions doc/disqus_identifiers/utils_file_buffer_allocator.html

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions doc/disqus_identifiers/utils_page_allocator.html
@@ -0,0 +1,4 @@
<script type="text/javascript">
var disqus_identifier = 'utils_page_allocator';
var disqus_title = 'Boost.AFIO utils::page_allocator';
</script>
4 changes: 4 additions & 0 deletions doc/disqus_identifiers/utils_page_allocator_-void-_.html
@@ -0,0 +1,4 @@
<script type="text/javascript">
var disqus_identifier = 'utils_page_allocator_-void-_';
var disqus_title = 'Boost.AFIO rebind utils::page_allocator&lt; void &gt;::rebind';
</script>
4 changes: 4 additions & 0 deletions doc/disqus_identifiers/utils_page_allocator_rebind.html
@@ -0,0 +1,4 @@
<script type="text/javascript">
var disqus_identifier = 'utils_page_allocator_rebind';
var disqus_title = 'Boost.AFIO utils::page_allocator::rebind';
</script>
Expand Up @@ -8,11 +8,11 @@


[/ Generated by doxygen_xml2qbk 1.1.1, don't change, will be overwritten automatically]
[/ Generated from doxy/doxygen_output/xml\classboost_1_1afio_1_1utils_1_1file__buffer__allocator.xml]
[section:utils_file_buffer_allocator utils::file_buffer_allocator]
'''<?dbhtml-include href="disqus_identifiers/utils_file_buffer_allocator.html"?>'''
[/ Generated from doxy/doxygen_output/xml\classboost_1_1afio_1_1utils_1_1page__allocator.xml]
[section:utils_page_allocator utils::page_allocator]
'''<?dbhtml-include href="disqus_identifiers/utils_page_allocator.html"?>'''

'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>file_buffer_allocator</primary></indexterm>'''
'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>page_allocator</primary></indexterm>'''
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.

[heading Description]
Expand All @@ -22,7 +22,7 @@ Be aware that as soon as the allocation exceeds a large page size, most systems

[heading Synopsis]
``template<typename T>
class utils::file_buffer_allocator
class utils::page_allocator
{
// ...
};
Expand All @@ -37,15 +37,15 @@ class utils::file_buffer_allocator
[heading Constructor(s)]
[table
[[Function] [Description] [Parameters] ]
[[``file_buffer_allocator()``
[[``page_allocator()``

] [] [

]]
[[``template<class U>
file_buffer_allocator(const file_buffer_allocator< U > & )``
page_allocator(const page_allocator< U > & )``

] [] [[* const file_buffer_allocator< U > &]: [']:
] [] [[* const page_allocator< U > &]: [']:



Expand Down
Expand Up @@ -8,15 +8,15 @@


[/ Generated by doxygen_xml2qbk 1.1.1, don't change, will be overwritten automatically]
[/ Generated from doxy/doxygen_output/xml\classboost_1_1afio_1_1utils_1_1file__buffer__allocator_3_01void_01_4.xml]
[section:utils_file_buffer_allocator< void > utils::file_buffer_allocator< void >]
'''<?dbhtml-include href="disqus_identifiers/utils_file_buffer_allocator_-void-_.html"?>'''
[/ Generated from doxy/doxygen_output/xml\classboost_1_1afio_1_1utils_1_1page__allocator_3_01void_01_4.xml]
[section:utils_page_allocator< void > utils::page_allocator< void >]
'''<?dbhtml-include href="disqus_identifiers/utils_page_allocator_-void-_.html"?>'''

'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>file_buffer_allocator< void ></primary></indexterm>'''
'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>page_allocator< void ></primary></indexterm>'''


[heading Synopsis]
``class utils::file_buffer_allocator< void >
``class utils::page_allocator< void >
{
// ...
};
Expand Down
2 changes: 1 addition & 1 deletion doc/generated/group_async_file_io_dispatcher.qbk
Expand Up @@ -53,7 +53,7 @@ URIs currently supported by AFIO:

[heading Synopsis]
``BOOST_AFIO_DECL outcome<dispatcher_ptr> make_dispatcher(std::string uri = "file : / / /", file_flags flagsforce = file_flags::none, file_flags flagsmask = file_flags::none,
std::shared_ptr< thread_source > threadpool = process_threadpool())``
std::shared_ptr< thread_source > threadpool = process_threadpool())``

[heading Parameters]

Expand Down
2 changes: 1 addition & 1 deletion doc/generated/group_utils.qbk
Expand Up @@ -43,7 +43,7 @@ The page sizes of this architecture.
'''<?dbhtml-include href="disqus_identifiers/file_buffer_default_size.html"?>'''

'''<indexterm><primary>file_buffer_default_size</primary></indexterm>'''
Returns a reasonable default size for file\u005fbuffer\u005fallocator, typically the closest page size from page\u005fsizes() to 1Mb.
Returns a reasonable default size for page\u005fallocator, typically the closest page size from page\u005fsizes() to 1Mb.

[heading Synopsis]
``size_t utils::file_buffer_default_size()``
Expand Down
Expand Up @@ -8,16 +8,16 @@


[/ Generated by doxygen_xml2qbk 1.1.1, don't change, will be overwritten automatically]
[/ Generated from doxy/doxygen_output/xml\structboost_1_1afio_1_1utils_1_1file__buffer__allocator_1_1rebind.xml]
[section:utils_file_buffer_allocator_rebind utils::file_buffer_allocator::rebind]
'''<?dbhtml-include href="disqus_identifiers/utils_file_buffer_allocator_rebind.html"?>'''
[/ Generated from doxy/doxygen_output/xml\structboost_1_1afio_1_1utils_1_1page__allocator_1_1rebind.xml]
[section:utils_page_allocator_rebind utils::page_allocator::rebind]
'''<?dbhtml-include href="disqus_identifiers/utils_page_allocator_rebind.html"?>'''

'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>file_buffer_allocator</primary></indexterm><indexterm><primary>rebind</primary></indexterm>'''
'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>page_allocator</primary></indexterm><indexterm><primary>rebind</primary></indexterm>'''


[heading Synopsis]
``template<class U>
struct utils::file_buffer_allocator::rebind
struct utils::page_allocator::rebind
{
// ...
};
Expand Down
Expand Up @@ -8,16 +8,16 @@


[/ Generated by doxygen_xml2qbk 1.1.1, don't change, will be overwritten automatically]
[/ Generated from doxy/doxygen_output/xml\structboost_1_1afio_1_1utils_1_1file__buffer__allocator_3_01void_01_4_1_1rebind.xml]
[section:utils_file_buffer_allocator< void >_rebind utils::file_buffer_allocator< void >::rebind]
'''<?dbhtml-include href="disqus_identifiers/utils_file_buffer_allocator_-void-_.html"?>'''
[/ Generated from doxy/doxygen_output/xml\structboost_1_1afio_1_1utils_1_1page__allocator_3_01void_01_4_1_1rebind.xml]
[section:utils_page_allocator< void >_rebind utils::page_allocator< void >::rebind]
'''<?dbhtml-include href="disqus_identifiers/utils_page_allocator_-void-_.html"?>'''

'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>file_buffer_allocator< void ></primary></indexterm><indexterm><primary>rebind</primary></indexterm>'''
'''<indexterm><primary>utils</primary></indexterm><indexterm><primary>page_allocator< void ></primary></indexterm><indexterm><primary>rebind</primary></indexterm>'''


[heading Synopsis]
``template<class U>
struct utils::file_buffer_allocator< void >::rebind
struct utils::page_allocator< void >::rebind
{
// ...
};
Expand Down
4 changes: 2 additions & 2 deletions doc/quickstart.qbk
Expand Up @@ -147,7 +147,7 @@ the file.
The write stream is a bit more complicated: we fill a 4Kb page and ['asynchronously] write it out
using a page stealing friendly algorithm which in the usual case means the kernel simply takes possession of
the 4Kb page as-is with no memory copying at all. At some future point it will be flushed onto storage. The
reason this works is thanks to the special STL allocator `utils::file_buffer_allocator<>` which returns whole kernel
reason this works is thanks to the special STL allocator `utils::page_allocator<>` which returns whole kernel
page cache pages. Most kernels will mark whole pages scheduled for write with copy-on-write behaviour such that
they can be safely DMAed by the kernel DMA engine as any subsequent write will cause a copy, so because we never write to the page between the write
request and freeing the page, most kernels simply transfer ownership of the page from the user space process
Expand Down Expand Up @@ -887,7 +887,7 @@ is a very good example, incidentally, of why C++11 is like a whole new language
C++98 even for simple systems programming tasks like this one.

You may note that the temporary buffers for each chunk are allocated using a special
`file_buffer_allocator`. If your operating system allows it, regions of memory returned
`page_allocator`. If your operating system allows it, regions of memory returned
by this allocator have the maximum possible scatter gather DMA efficiency possible.
Even if your operating system doesn't allow it, it does no harm to use this allocator
instead of the system allocator.
Expand Down
2 changes: 1 addition & 1 deletion doc/reference.qbk
Expand Up @@ -99,7 +99,7 @@

[section:utilities Utilities]
[section:classes Classes]
[include generated/class_utils_1_1file_buffer_allocator.qbk]
[include generated/class_utils_1_1page_allocator.qbk]
[include generated/class_utils_1_1secded_ecc.qbk]
[endsect]
[section:function Functions in namespace utils]
Expand Down
4 changes: 3 additions & 1 deletion doc/release_notes.qbk
Expand Up @@ -152,6 +152,8 @@ explicitly closed, the async_io_handle destructor must synchronously close)
link() or file(file_flags::create_compressed). This caused test failure on FAT32 and ReFS
volumes on Windows as those operations are not supported.

* Rename file_buffer_allocator to page_allocator. Fixes issue #95 from review.

[/=================]
[heading Boost 1.59 AFIO v1.40 alpha 21st August 2015 Boost peer review 1 edition]
[/=================]
Expand Down Expand Up @@ -329,7 +331,7 @@ expect-based lldb automator to get stack backtraces of failures, which was tedio
* page_size() has become page_sizes(), and now can return large/huge page sizes. A file_buffer_default_size()
new API will return the closest page size to 1Mb.

* Added file_buffer_allocator, a STL allocator suitable for allocating efficient large file buffers.
* Added page_allocator, a STL allocator suitable for allocating efficient large file buffers.

* stat_t flags, gen and birthtime weren't being set on FreeBSD. Sorry.

Expand Down
2 changes: 1 addition & 1 deletion example/filecopy_example.cpp
Expand Up @@ -21,7 +21,7 @@ namespace {

// Keep memory buffers around
// A special allocator of highly efficient file i/o memory
typedef std::vector<char, utils::file_buffer_allocator<char>> file_buffer_type;
typedef std::vector<char, utils::page_allocator<char>> file_buffer_type;
static std::vector<std::unique_ptr<file_buffer_type>> buffers;

// Parallel copy files in sources into dest, concatenating
Expand Down
2 changes: 1 addition & 1 deletion example/workshop_atomic_updates_afio.ipp
Expand Up @@ -37,7 +37,7 @@ using BOOST_AFIO_V2_NAMESPACE::error_code;
using BOOST_AFIO_V2_NAMESPACE::generic_category;

// A special allocator of highly efficient file i/o memory
using file_buffer_type = std::vector<char, afio::utils::file_buffer_allocator<char>>;
using file_buffer_type = std::vector<char, afio::utils::page_allocator<char>>;

// An iostream which reads directly from a memory mapped AFIO file
struct idirectstream : public std::istream
Expand Down
4 changes: 2 additions & 2 deletions example/workshop_final_afio.ipp
Expand Up @@ -49,7 +49,7 @@ using BOOST_AFIO_V2_NAMESPACE::generic_category;
using BOOST_OUTCOME_V1_NAMESPACE::outcome;

// A special allocator of highly efficient file i/o memory
using file_buffer_type = std::vector<char, afio::utils::file_buffer_allocator<char>>;
using file_buffer_type = std::vector<char, afio::utils::page_allocator<char>>;

// Serialisation helper types
#pragma pack(push, 1)
Expand Down Expand Up @@ -421,7 +421,7 @@ using BOOST_AFIO_V2_NAMESPACE::error_code;
using BOOST_AFIO_V2_NAMESPACE::generic_category;

// A special allocator of highly efficient file i/o memory
using file_buffer_type = std::vector<char, afio::utils::file_buffer_allocator<char>>;
using file_buffer_type = std::vector<char, afio::utils::page_allocator<char>>;

// An iostream which reads directly from a memory mapped AFIO file
struct idirectstream : public std::istream
Expand Down
2 changes: 1 addition & 1 deletion example/workshop_naive_afio.ipp
Expand Up @@ -37,7 +37,7 @@ using BOOST_AFIO_V2_NAMESPACE::error_code;
using BOOST_AFIO_V2_NAMESPACE::generic_category;

// A special allocator of highly efficient file i/o memory
using file_buffer_type = std::vector<char, afio::utils::file_buffer_allocator<char>>;
using file_buffer_type = std::vector<char, afio::utils::page_allocator<char>>;

// An iostream which reads directly from a memory mapped AFIO file
struct idirectstream : public std::istream
Expand Down
2 changes: 1 addition & 1 deletion example/workshop_naive_async_afio.ipp
Expand Up @@ -36,7 +36,7 @@ using BOOST_AFIO_V2_NAMESPACE::error_code;
using BOOST_AFIO_V2_NAMESPACE::generic_category;

// A special allocator of highly efficient file i/o memory
using file_buffer_type = std::vector<char, afio::utils::file_buffer_allocator<char>>;
using file_buffer_type = std::vector<char, afio::utils::page_allocator<char>>;

// An iostream which reads directly from a memory mapped AFIO file
struct idirectstream : public std::istream
Expand Down
18 changes: 9 additions & 9 deletions include/boost/afio/v2/afio.hpp
Expand Up @@ -5780,7 +5780,7 @@ namespace utils
*/
BOOST_AFIO_HEADERS_ONLY_FUNC_SPEC std::vector<size_t> page_sizes(bool only_actually_available = true) noexcept;

/*! \brief Returns a reasonable default size for file_buffer_allocator, typically the closest page size from
/*! \brief Returns a reasonable default size for page_allocator, typically the closest page size from
page_sizes() to 1Mb.
\return A value of a TLB large page size close to 1Mb.
Expand Down Expand Up @@ -6236,7 +6236,7 @@ namespace utils
BOOST_AFIO_HEADERS_ONLY_FUNC_SPEC large_page_allocation allocate_large_pages(size_t bytes);
BOOST_AFIO_HEADERS_ONLY_FUNC_SPEC void deallocate_large_pages(void *p, size_t bytes);
}
/*! \class file_buffer_allocator
/*! \class page_allocator
\brief An STL allocator which allocates large TLB page memory.
\ingroup utils
Expand All @@ -6255,7 +6255,7 @@ namespace utils
page size, so if the large page size were 2Mb and you allocate 2Mb + 1 byte, 4Mb is actually consumed.
*/
template <typename T>
class file_buffer_allocator
class page_allocator
{
public:
typedef T value_type;
Expand All @@ -6269,13 +6269,13 @@ namespace utils
typedef std::true_type is_always_equal;

template <class U>
struct rebind { typedef file_buffer_allocator<U> other; };
struct rebind { typedef page_allocator<U> other; };

file_buffer_allocator() noexcept
page_allocator() noexcept
{}

template <class U>
file_buffer_allocator(const file_buffer_allocator<U>&) noexcept
page_allocator(const page_allocator<U>&) noexcept
{}

size_type
Expand Down Expand Up @@ -6319,7 +6319,7 @@ namespace utils
{ p->~U(); }
};
template <>
class file_buffer_allocator<void>
class page_allocator<void>
{
public:
typedef void value_type;
Expand All @@ -6329,9 +6329,9 @@ namespace utils
typedef std::true_type is_always_equal;

template <class U>
struct rebind { typedef file_buffer_allocator<U> other; };
struct rebind { typedef page_allocator<U> other; };
};
template<class T, class U> inline bool operator==(const file_buffer_allocator<T> &, const file_buffer_allocator<U> &) noexcept { return true; }
template<class T, class U> inline bool operator==(const page_allocator<T> &, const page_allocator<U> &) noexcept { return true; }
}


Expand Down
2 changes: 1 addition & 1 deletion include/boost/afio/v2/detail/impl/afio.ipp
Expand Up @@ -2560,7 +2560,7 @@ namespace detail {
// Fall back onto a write of zeros
if(!done)
{
std::vector<char, utils::file_buffer_allocator<char>> buffer(utils::file_buffer_default_size());
std::vector<char, utils::page_allocator<char>> buffer(utils::file_buffer_default_size());
for(auto &i: ranges)
{
ssize_t byteswritten=0;
Expand Down
2 changes: 1 addition & 1 deletion test/tests/async_io_pagesize.cpp
Expand Up @@ -15,7 +15,7 @@ BOOST_AFIO_AUTO_TEST_CASE(async_io_pagesize, "Tests that the utility functions w
std::cout << " " << i << " bytes" << std::endl;
BOOST_CHECK(!utils::page_sizes(true).empty());

std::vector<char, utils::file_buffer_allocator<char>> fba(8*1024*1024);
std::vector<char, utils::page_allocator<char>> fba(8*1024*1024);
auto fba_detail(utils::detail::calculate_large_page_allocation(8*1024*1024));
std::cout << "\n\nAllocating 8Mb with the file buffer allocator yields an address at " << ((void *) fba.data())
<< " and may use pages of " << fba_detail.page_size_used << " and be actually "
Expand Down

0 comments on commit fcfe513

Please sign in to comment.