fix(ludic.telemetry): nothing made per event - properties and the line written into kept buffers, the queue a ring of bytes made at the start
An event was a tree of values encoded into a new string, a dropped line was never given back, and every batch and save joined the queue into another. Now: telemetry_props / telemetry_str / _int / _bool write the properties as JSON into a buffer the state keeps; the line is written beside it, its time worked out from the clock's seconds (TelemetryWorld.clock_s, was stamp); its bytes go into one ring (ring_bytes, at most queue_max lines), the oldest overwritten past either; a batch and the file are written into a third kept buffer and go as bytes (TelemetryTransport.send takes the bytes and their length; Http.body_bytes, Fs.write_bytes). The facts are pooled. tests/ring_test: ten thousand events past the cap in lines and in bytes, 0 bytes of heap; the line exact JSON, escaped, 2000-02-29 right; the batch puts the id in; the file round-trips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fc0f3d3790
commit
d1bea7f10e
14 changed files with 454 additions and 97 deletions
|
|
@ -7,13 +7,14 @@ export function telemetry_fails(telemetry_st: TelemetryState) -> int { return te
|
|||
export function telemetry_next_ms(telemetry_st: TelemetryState) -> int { return telemetry_st.telemetry__next_ms }
|
||||
export function telemetry_in_flight(telemetry_st: TelemetryState) -> bool { return telemetry_st.telemetry__h >= 0 }
|
||||
|
||||
export function telemetry_queued(telemetry_st: TelemetryState) -> int {
|
||||
if telemetry_st.telemetry__q == null { return 0 }
|
||||
return len(telemetry_st.telemetry__q)
|
||||
}
|
||||
export function telemetry_queued(telemetry_st: TelemetryState) -> int { return telemetry_st.telemetry__n }
|
||||
|
||||
# a queued line as it will be sent, player mark and all
|
||||
export function telemetry_line(telemetry_st: TelemetryState, i: int) -> string { return telemetry_st.telemetry__q[i] }
|
||||
export function telemetry_line(telemetry_st: TelemetryState, i: int) -> string {
|
||||
let sb = sb_new(TELEMETRY_LINE)
|
||||
tr_line_to(telemetry_st, i, sb, null)
|
||||
return text_of(sb.b, sb_len(sb))
|
||||
}
|
||||
|
||||
# back to before telemetry_start, ports and config kept (tests; a start after a failed boot)
|
||||
export function telemetry_reset(telemetry_st: mut TelemetryState) -> void {
|
||||
|
|
@ -21,7 +22,7 @@ export function telemetry_reset(telemetry_st: mut TelemetryState) -> void {
|
|||
telemetry_st.telemetry__ready = false
|
||||
telemetry_st.telemetry__id = ""
|
||||
telemetry_st.telemetry__session = ""
|
||||
telemetry_st.telemetry__q = null
|
||||
if telemetry_st.telemetry__ring != null { tr_clear(telemetry_st) }
|
||||
telemetry_st.telemetry__dirty = false
|
||||
telemetry_st.telemetry__sent_n = 0
|
||||
telemetry_st.telemetry__next_ms = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue