1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-10-29 15:02:30 +00:00
Commit Graph

2 Commits

Author SHA1 Message Date
Alberto Bertogli 5e827fe36f trace: Truncate long messages
Currently we trace everything we are given; sometimes in rare but valid
cases that can be multi-MiB strings. That gets logged and stays in
memory for tracing, which can blow up quite a lot and be a source of
problems and unexpected excessive resource usage.

To mitigate this and reduce the chances of issues, this patch truncates
very long messages to 8k utf8 characters. That's long enough to be
useful for debugging, without running the risk of causing problems on
extremely long messages.

We may adjust this issue in the future if this limit becomes a problem.
2026-10-12 19:29:40 +01:00
Alberto Bertogli 7a30982bf0 trace: Format messages only once, and only log them if needed
Today, trace.Printf and trace.Debugf format the message more than once:
at least once for logging, and once for tracing.

Some of that formatting can be expensive for large messages, causing CPU
and RAM spikes due to transient allocations. So this patch makes those
trace functions only format once, and avoid the logging calls if they're
below the logging level.
2026-10-12 16:13:40 +01:00