Commit Graph

16 Commits (c785a0e955478dcad867af55bcd44111a718aefd)

Author SHA1 Message Date
Andrey Kleshchev 18ec799992 SL-18721 Shutdown fixes #5 2024-02-27 23:14:44 +02:00
Andrey Kleshchev 4a34a11966 SL-18721 Shutdown fixes
1. After window closes viewer still takes some time to shut down, so
added splash screen to not confuse users (and to see if something gets
stuck)
2. Having two identical mWindowHandle caused confusion for me, so I
split them. It looks like there might have been issues with thread being
stuck because thread's handle wasn't cleaned up.
3. Made region clean mCacheMap immediately instead of spending time
making copies on shutdown
2024-01-22 18:47:43 +02:00
Nat Goodspeed f41278082f SL-18809: Merge 'DRTVWR-559' of secondlife/viewer into sl-18809 2022-12-09 16:34:28 -05:00
Nat Goodspeed fc424a0db9 SL-18809: Add WorkSchedule; remove timestamps from WorkQueue.
For work queues that don't need timestamped tasks, eliminate the overhead of a
priority queue ordered by timestamp. Timestamped task support moves to
WorkSchedule. WorkQueue is a simpler queue that just waits for work.

Both WorkQueue and WorkSchedule can be accessed via new WorkQueueBase API. Of
course the WorkQueueBase API doesn't deal with timestamps, but a WorkSchedule
can be accessed directly to post timestamped tasks and then handled normally
(e.g. by ThreadPool) to run them.

Most ThreadPool functionality migrates to new ThreadPoolBase class, with
template subclass ThreadPoolUsing<WorkQueue> or ThreadPoolUsing<WorkSchedule>
depending on need. ThreadPool is now an alias for ThreadPoolUsing<WorkQueue>.
Importantly, ThreadPoolUsing::getQueue() delivers a reference to the specific
queue subclass type, so you can post timestamped tasks on a queue retrieved
from ThreadPoolUsing<WorkSchedule>::getQueue().

Since ThreadPool is no longer a simple class but an alias for a particular
template specialization, introduce threadpool_fwd.h to forward-declare it.

Recast workqueue_test.cpp to exercise WorkSchedule, since some of the tests
are time-based. A future todo would be to exercise each applicable test with
both WorkQueue and WorkSchedule.
2022-12-09 13:21:45 -05:00
Brad Kittenbrink e3b34fec69 Fix for non-windows build of DRTVWR-559 use usleep() for sleepy_robin scheduler 2022-12-08 12:53:51 -08:00
RunitaiLinden e98091e298
DRTVWR-559: Try using custom fiber scheduler for ThreadPool threads. (#30)
Co-authored-by: Nat Goodspeed <nat@lindenlab.com>
2022-12-07 12:53:59 -06:00
Nat Goodspeed 64209ddeea SL-17483: Add integration test for CommonControl
and for LLViewerControlListener, to which it talks.

Fix glitches detected by the tests.
2022-06-09 17:04:26 -04:00
Nat Goodspeed 1ff79a430d SL-17483: Fix ThreadPool::getConfiguredWidth() compile error.
Log ThreadPoolSizes at DEBUG level, not INFO.
2022-06-09 11:19:21 -04:00
Nat Goodspeed ac99e979f4 SL-17483: Make it possible to override width of any ThreadPool.
Introduce CommonControl, which in a running viewer (or any program containing
an LLViewerControlListener instance) gives access to LLViewerControl
functionality, e.g. getting, setting or enumerating control variables --
without introducing a link dependency on newview.

Make ThreadPool's constructor consult CommonControl to check for an override
for the width of the new ThreadPool in the Global (i.e. gSavedSettings)
setting ThreadPoolSizes, and honor that if found.

Introduce static ThreadPool methods getConfiguredWidth(), to query for such an
override on any particular ThreadPool name; and getWidth(), to ask for the
width of an instance if that instance already exists, else the width with
which it *would* be instantiated.
2022-06-09 10:18:29 -04:00
Cosmic Linden ef87eb7fa8 SL-17483: Make ThreadPool inherit LLInstanceTracker
(cherry picked from commit 41d6a0e222241606c317281e2f0b211e16813dd5)
2022-06-09 09:54:39 -04:00
Nat Goodspeed 2b96f89c2a SL-16400: Add ThreadPool::start() method, and call it.
It's sometimes important to finish other initialization before launching the
threads in the ThreadPool, so make that an explicit step. In particular, we
were launching the LLImageGL texture thread before initializing the GL
context, resulting in all gray textures.
2021-11-23 20:39:32 -05:00
Runitai Linden 9b0d8c7e62 SL-16094 More profile hooks for threading code, remove redundant wglCreateContextAttribs call 2021-11-22 18:42:56 -06:00
Nat Goodspeed ff5496239b SL-16202: Use WorkQueue::postTo() for texture create/post handshake.
That is, when LLViewerFetchedTexture::scheduleCreateTexture() wants to call
createTexture() on the LLImageGLThread, but postCreateTexture() on the main
thread, use the "mainloop" WorkQueue to set up the handshake.

Give ThreadPool a public virtual run() method so a subclass can override with
desired behavior. This necessitates a virtual destructor. Add accessors for
embedded WorkQueue (for post calls), ThreadPool name and width (in threads).

Allow LLSimpleton::createInstance() to forward arguments to the subject
constructor.

Make LLImageGLThread an LLSimpleton - that abstraction didn't yet exist at the
time LLImageGLThread was coded. Also derive from ThreadPool rather than
LLThread. Make it a single-thread "pool" with a very large queue capacity.
2021-11-05 12:33:31 -04:00
Nat Goodspeed 834e7ca088 SL-16202: Use large WorkQueue size limits for mainloop and General.
Give ThreadPool and WorkQueue the ability to override default
ThreadSafeSchedule capacity.

Instantiate "mainloop" WorkQueue and "General" ThreadPool with very large
capacity because we never want to have to block trying to push to either.
2021-11-04 17:18:57 -04:00
Nat Goodspeed d2763897f2 SL-16220: Fix thread name expression. 2021-10-22 21:51:44 -04:00
Nat Goodspeed 11afa09ea3 SL-16220: Add LL::ThreadPool class and a "General" instance.
ThreadPool bundles a WorkQueue with the specified number of worker threads to
service it. Each ThreadPool has a name that can be used to locate its
WorkQueue.

Each worker thread calls WorkQueue::runUntilClose().

ThreadPool listens on the "LLApp" LLEventPump for shutdown notification. On
receiving that, it closes its WorkQueue and then join()s each of its worker
threads for orderly shutdown.

Add a settings.xml entry "ThreadPoolSizes", the first LLSD-valued settings
entry to expect a map: pool name->size. The expectation is that usually code
instantiating a particular ThreadPool will have a default size in mind, but it
should check "ThreadPoolSizes" for a user override.

Make idle_startup()'s STATE_SEED_CAP_GRANTED state instantiate a "General"
ThreadPool. This is function-static for lazy initialization.

Eliminate LLMainLoopRepeater, which is completely unreferenced. Any potential
future use cases are better addressed by posting to the main loop's WorkQueue.

Eliminate llappviewer.cpp's private LLDeferredTaskList class, which
implemented LLAppViewer::addOnIdleCallback(). Make addOnIdleCallback() post
work to the main loop's WorkQueue instead.
2021-10-22 11:36:31 -04:00