summaryrefslogtreecommitdiff
path: root/benchmarks/profile_quick.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-26 13:49:38 +0300
committerPaul Buetow <paul@buetow.org>2025-06-26 13:49:38 +0300
commit6664996ced62c77e0c62bc1619662cbed7fccff6 (patch)
treeb995d8aa34aa68ec8f97c4be417ac96e6c6abf48 /benchmarks/profile_quick.sh
parent72828b8c5f575cfc7c7c27c5a5d3b7fd9225b625 (diff)
feat: add profiling framework with command echoing
Created a comprehensive profiling framework for dtail commands (dcat, dgrep, dmap) to analyze CPU usage and memory allocations. The framework now prints all executed commands to stdout for full transparency. Key features: - Integrated Go profiling (CPU, memory, allocations) into all three commands - Created profile.sh bash script for analyzing pprof profiles - Added multiple Makefile targets for different profiling scenarios - Automated profiling scripts with command echoing - Support for different data sizes (quick, normal, full) - Special handling for dmap MapReduce format All profiling commands are now echoed to stdout before execution, making it easy to understand what the framework is doing and reproduce commands manually. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'benchmarks/profile_quick.sh')
-rwxr-xr-xbenchmarks/profile_quick.sh86
1 files changed, 86 insertions, 0 deletions
diff --git a/benchmarks/profile_quick.sh b/benchmarks/profile_quick.sh
new file mode 100755
index 0000000..1aa9425
--- /dev/null
+++ b/benchmarks/profile_quick.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# Quick profile script for dtail commands
+# This runs profiling with smaller datasets for faster results
+
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+cd "$SCRIPT_DIR"
+
+# Colors for output
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+NC='\033[0m' # No Color
+
+# Default values
+PROFILE_DIR="${PROFILE_DIR:-profiles}"
+TEST_DATA_DIR="${TEST_DATA_DIR:-testdata}"
+
+# Create directories
+mkdir -p "$PROFILE_DIR"
+mkdir -p "$TEST_DATA_DIR"
+
+echo -e "${GREEN}DTail Quick Profiling${NC}"
+echo "====================="
+echo
+
+# Generate test data if needed
+if [ ! -f "$TEST_DATA_DIR/quick_test.log" ]; then
+ echo -e "${YELLOW}Generating test data...${NC}"
+ echo " Command: go run generate_profile_data.go -size \"10MB\" -output \"$TEST_DATA_DIR/quick_test.log\" -format log"
+ go run generate_profile_data.go -size "10MB" -output "$TEST_DATA_DIR/quick_test.log" -format log
+ echo " Command: go run generate_profile_data.go -size \"10MB\" -output \"$TEST_DATA_DIR/quick_test.csv\" -format csv"
+ go run generate_profile_data.go -size "10MB" -output "$TEST_DATA_DIR/quick_test.csv" -format csv
+fi
+
+# Build commands
+echo -e "${GREEN}Building commands...${NC}"
+echo " Command: cd .. && make dcat dgrep dmap"
+cd ..
+make dcat dgrep dmap 2>/dev/null || true
+cd "$SCRIPT_DIR"
+
+echo
+echo -e "${GREEN}Running quick profiles...${NC}"
+
+# Profile dcat
+echo -e "\n${YELLOW}Profiling dcat...${NC}"
+echo "Command: ../dcat -profile -profiledir $PROFILE_DIR -plain -cfg none $TEST_DATA_DIR/quick_test.log"
+../dcat -profile -profiledir "$PROFILE_DIR" -plain -cfg none "$TEST_DATA_DIR/quick_test.log" > /dev/null 2>&1
+DCAT_CPU=$(ls -t "$PROFILE_DIR"/dcat_cpu_*.prof 2>/dev/null | head -1)
+if [ -n "$DCAT_CPU" ]; then
+ echo " Generated: $(basename "$DCAT_CPU")"
+ echo " Analysis: ../profiling/profile.sh -top 3 $DCAT_CPU"
+ ../profiling/profile.sh -top 3 "$DCAT_CPU" | grep -A 5 "Top 3 functions"
+fi
+
+# Profile dgrep
+echo -e "\n${YELLOW}Profiling dgrep...${NC}"
+echo "Command: ../dgrep -profile -profiledir $PROFILE_DIR -plain -cfg none -regex \"user[0-9]+\" $TEST_DATA_DIR/quick_test.log"
+../dgrep -profile -profiledir "$PROFILE_DIR" -plain -cfg none -regex "user[0-9]+" "$TEST_DATA_DIR/quick_test.log" > /dev/null 2>&1
+DGREP_CPU=$(ls -t "$PROFILE_DIR"/dgrep_cpu_*.prof 2>/dev/null | head -1)
+if [ -n "$DGREP_CPU" ]; then
+ echo " Generated: $(basename "$DGREP_CPU")"
+ echo " Analysis: ../profiling/profile.sh -top 3 $DGREP_CPU"
+ ../profiling/profile.sh -top 3 "$DGREP_CPU" | grep -A 5 "Top 3 functions"
+fi
+
+# Profile dmap
+echo -e "\n${YELLOW}Profiling dmap...${NC}"
+echo "Command: ../dmap -profile -profiledir $PROFILE_DIR -plain -cfg none -query \"select count(*) from $TEST_DATA_DIR/quick_test.csv\""
+../dmap -profile -profiledir "$PROFILE_DIR" -plain -cfg none -query "select count(*) from $TEST_DATA_DIR/quick_test.csv" > /dev/null 2>&1
+DMAP_CPU=$(ls -t "$PROFILE_DIR"/dmap_cpu_*.prof 2>/dev/null | head -1)
+if [ -n "$DMAP_CPU" ]; then
+ echo " Generated: $(basename "$DMAP_CPU")"
+ echo " Analysis: ../profiling/profile.sh -top 3 $DMAP_CPU"
+ ../profiling/profile.sh -top 3 "$DMAP_CPU" | grep -A 5 "Top 3 functions"
+fi
+
+echo
+echo -e "${GREEN}Quick profiling complete!${NC}"
+echo
+echo "To analyze in detail:"
+echo " go tool pprof $PROFILE_DIR/<profile_file>"
+echo " make profile-flamegraph PROFILE=$PROFILE_DIR/<profile_file>"
+echo \ No newline at end of file