MCPcopy Create free account
hub / github.com/InferCore/InferCore / Snapshot

Method Snapshot

internal/slo/memory_engine.go:141–182  ·  view source on GitHub ↗
(requestID string)

Source from the content-addressed store, hash-verified

139}
140
141func (e *MemoryEngine) Snapshot(requestID string) types.SLOSnapshot {
142 e.mu.Lock()
143 defer e.mu.Unlock()
144
145 rec, ok := e.records[requestID]
146 if !ok {
147 return types.SLOSnapshot{}
148 }
149
150 var ttft int64
151 if !rec.startTime.IsZero() && !rec.firstTokenTime.IsZero() {
152 ttft = rec.firstTokenTime.Sub(rec.startTime).Milliseconds()
153 if ttft < 0 {
154 ttft = 0
155 }
156 }
157
158 var completion int64
159 var tpot int64
160 if !rec.startTime.IsZero() && !rec.endTime.IsZero() {
161 completion = rec.endTime.Sub(rec.startTime).Milliseconds()
162 if completion < 0 {
163 completion = 0
164 }
165 }
166 if !rec.firstTokenTime.IsZero() && !rec.endTime.IsZero() {
167 postFirstToken := rec.endTime.Sub(rec.firstTokenTime).Milliseconds()
168 if postFirstToken > 0 {
169 tpot = postFirstToken / 32
170 if tpot <= 0 {
171 tpot = 1
172 }
173 }
174 }
175
176 return types.SLOSnapshot{
177 TTFTMs: ttft,
178 TPOTMs: tpot,
179 CompletionLatencyMs: completion,
180 FallbackTriggered: rec.fallback,
181 }
182}
183
184func (e *MemoryEngine) ensureRecord(requestID string) *requestTiming {
185 rec, ok := e.records[requestID]

Calls

no outgoing calls