Files
hakmem/benchmarks/src/pf_test.c
Moe Charm (CI) 52386401b3 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>
2025-11-05 12:31:14 +09:00

72 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pf_test.c - Page Fault Investigation
#include "hakmem.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define SIZE (2 * 1024 * 1024)
static void get_pf(unsigned long *soft, unsigned long *hard) {
FILE* f = fopen("/proc/self/stat", "r");
if (!f) { *soft = 0; *hard = 0; return; }
unsigned long minflt = 0, majflt = 0;
(void)fscanf(f, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %lu %*u %lu",
&minflt, &majflt);
fclose(f);
*soft = minflt;
*hard = majflt;
}
void test_hakmem() {
unsigned long pf_before, pf_after, hard_before, hard_after;
printf("\n=== hakmem Test ===\n");
hak_init();
get_pf(&pf_before, &hard_before);
for (int i = 0; i < 10; i++) {
void* buf = hak_alloc_cs(SIZE);
memset(buf, 0xEF, SIZE);
hak_free_cs(buf, SIZE);
}
get_pf(&pf_after, &hard_after);
printf("Page Faults: %lu (soft), %lu (hard)\n",
pf_after - pf_before, hard_after - hard_before);
hak_shutdown();
}
void test_system() {
unsigned long pf_before, pf_after, hard_before, hard_after;
printf("\n=== system malloc Test ===\n");
get_pf(&pf_before, &hard_before);
for (int i = 0; i < 10; i++) {
void* buf = malloc(SIZE);
memset(buf, 0xEF, SIZE);
free(buf);
}
get_pf(&pf_after, &hard_after);
printf("Page Faults: %lu (soft), %lu (hard)\n",
pf_after - pf_before, hard_after - hard_before);
}
int main() {
printf("=== Page Fault Comparison ===\n");
printf("Size: 2MB × 10 iterations\n");
test_system();
test_hakmem();
return 0;
}