diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-01 21:03:53 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-01 21:03:53 +0300 |
| commit | 4e4034a129e3400ffccb23975a6f3a0cd3011309 (patch) | |
| tree | 4f77f8b72c9fe93481c66053749a56aa78ee9651 /benchmarks/turbo_final_test.sh | |
| parent | de974de3d8f4ed38ff7fac6447fdcfec2c00cfc1 (diff) | |
perf: optimize turbo mode for 2.87x faster serverless performance
Major performance improvements in turbo mode:
- Fixed trace logging overhead by adding early level checks before expensive runtime.Caller() operations
- Improved buffering strategy by removing forced immediate flush in serverless mode
- Turbo mode now 2.87x faster (was 3-5x slower before optimization)
Changes:
- internal/io/dlog/dlog.go: Added early return in Trace() and Devel() when logging disabled
- internal/server/handlers/turbo_writer.go: Removed serverless immediate flush condition
Performance results:
- Before: Turbo mode was 3-5x slower than non-turbo mode
- After: Turbo mode is 2.87x faster (65% improvement)
- All integration tests pass
Added comprehensive benchmarking tools in benchmarks/ directory
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'benchmarks/turbo_final_test.sh')
| -rwxr-xr-x | benchmarks/turbo_final_test.sh | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/benchmarks/turbo_final_test.sh b/benchmarks/turbo_final_test.sh new file mode 100755 index 0000000..539a33e --- /dev/null +++ b/benchmarks/turbo_final_test.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# Final turbo mode performance test + +set -e + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +RED='\033[0;31m' +NC='\033[0m' + +echo -e "${BLUE}=== Final Turbo Mode Performance Test ===${NC}" +echo "" + +# Create test file +TEST_FILE="final_test_data.log" +echo -e "${YELLOW}Creating test file (1M lines)...${NC}" +rm -f "$TEST_FILE" +for i in {1..1000000}; do + echo "2025-01-01 10:00:00 INFO [app] Processing request ID=$i status=OK latency=42ms" >> "$TEST_FILE" +done +echo -e "${GREEN}✓ Test file created${NC}" +echo "" + +# Test 1: Non-turbo mode +echo -e "${YELLOW}Testing non-turbo mode...${NC}" +unset DTAIL_TURBOBOOST_ENABLE +start=$(date +%s.%N) +../dcat --plain "$TEST_FILE" > /dev/null 2>&1 +end=$(date +%s.%N) +non_turbo_time=$(echo "$end - $start" | bc) +echo -e "${GREEN}Non-turbo time: ${non_turbo_time}s${NC}" + +# Test 2: Turbo mode +echo -e "${YELLOW}Testing turbo mode...${NC}" +export DTAIL_TURBOBOOST_ENABLE=yes +start=$(date +%s.%N) +../dcat --plain "$TEST_FILE" > /dev/null 2>&1 +end=$(date +%s.%N) +turbo_time=$(echo "$end - $start" | bc) +echo -e "${GREEN}Turbo time: ${turbo_time}s${NC}" + +# Calculate improvement +improvement=$(echo "scale=2; (($non_turbo_time - $turbo_time) / $non_turbo_time) * 100" | bc) +speedup=$(echo "scale=2; $non_turbo_time / $turbo_time" | bc) + +echo "" +echo -e "${BLUE}=== Results ===${NC}" +echo "Non-turbo: ${non_turbo_time}s" +echo "Turbo: ${turbo_time}s" +if (( $(echo "$improvement > 0" | bc -l) )); then + echo -e "${GREEN}Turbo mode is ${speedup}x faster (${improvement}% improvement)${NC}" +else + echo -e "${RED}Turbo mode is slower by ${improvement}%${NC}" +fi + +# Test with colors too +echo "" +echo -e "${YELLOW}Testing with colors enabled...${NC}" + +# Non-turbo with colors +unset DTAIL_TURBOBOOST_ENABLE +start=$(date +%s.%N) +../dcat "$TEST_FILE" > /dev/null 2>&1 +end=$(date +%s.%N) +non_turbo_color_time=$(echo "$end - $start" | bc) + +# Turbo with colors +export DTAIL_TURBOBOOST_ENABLE=yes +start=$(date +%s.%N) +../dcat "$TEST_FILE" > /dev/null 2>&1 +end=$(date +%s.%N) +turbo_color_time=$(echo "$end - $start" | bc) + +echo "Non-turbo (colors): ${non_turbo_color_time}s" +echo "Turbo (colors): ${turbo_color_time}s" + +# Cleanup +rm -f "$TEST_FILE" + +echo "" +echo -e "${BLUE}Test complete!${NC}"
\ No newline at end of file |
