Skip to content

#6014 Reduce shutdown delays on thread cleanup#6024

Open
akleshchev wants to merge 2 commits into
developfrom
andreyk/viewer_6014
Open

#6014 Reduce shutdown delays on thread cleanup#6024
akleshchev wants to merge 2 commits into
developfrom
andreyk/viewer_6014

Conversation

@akleshchev

@akleshchev akleshchev commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Viewer runs a lot of different threads and each one was waiting 100ms on shutdown. Watchdog was waiting for internal sleep to finish.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces viewer shutdown delays by allowing long-sleeping/background threads to exit more promptly during cleanup, notably by signaling the watchdog earlier and adding a bounded wait for queued-thread shutdown.

Changes:

  • Add LLWatchdog::shutdown() and call it earlier during LLAppViewer::cleanup() to reduce watchdog-related shutdown waiting.
  • Add a timed LLQueuedThread::waitOnPending(F32 max_time_sec) overload and use it for sTextureFetch shutdown.
  • Reduce LLThread::shutdown() polling sleep interval from 100ms to 10ms (6s total wait before forced termination).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
indra/newview/llappviewer.cpp Signals watchdog shutdown earlier; bounds texture fetch pending-wait during shutdown.
indra/llcommon/llwatchdog.h Declares new LLWatchdog::shutdown() API.
indra/llcommon/llwatchdog.cpp Implements watchdog shutdown and adjusts timer-thread stop behavior.
indra/llcommon/llthread.cpp Decreases shutdown polling sleep interval to reduce teardown delays.
indra/llcommon/llqueuedthread.h Adds timed waitOnPending() overload declaration.
indra/llcommon/llqueuedthread.cpp Implements timed waitOnPending() to prevent unbounded shutdown waits.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread indra/llcommon/llwatchdog.cpp
Comment on lines +229 to +237
void LLWatchdog::shutdown()
{
if (mTimer)
{
mTimer->stop();
// update mLastClockCount to not trip run()
mLastClockCount = LLTimer::getTotalTime();
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be I will just remove the string, but either way, no point locking it. Either thread is already in and will rewrite to a comparable value; thread is about to run and has plenty of time so won't hurt the shutdown; or value gets set and next run will be fast.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants