Phase 1 Commit: Comprehensive documentation and build system cleanup Added Documentation: - BENCHMARK_SUMMARY_20251122.md: Current performance baseline - COMPREHENSIVE_BENCHMARK_REPORT_20251122.md: Detailed analysis - LARSON_SLOWDOWN_INVESTIGATION_REPORT.md: Larson benchmark deep dive - ATOMIC_FREELIST_*.md (5 files): Complete atomic freelist documentation - Implementation strategy, quick start, site-by-site guide - Index and summary for easy navigation Added Scripts: - run_comprehensive_benchmark.sh: Automated benchmark runner - scripts/analyze_freelist_sites.sh: Freelist analysis tool - scripts/verify_atomic_freelist_conversion.sh: Conversion verification Build System: - Updated .gitignore: Added *.d (build dependency files) - Cleaned up tracked .d files (will be ignored going forward) Performance Status (2025-11-22): - Random Mixed 256B: 59.6M ops/s (VERIFIED WORKING) - Benchmark command: ./out/release/bench_random_mixed_hakmem 10000000 256 42 - Known issue: workset=8192 causes SEGV (to be fixed separately) Notes: - bench_random_mixed.c already tracked, working state confirmed - Ultra SLIM implementation backed up to /tmp/ (Phase 2 restore pending) - Documentation covers atomic freelist conversion and benchmarking methodology 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
174 lines
5.8 KiB
Bash
Executable File
174 lines
5.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# analyze_freelist_sites.sh - Automated freelist site analysis
|
|
|
|
set -e
|
|
|
|
echo "========================================"
|
|
echo "Atomic Freelist Site Analysis"
|
|
echo "========================================"
|
|
echo ""
|
|
|
|
# Color codes
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
echo "=== OVERALL STATISTICS ==="
|
|
TOTAL=$(grep -rn "meta->freelist" core/ --include="*.c" --include="*.h" 2>/dev/null | wc -l)
|
|
echo -e "${GREEN}Total freelist access sites: ${TOTAL}${NC}"
|
|
|
|
READS=$(grep -rn "meta->freelist" core/ --include="*.c" --include="*.h" 2>/dev/null | grep -v "=" | wc -l)
|
|
echo " Read operations (checks/loads): ${READS}"
|
|
|
|
WRITES=$(grep -rn "meta->freelist.*=" core/ --include="*.c" --include="*.h" 2>/dev/null | grep -v "==" | grep -v "!=" | wc -l)
|
|
echo " Write operations (assignments): ${WRITES}"
|
|
|
|
echo ""
|
|
|
|
echo "=== PHASE 1: CRITICAL HOT PATHS ==="
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}File 1: core/tiny_superslab_alloc.inc.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/tiny_superslab_alloc.inc.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
grep -n "meta->freelist" core/tiny_superslab_alloc.inc.h 2>/dev/null | head -10
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}File 2: core/hakmem_tiny_refill_p0.inc.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/hakmem_tiny_refill_p0.inc.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
grep -n "meta->freelist" core/hakmem_tiny_refill_p0.inc.h 2>/dev/null | head -10
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}File 3: core/box/carve_push_box.c${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/box/carve_push_box.c 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
grep -n "meta->freelist" core/box/carve_push_box.c 2>/dev/null | head -10
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}File 4: core/hakmem_tiny_tls_ops.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/hakmem_tiny_tls_ops.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
grep -n "meta->freelist" core/hakmem_tiny_tls_ops.h 2>/dev/null | head -10
|
|
echo ""
|
|
|
|
echo "=== PHASE 2: IMPORTANT PATHS ==="
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}File 5: core/tiny_refill_opt.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/tiny_refill_opt.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
|
|
echo -e "${YELLOW}File 6: core/tiny_free_magazine.inc.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/tiny_free_magazine.inc.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
|
|
echo -e "${YELLOW}File 7: core/refill/ss_refill_fc.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/refill/ss_refill_fc.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
|
|
echo -e "${YELLOW}File 8: core/slab_handle.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/slab_handle.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES}"
|
|
|
|
echo ""
|
|
|
|
echo "=== PHASE 3: DEBUG/STATS (SKIP CONVERSION) ==="
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}File 9: core/box/ss_stats_box.c${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/box/ss_stats_box.c 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES} (debug only)"
|
|
|
|
echo -e "${YELLOW}File 10: core/tiny_debug.h${NC}"
|
|
SITES=$(grep -n "meta->freelist" core/tiny_debug.h 2>/dev/null | wc -l)
|
|
echo " Total sites: ${SITES} (debug only)"
|
|
|
|
echo ""
|
|
|
|
echo "=== OPERATION BREAKDOWN ==="
|
|
echo ""
|
|
|
|
POP_PATTERN=$(grep -B1 -A1 "meta->freelist.*tiny_next_read\|tiny_next_read.*meta->freelist" core/ -r --include="*.c" --include="*.h" 2>/dev/null | grep -c "meta->freelist" || true)
|
|
echo " POP operations (load + next): ${POP_PATTERN}"
|
|
|
|
PUSH_PATTERN=$(grep -B1 "meta->freelist = " core/ -r --include="*.c" --include="*.h" 2>/dev/null | grep -c "tiny_next_write" || true)
|
|
echo " PUSH operations (write + assign): ${PUSH_PATTERN}"
|
|
|
|
NULL_CHECKS=$(grep -rn "meta->freelist" core/ --include="*.c" --include="*.h" 2>/dev/null | grep -E "if.*freelist|while.*freelist" | wc -l)
|
|
echo " NULL checks (if/while conditions): ${NULL_CHECKS}"
|
|
|
|
DIRECT_ASSIGN=$(grep -rn "meta->freelist.*=" core/ --include="*.c" --include="*.h" 2>/dev/null | grep -v "==" | grep -v "!=" | wc -l)
|
|
echo " Direct assignments (store): ${DIRECT_ASSIGN}"
|
|
|
|
echo ""
|
|
|
|
echo "=== FILES WITH FREELIST USAGE ==="
|
|
echo ""
|
|
grep -rl "meta->freelist" core/ --include="*.c" --include="*.h" 2>/dev/null | sort | nl
|
|
echo ""
|
|
|
|
echo "=== CONVERSION ESTIMATES ==="
|
|
echo ""
|
|
|
|
PHASE1_FILES=5
|
|
PHASE1_SITES=25
|
|
PHASE2_FILES=10
|
|
PHASE2_SITES=40
|
|
PHASE3_FILES=5
|
|
PHASE3_SITES=25
|
|
|
|
echo "Phase 1 (Critical Hot Paths):"
|
|
echo " Files: ${PHASE1_FILES}"
|
|
echo " Sites: ${PHASE1_SITES}"
|
|
echo " Time: 2-3 hours"
|
|
echo ""
|
|
|
|
echo "Phase 2 (Important Paths):"
|
|
echo " Files: ${PHASE2_FILES}"
|
|
echo " Sites: ${PHASE2_SITES}"
|
|
echo " Time: 2-3 hours"
|
|
echo ""
|
|
|
|
echo "Phase 3 (Cleanup):"
|
|
echo " Files: ${PHASE3_FILES}"
|
|
echo " Sites: ${PHASE3_SITES}"
|
|
echo " Time: 1-2 hours"
|
|
echo ""
|
|
|
|
TOTAL_EFFORT="5-8 hours"
|
|
echo -e "${GREEN}Total Estimated Effort: ${TOTAL_EFFORT}${NC}"
|
|
echo ""
|
|
|
|
echo "=== LOCK-PROTECTED SITES CHECK ==="
|
|
echo ""
|
|
LOCK_PROTECTED=$(grep -B10 "meta->freelist" core/ -r --include="*.c" --include="*.h" 2>/dev/null | grep -c "pthread_mutex\|mutex_lock" || true)
|
|
echo " Sites potentially protected by locks: ${LOCK_PROTECTED}"
|
|
if [ ${LOCK_PROTECTED} -gt 0 ]; then
|
|
echo -e " ${YELLOW}Review these sites - may not need atomic conversion${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
echo "=== EXISTING ATOMIC PATTERNS (for reference) ==="
|
|
echo ""
|
|
EXISTING_ATOMIC=$(grep -rn "atomic_load\|atomic_store\|atomic_compare_exchange" core/ --include="*.c" --include="*.h" 2>/dev/null | wc -l)
|
|
echo " Existing atomic operations in codebase: ${EXISTING_ATOMIC}"
|
|
echo " (can use as reference for memory ordering)"
|
|
echo ""
|
|
|
|
echo "=== NEXT STEPS ==="
|
|
echo ""
|
|
echo "1. Review ATOMIC_FREELIST_IMPLEMENTATION_STRATEGY.md"
|
|
echo "2. Review ATOMIC_FREELIST_SITE_BY_SITE_GUIDE.md"
|
|
echo "3. Create core/box/slab_freelist_atomic.h (30 min)"
|
|
echo "4. Start Phase 1 conversion (5 files, 2-3 hours)"
|
|
echo "5. Test with: ./out/release/larson_hakmem 8 100000 256"
|
|
echo ""
|
|
|
|
echo "========================================"
|
|
echo "Analysis Complete"
|
|
echo "========================================"
|