更新
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
// Read-only concurrency probe: samples how many model tasks hold a live lease at the same time.
|
||||
// Prints task metadata only; no clinical content.
|
||||
$serverRoot = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR;
|
||||
chdir($serverRoot);
|
||||
require $serverRoot . 'vendor/autoload.php';
|
||||
$app = new \think\App($serverRoot);
|
||||
$app->initialize();
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
$seconds = (int) ($argv[1] ?? 120);
|
||||
$deadline = time() + $seconds;
|
||||
$peak = ['total' => 0, 'qwen' => 0, 'openai' => 0];
|
||||
$samples = [];
|
||||
while (time() <= $deadline) {
|
||||
$now = time();
|
||||
$rows = Db::name('prescription_ai_task')->where('status', 'running')->where('lock_until', '>', $now)
|
||||
->field('id,batch_id,model_key')->select()->toArray();
|
||||
$byModel = array_count_values(array_column($rows, 'model_key'));
|
||||
$peak['total'] = max($peak['total'], count($rows));
|
||||
foreach (['qwen', 'openai'] as $model) {
|
||||
$peak[$model] = max($peak[$model], (int) ($byModel[$model] ?? 0));
|
||||
}
|
||||
$samples[] = ['at' => date('H:i:s', $now), 'running' => count($rows),
|
||||
'qwen' => (int) ($byModel['qwen'] ?? 0), 'openai' => (int) ($byModel['openai'] ?? 0),
|
||||
'batches' => array_values(array_unique(array_map('intval', array_column($rows, 'batch_id')))),
|
||||
'queued' => Db::name('prescription_ai_task')->whereIn('status', ['queued', 'retry_wait'])->count()];
|
||||
if (count($samples) > 1 && $samples[count($samples) - 1] === $samples[count($samples) - 2]) {
|
||||
array_pop($samples);
|
||||
}
|
||||
if ($peak['total'] > 0 && count($rows) === 0 && (int) end($samples)['queued'] === 0) {
|
||||
break;
|
||||
}
|
||||
sleep(5);
|
||||
}
|
||||
echo json_encode(['peak' => $peak, 'samples' => array_slice($samples, -40)],
|
||||
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), "\n";
|
||||
Reference in New Issue
Block a user