mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-07 13:39:55 +00:00
perf(libc): count private collect calls only in the collect test
The private collect counted its GetWriteWatch calls and pieces on every call, under the mappings mutex, for agc_private_collect to read. They are now compiled only where APS5_COUNT_MAPPING_QUERIES is set, as the address-space query counter is: agc_private_collect_tests sets it, and the runtime's Collect updates no counter. libc's GuestArenaCollectWork export, which nothing calls (the test reads its own WindowsMappings), is removed. Adapts fable-void's 2760ad808.
This commit is contained in:
1 parent
4d57a206c7
commit
d2c46d96bb
4 files changed
+7
-5
No files matched your search
@@ -484,6 +484,7 @@ if(BUILD_TESTING)
|
||||
add_test_executable(agc_private_collect_tests EXCLUDE_FROM_ALL tests/PrivateCollect.cpp)
|
||||
target_include_directories(agc_private_collect_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(agc_private_collect_tests PRIVATE libc)
|
||||
target_compile_definitions(agc_private_collect_tests PRIVATE APS5_COUNT_MAPPING_QUERIES=1)
|
||||
set_target_properties(agc_private_collect_tests PROPERTIES CXX_EXTENSIONS OFF)
|
||||
configure_windows_unwind(agc_private_collect_tests)
|
||||
add_test(NAME agc_private_collect COMMAND agc_private_collect_tests)
|
||||
|
||||
@@ -46,7 +46,6 @@ bool GuestArenaProtection_nid_postfix(std::uintptr_t address, std::uint32_t* pro
|
||||
bool GuestArenaCollectWrites_nid_postfix(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear);
|
||||
bool GuestArenaCollectArmedWrites_nid_postfix(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear);
|
||||
bool GuestArenaCollectFreshWrites_nid_postfix(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear);
|
||||
void GuestArenaCollectWork_nid_postfix(std::uint64_t* systemCalls, std::uint64_t* pieces);
|
||||
bool GuestArenaHostRegionOverlaps_nid_postfix(std::uintptr_t address, std::size_t bytes);
|
||||
std::uint64_t GuestArenaCommitGeneration_nid_postfix();
|
||||
void GuestArenaSetPrivateMappingObserver_nid_postfix(void (*callback)(std::uintptr_t address, std::size_t bytes, std::uint64_t generation));
|
||||
|
||||
@@ -381,11 +381,13 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef APS5_COUNT_MAPPING_QUERIES
|
||||
void CollectWork(std::uint64_t* systemCalls, std::uint64_t* pieces) {
|
||||
std::lock_guard lock(mutex);
|
||||
*systemCalls = collectSystemCalls;
|
||||
*pieces = collectPieces;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Collect(std::uintptr_t address, std::size_t bytes, void** pages, std::size_t* count, bool clear, Collection collection = Collection::All) {
|
||||
std::lock_guard lock(mutex);
|
||||
@@ -528,8 +530,10 @@ public:
|
||||
const auto touched = (((stop + 4095) & ~static_cast<std::uintptr_t>(4095)) - (cursor & ~static_cast<std::uintptr_t>(4095))) / 4096;
|
||||
ULONG_PTR available = std::min<ULONG_PTR>(capacity - *count, touched);
|
||||
DWORD granularity = 0;
|
||||
#ifdef APS5_COUNT_MAPPING_QUERIES
|
||||
++collectSystemCalls;
|
||||
collectPieces += (stop + pageBytes - 1) / pageBytes - cursor / pageBytes;
|
||||
#endif
|
||||
const bool committed = !verifyDirect() || committedPrivate(cursor, stop);
|
||||
if (GetWriteWatch(clear ? WRITE_WATCH_FLAG_RESET : 0, reinterpret_cast<void*>(cursor), stop - cursor, pages + *count, &available, &granularity) != 0) {
|
||||
const auto memory = query(cursor);
|
||||
@@ -1148,8 +1152,10 @@ private:
|
||||
Ranges cleanRanges;
|
||||
Ranges collectableRanges;
|
||||
Ranges privateAllocations;
|
||||
#ifdef APS5_COUNT_MAPPING_QUERIES
|
||||
std::uint64_t collectSystemCalls = 0;
|
||||
std::uint64_t collectPieces = 0;
|
||||
#endif
|
||||
Ranges freshRanges;
|
||||
std::map<std::uintptr_t, View> views;
|
||||
|
||||
|
||||
@@ -438,10 +438,6 @@ bool GuestArenaCollectFreshWrites_nid_postfix(std::uintptr_t address, std::size_
|
||||
return WindowsMappings::Get().Collect(address, bytes, pages, count, clear, WindowsMappings::Collection::Fresh);
|
||||
}
|
||||
|
||||
void GuestArenaCollectWork_nid_postfix(std::uint64_t* systemCalls, std::uint64_t* pieces) {
|
||||
WindowsMappings::Get().CollectWork(systemCalls, pieces);
|
||||
}
|
||||
|
||||
bool GuestArenaHostRegionOverlaps_nid_postfix(std::uintptr_t address, std::size_t bytes) {
|
||||
return Arena::Get().OverlapsHostRegion(address, bytes);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user