|
4 | 4 |
|
5 | 5 | import type postgres from 'postgres'; |
6 | 6 | import type { BenchmarkParams } from './benchmark-mapper'; |
7 | | -import { kvCachePoolTokensFromServerLog } from './server-log-metrics'; |
8 | 7 |
|
9 | 8 | type Sql = ReturnType<typeof postgres>; |
10 | 9 |
|
@@ -74,12 +73,16 @@ export async function bulkIngestBenchmarkRows( |
74 | 73 | unnest(${sql.array(workersJsons)}::jsonb[]) |
75 | 74 | on conflict (workflow_run_id, config_id, benchmark_type, isl, osl, conc, offload_mode) |
76 | 75 | do update set |
77 | | - -- Replace metrics with the fresh artifact values, but carry over |
78 | | - -- kv_cache_pool_tokens: it is derived from the server log at |
79 | | - -- insertServerLog time (not present in any artifact JSON), so a later |
80 | | - -- upsert from the aggregated results_bmk artifact would silently wipe it. |
| 76 | + -- Producer artifacts now carry kv_cache_pool_tokens. Preserve an existing |
| 77 | + -- backfill only when replaying a legacy artifact that predates the field. |
81 | 78 | metrics = excluded.metrics || jsonb_strip_nulls( |
82 | | - jsonb_build_object('kv_cache_pool_tokens', benchmark_results.metrics->'kv_cache_pool_tokens') |
| 79 | + jsonb_build_object( |
| 80 | + 'kv_cache_pool_tokens', |
| 81 | + coalesce( |
| 82 | + excluded.metrics->'kv_cache_pool_tokens', |
| 83 | + benchmark_results.metrics->'kv_cache_pool_tokens' |
| 84 | + ) |
| 85 | + ) |
83 | 86 | ), |
84 | 87 | image = excluded.image, |
85 | 88 | workers = excluded.workers |
@@ -113,18 +116,9 @@ export async function insertServerLog( |
113 | 116 | insert into server_logs (server_log) values (${serverLog}) |
114 | 117 | returning id |
115 | 118 | `; |
116 | | - // Derive the KV-cache pool size (tokens) from the log's authoritative |
117 | | - // "GPU KV cache size: N tokens" line(s) and stash it on the result's metrics |
118 | | - // JSON, mirroring how trace-replay-ingest derives cache-hit rates. The |
119 | | - // scraped vllm:cache_config_info metric can't reconstruct this for MLA models. |
120 | | - const kvCachePoolTokens = kvCachePoolTokensFromServerLog(serverLog); |
121 | 119 | await sql` |
122 | 120 | update benchmark_results |
123 | | - set server_log_id = ${logId}${ |
124 | | - kvCachePoolTokens === null |
125 | | - ? sql`` |
126 | | - : sql`, metrics = jsonb_set(metrics, '{kv_cache_pool_tokens}', to_jsonb(${kvCachePoolTokens}::bigint))` |
127 | | - } |
| 121 | + set server_log_id = ${logId} |
128 | 122 | where id = any(${sql.array(unlinked.map((r) => r.id))}::bigint[]) |
129 | 123 | `; |
130 | 124 | } |
|
0 commit comments