Debug Counters Implementation - Clean History
Major Features: - Debug counter infrastructure for Refill Stage tracking - Free Pipeline counters (ss_local, ss_remote, tls_sll) - Diagnostic counters for early return analysis - Unified larson.sh benchmark runner with profiles - Phase 6-3 regression analysis documentation Bug Fixes: - Fix SuperSlab disabled by default (HAKMEM_TINY_USE_SUPERSLAB) - Fix profile variable naming consistency - Add .gitignore patterns for large files Performance: - Phase 6-3: 4.79 M ops/s (has OOM risk) - With SuperSlab: 3.13 M ops/s (+19% improvement) This is a clean repository without large log files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
62
archive/tools/vm_profile_system.c
Normal file
62
archive/tools/vm_profile_system.c
Normal file
@ -0,0 +1,62 @@
|
||||
// vm_profile_system.c - Detailed profiling for system malloc
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define ITERATIONS 10
|
||||
#define SIZE (2 * 1024 * 1024)
|
||||
|
||||
static double timespec_diff_ms(struct timespec *start, struct timespec *end) {
|
||||
return (end->tv_sec - start->tv_sec) * 1000.0 +
|
||||
(end->tv_nsec - start->tv_nsec) / 1000000.0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
struct timespec t_start, t_end;
|
||||
double total_alloc_time = 0.0;
|
||||
double total_memset_time = 0.0;
|
||||
double total_free_time = 0.0;
|
||||
|
||||
printf("=== VM Scenario Detailed Profile (SYSTEM MALLOC) ===\n");
|
||||
printf("Size: %d bytes (2MB)\n", SIZE);
|
||||
printf("Iterations: %d\n\n", ITERATIONS);
|
||||
|
||||
for (int i = 0; i < ITERATIONS; i++) {
|
||||
// Time: Allocation
|
||||
clock_gettime(CLOCK_MONOTONIC, &t_start);
|
||||
void* buf = malloc(SIZE);
|
||||
clock_gettime(CLOCK_MONOTONIC, &t_end);
|
||||
double alloc_ms = timespec_diff_ms(&t_start, &t_end);
|
||||
total_alloc_time += alloc_ms;
|
||||
|
||||
// Time: memset (simulate usage)
|
||||
clock_gettime(CLOCK_MONOTONIC, &t_start);
|
||||
memset(buf, 0xEF, SIZE);
|
||||
clock_gettime(CLOCK_MONOTONIC, &t_end);
|
||||
double memset_ms = timespec_diff_ms(&t_start, &t_end);
|
||||
total_memset_time += memset_ms;
|
||||
|
||||
// Time: Free
|
||||
clock_gettime(CLOCK_MONOTONIC, &t_start);
|
||||
free(buf);
|
||||
clock_gettime(CLOCK_MONOTONIC, &t_end);
|
||||
double free_ms = timespec_diff_ms(&t_start, &t_end);
|
||||
total_free_time += free_ms;
|
||||
|
||||
printf("Iter %2d: alloc=%.3f ms, memset=%.3f ms, free=%.3f ms\n",
|
||||
i, alloc_ms, memset_ms, free_ms);
|
||||
}
|
||||
|
||||
printf("\n=== Summary ===\n");
|
||||
printf("Total alloc time: %.3f ms (avg: %.3f ms)\n",
|
||||
total_alloc_time, total_alloc_time / ITERATIONS);
|
||||
printf("Total memset time: %.3f ms (avg: %.3f ms)\n",
|
||||
total_memset_time, total_memset_time / ITERATIONS);
|
||||
printf("Total free time: %.3f ms (avg: %.3f ms)\n",
|
||||
total_free_time, total_free_time / ITERATIONS);
|
||||
printf("Total time: %.3f ms\n",
|
||||
total_alloc_time + total_memset_time + total_free_time);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user