Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
84
tests/debug/test-web-request-cache.php
Normal file
84
tests/debug/test-web-request-cache.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Framework\Core\AppBootstrapper;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
use App\Framework\DateTime\SystemHighResolutionClock;
|
||||
use App\Framework\Performance\EnhancedPerformanceCollector;
|
||||
use App\Framework\Performance\MemoryMonitor;
|
||||
|
||||
echo "=== Testing Web Request Performance & Caching ===\n\n";
|
||||
|
||||
// Simulate multiple web requests to see caching behavior
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
echo "Request #{$i}:\n";
|
||||
$startTime = microtime(true);
|
||||
|
||||
try {
|
||||
$basePath = dirname(__DIR__, 2);
|
||||
|
||||
// Create fresh instances for each "request" (like web would do)
|
||||
$clock = new SystemClock();
|
||||
$highResClock = new SystemHighResolutionClock();
|
||||
$memoryMonitor = new MemoryMonitor();
|
||||
$performanceCollector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, false);
|
||||
|
||||
$bootstrapper = new AppBootstrapper($basePath, $performanceCollector, $memoryMonitor);
|
||||
$application = $bootstrapper->bootstrapWeb();
|
||||
|
||||
$endTime = microtime(true);
|
||||
$duration = ($endTime - $startTime) * 1000;
|
||||
|
||||
echo " ✅ Bootstrap completed in " . number_format($duration, 2) . "ms\n";
|
||||
|
||||
// Check if this was a cache hit or miss
|
||||
if ($duration < 100) {
|
||||
echo " 🚀 CACHE HIT - Fast bootstrap!\n";
|
||||
} elseif ($duration < 500) {
|
||||
echo " ⚡ PARTIAL CACHE - Some components cached\n";
|
||||
} else {
|
||||
echo " 🐌 CACHE MISS - Full bootstrap performed\n";
|
||||
}
|
||||
|
||||
// Force cleanup
|
||||
unset($bootstrapper, $application, $performanceCollector, $memoryMonitor);
|
||||
if (function_exists('gc_collect_cycles')) {
|
||||
gc_collect_cycles();
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo " ❌ Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
// Check cache state
|
||||
echo "Cache Analysis:\n";
|
||||
|
||||
try {
|
||||
// Try to access Redis directly to see what's cached
|
||||
$redis = new Redis();
|
||||
$redis->connect('redis', 6379);
|
||||
$redis->select(1); // Cache DB
|
||||
|
||||
$cacheKeys = $redis->keys('cache:discovery:*');
|
||||
echo " Discovery cache keys: " . count($cacheKeys) . "\n";
|
||||
|
||||
foreach ($cacheKeys as $key) {
|
||||
$ttl = $redis->ttl($key);
|
||||
$size = strlen($redis->get($key));
|
||||
echo " - $key (TTL: {$ttl}s, Size: " . number_format($size) . " bytes)\n";
|
||||
}
|
||||
|
||||
if (empty($cacheKeys)) {
|
||||
echo " ⚠️ NO DISCOVERY CACHE KEYS FOUND!\n";
|
||||
echo " This means discovery results are NOT being cached.\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo " ❌ Could not check Redis cache: " . $e->getMessage() . "\n";
|
||||
}
|
||||
Reference in New Issue
Block a user