perf(chat): use reentrant local time for chat timestamps

The open chat thread called std::localtime at least twice per message
per frame (two day keys for grouping), and more for day separators and
time labels. On glibc every call re-checks the timezone with a stat of
/etc/localtime. The chat time helpers now use util::localTime() from
the new util/local_time.h: localtime_r (localtime_s on Windows), with
no per-call timezone check and no shared static result buffer.

glibc's localtime_r reads the timezone only once, so local_time.h also
adds util::refreshTimezone() (tzset) for caches to call when they
rebuild. Nothing calls it yet; its first caller is the chat thread's
grouping-flags cache in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 09:50:03 -05:00
co-authored by Claude Opus 5.5
parent e45f4c7d90
commit a69380817e
4 changed files with 62 additions and 21 deletions
+1
View File
@@ -713,6 +713,7 @@ set(APP_HEADERS
src/util/serial_job_lane.h
src/util/fetch_backoff.h
src/util/coalescing_writer.h
src/util/local_time.h
src/util/background_sampler.h
src/util/amount_format.h
src/util/base64.h