diff --git a/tools/cache_collect/CMakeLists.txt b/tools/cache_collect/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..54a2a3951a81d3212cb31fe79593878e070391c9 --- /dev/null +++ b/tools/cache_collect/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 3.12.0) +project(cache_collect) + +include_directories(${CMAKE_CURRENT_LIST_DIR}/../../output/include) +include_directories(${CMAKE_CURRENT_LIST_DIR}/../../util) +file(GLOB SRC_FILES ${CMAKE_CURRENT_LIST_DIR}/*.cpp) + +add_executable(cache_collect ${SRC_FILES}) + +target_link_directories(cache_collect PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../output/lib) +target_link_libraries(cache_collect PRIVATE sym kperf) \ No newline at end of file diff --git a/tools/cache_collect/README.md b/tools/cache_collect/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7df18e82ab15207e9d6e4cc4320e0e60619d6ff8 --- /dev/null +++ b/tools/cache_collect/README.md @@ -0,0 +1,144 @@ +# Cache Collect Tool +### Description +This tool is designed to collect L2I cache, l2D cache infomation of go program. + +1. It generates statistics of hotspots from the function and instruction perspectives. + +2. It reports the L2I cache miss ratio, L2D cache miss ratio, and IPC (Instructions Per Cycle) for each process. + +In L2I cache collect mode, the corresponding data can be output as a txt file for BOLT in the work directory. +Format: 1 [funcName] [offset] [number] + +[number] is the sample count for [funcName] at [offset] + +### Build +Build the libkperf tool first: +``` +bash build.sh +``` + +then: +``` +cd tools/cache_collect +mkdir build && cd build +cmake .. +make +``` + +### Run +Use 'cache_collect --help/-h' to view the help information. + +``` + Usage: cache_collect --pid/-p [options] + + Required: + --pid/-p : Target process ID(s). Multiple IDs can be separated by ',' + Optional: + --duration/-d : Set collection time of hotspots. Unit: s, default: 10 + --level/-l : Set to 'inst' for instruction-level summary. Default: function-level summary + --mode/-m : Set to 'dcache' to collect L2D cache data. Default: L2I cache data + --interval/-i : Interval for reading the ring buffer. Unit: ms, default: 1000 + --frequency/-f : Sampling frequency, default: 1000 + --bolt/-b