Bartosz Taudul 75320a3353 Fix race condition when regenerating LLM reply.
The chat regenerate/trash button handling had a monolithic lock that
blocked the worker thread during token counting. The token counting
is performed by calling TracyLlmApi::Tokenize(), which issues a
blocking HTTP POST request to the LLM API - on the UI thread.

To avoid blocking both the worker and freezing the UI during HTTP
calls, the lock was split into m_jobsLock and m_chatLock. However,
this introduced a race condition.

For the assistant role (regenerate message action), the code:
1. Stops the current job and queues a new one (under m_jobsLock)
2. Releases the lock
3. Performs token counting via HTTP calls (no lock held)
4. Re-acquires m_jobsLock and stops m_currentJob again

Between steps 2 and 4, the worker thread can complete the old job
and pick up the newly queued job. The stop at step 4 then incorrectly
stops the new regenerate job instead of the old one.

Under the original monolithic lock, the worker couldn't access
m_currentJob until after step 4, so the stop always applied to the
correct job. After the split, the second stop became harmful for
the assistant case.

The fix makes the second stop conditional on user role only (thrash
action), since that's the case where no new job is queued and we
genuinely need to stop any running generation before the user edits
their message.
2026-02-17 00:04:53 +01:00
2026-01-13 11:25:44 +01:00
2026-01-26 20:48:15 +01:00
2024-05-25 00:16:29 +02:00
2024-05-12 19:23:18 +02:00
2026-01-24 01:50:11 +01:00
2023-10-09 22:38:04 +02:00
2022-04-16 00:13:10 +02:00
2026-01-24 01:50:11 +01:00
2026-01-14 01:51:32 +01:00
2025-12-11 23:46:02 +01:00
2025-07-27 21:18:57 +02:00
2025-07-12 11:50:11 +02:00
2024-09-27 16:56:55 +02:00
2026-01-01 02:12:05 +01:00
2026-01-30 21:49:17 +01:00

Tracy Profiler

Sponsor

A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications.

Tracy supports profiling CPU (Direct support is provided for C, C++, Lua, Python and Fortran integration. At the same time, third-party bindings to many other languages exist on the internet, such as Rust, Zig, C#, OCaml, Odin, etc.), GPU (All major graphic APIs: OpenGL, Vulkan, Direct3D 11/12, Metal, OpenCL, CUDA.), memory allocations, locks, context switches, automatically attribute screenshots to captured frames, and much more.

An Introduction to Tracy Profiler in C++ - Marcos Slomp - CppCon 2023

Introduction to Tracy Profiler v0.2
New features in Tracy Profiler v0.3
New features in Tracy Profiler v0.4
New features in Tracy Profiler v0.5
New features in Tracy Profiler v0.6
New features in Tracy Profiler v0.7
New features in Tracy Profiler v0.8

Description
No description provided
Readme BSD-3-Clause 89 MiB
Languages
C++ 89.8%
C 5.4%
TeX 2.4%
Python 1.1%
CMake 0.7%
Other 0.3%