Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2021-08-21 20:39:45 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2021-08-21 20:39:45 +0300
commit2917dc7799bc3be9c3fef406ccde21a273aeaffc (patch)
tree9a85cba3daafe6695be1f038b8725e8d6229dd27 /test
parent46f0760e7ed2b80c46acd91bacc130049620bee6 (diff)
map_handle cache now looks to be working well.
Diffstat (limited to 'test')
-rw-r--r--test/tests/map_handle_cache.cpp41
-rw-r--r--test/tests/utils.cpp12
2 files changed, 35 insertions, 18 deletions
diff --git a/test/tests/map_handle_cache.cpp b/test/tests/map_handle_cache.cpp
index 1756273b..4e25c27f 100644
--- a/test/tests/map_handle_cache.cpp
+++ b/test/tests/map_handle_cache.cpp
@@ -27,18 +27,20 @@ Distributed under the Boost Software License, Version 1.0.
#include <deque>
#include <list>
+inline QUICKCPPLIB_NOINLINE void fault(LLFIO_V2_NAMESPACE::map_handle &mh)
+{
+ for(auto *p = (volatile char *) mh.address(); p < (volatile char *) mh.address() + mh.length(); p += mh.page_size())
+ {
+ *p = 1;
+ }
+};
+
static inline void TestMapHandleCache()
{
static constexpr size_t ITEMS_COUNT = 10000;
namespace llfio = LLFIO_V2_NAMESPACE;
- bool free_cache_immediately = false;
+ bool free_cache_immediately = true;
auto test = [&] {
- auto fault = [](llfio::map_handle &mh) {
- for(auto *p = (volatile char *) mh.address(); p < (volatile char *) mh.address() + mh.length(); p += mh.page_size())
- {
- *p = 1;
- }
- };
QUICKCPPLIB_NAMESPACE::algorithm::small_prng::small_prng rand;
std::vector<llfio::map_handle> maps;
for(size_t n = 0; n < ITEMS_COUNT; n++)
@@ -59,7 +61,8 @@ static inline void TestMapHandleCache()
BOOST_REQUIRE(stats.items_in_cache == 0);
}
auto begin = std::chrono::steady_clock::now();
- for(size_t n = 0; n < ITEMS_COUNT * 10; n++)
+ size_t ops = 0;
+ for(size_t n = 0; n < ITEMS_COUNT * 100; n++)
{
auto v = rand();
auto toallocate = (v >> 2) & (128 * 1024 - 1);
@@ -70,10 +73,12 @@ static inline void TestMapHandleCache()
if(v & 1)
{
maps[n % ITEMS_COUNT].close().value();
+ ops++;
}
else
{
fault((maps[n % ITEMS_COUNT] = llfio::map_handle::map(toallocate, false).value()));
+ ops += 2;
}
if(free_cache_immediately)
{
@@ -85,8 +90,11 @@ static inline void TestMapHandleCache()
auto end = std::chrono::steady_clock::now();
{
auto stats = llfio::map_handle::trim_cache();
- std::cout << "\nIn the map_handle cache after churn there are " << stats.bytes_in_cache << " bytes in the cache in " << stats.items_in_cache << " items."
- << std::endl;
+ auto usage = llfio::utils::current_process_memory_usage().value();
+ std::cout << "\n\nIn the map_handle cache after churn there are " << (stats.bytes_in_cache / 1024.0 / 1024.0) << " Mb in the cache in "
+ << stats.items_in_cache << " items. There were " << stats.hits << " hits and " << stats.misses
+ << " misses. Process virtual address space used is " << (usage.total_address_space_in_use / 1024.0 / 1024.0 / 1024.0)
+ << " Gb and commit charge is " << (usage.private_committed / 1024.0 / 1024.0) << " Mb." << std::endl;
}
for(auto &i : maps)
{
@@ -94,14 +102,17 @@ static inline void TestMapHandleCache()
}
{
auto stats = llfio::map_handle::trim_cache();
- std::cout << "\nIn the map_handle cache after releasing everything there are " << stats.bytes_in_cache << " bytes in the cache in "
- << stats.items_in_cache << " items." << std::endl;
+ auto usage = llfio::utils::current_process_memory_usage().value();
+ std::cout << "\nIn the map_handle cache after releasing everything there are " << (stats.bytes_in_cache / 1024.0 / 1024.0) << " Mb in the cache in "
+ << stats.items_in_cache << " items. Process virtual address space used is " << (usage.total_address_space_in_use / 1024.0 / 1024.0 / 1024.0)
+ << " Gb and commit charge is " << (usage.private_committed / 1024.0 / 1024.0) << " Mb." << std::endl;
}
- std::cout << "With free_cache_immediately = " << free_cache_immediately << " it took "
- << (std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count() / 1000.0 / ITEMS_COUNT) << " us per allocation-free." << std::endl;
+ std::cout << "\nWith free_cache_immediately = " << free_cache_immediately << " it took "
+ << (std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count() / 1000.0 / ops) << " us per allocation-free."
+ << std::endl;
};
test();
- free_cache_immediately = true;
+ free_cache_immediately = false;
test();
}
diff --git a/test/tests/utils.cpp b/test/tests/utils.cpp
index 07712229..82967e87 100644
--- a/test/tests/utils.cpp
+++ b/test/tests/utils.cpp
@@ -172,15 +172,21 @@ static inline void TestCurrentProcessMemoryUsage()
BOOST_CHECK(within(before_anything, after_fault, 1024, 1024, 1024, 1024));
BOOST_CHECK(within(before_anything, after_decommit, 1024, 0, 0, 0));
#ifdef _WIN32
- BOOST_CHECK(within(before_anything, after_zero, 1024, 0, 1024, 0)); // may not evict faulted set on POSIX
+ BOOST_CHECK(within(before_anything, after_zero, 1024, 0, 1024, 0));
+ BOOST_CHECK(within(before_anything, after_do_not_store, 1024, 0, 1024, 0)); // do_not_store() decreases RSS but not commit on Windows
#else
- (void) after_zero;
+ (void) after_zero; // may not evict faulted set on POSIX
+ BOOST_CHECK(within(before_anything, after_do_not_store, 1024, 1024, 0, 1024)); // do_not_store() decreases commit but does not RSS on POSIX
#endif
- BOOST_CHECK(within(before_anything, after_do_not_store, 1024, 0, 1024, 0));
#endif
}
std::cout << "\nFor file mapping:\n";
{
+ auto stats = llfio::map_handle::trim_cache(std::chrono::steady_clock::now());
+ BOOST_REQUIRE(stats.bytes_in_cache == 0);
+ BOOST_REQUIRE(stats.items_in_cache == 0);
+ }
+ {
auto sectionh = llfio::section_handle::section(1024 * 1024 * 1024).value();
llfio::utils::process_memory_usage before_anything, after_reserve, after_commit, after_fault, after_decommit, after_zero, after_do_not_store;
std::cout << " Total address space, Total address space paged in, Private bytes committed, Private bytes paged in\n\n";