Commit Graph

44081 Commits (8b16ecb9cfb4917fe38e4e5b0e4f40a23dd4ffbf)

Author SHA1 Message Date
Nat Goodspeed 8b16ecb9cf SL-16220: Add tests for WorkQueue::waitForResult(), void & non-void. 2021-10-27 15:31:54 -04:00
Nat Goodspeed f06765cba8 SL-16220: Make WorkQueue::postTo() return exception to caller.
postTo() sets up two-way communication: the caller asks to run work on some
other WorkQueue, expecting an eventual callback on the originating WorkQueue.
That permits us to transport any exception thrown by the work callable back to
rethrow on the originating WorkQueue.
2021-10-26 12:29:49 -04:00
Nat Goodspeed e6eebea8da SL-16220: Change WorkQueue::runOn() to waitForResult().
In addition to the name making the blocking explicit, we changed the
signature: instead of specifying a target WorkQueue on which to run,
waitForResult() runs the passed callable on its own WorkQueue.

Why is that? Because, unlike postTo(), we do not require a handshake between
two different WorkQueues. postTo() allows running arbitrary callback code,
setting variables or whatever, on the originating WorkQueue (presumably on the
originating thread). waitForResult() synchronizes using Promise/Future, which
are explicitly designed for cross-thread communication. We need not call
set_value() on the originating thread, so we don't need a postTo() callback
lambda.
2021-10-26 11:49:53 -04:00
Nat Goodspeed 023d39963e SL-16220: WorkQueue::runOn() methods submit work, wait for result.
The idea is that you can call runOn(target, callable) from a (non-default)
coroutine and block that coroutine until the result becomes available.

As a safety check, we forbid calling runOn() from a thread's default
coroutine, assuming that a given thread's default coroutine is the one
servicing the relevant WorkQueue.
2021-10-25 17:31:27 -04:00
Nat Goodspeed e7b8c27741 SL-16220: Specialize WorkQueue for callable with void return.
Add a test exercising this feature.
2021-10-25 15:55:49 -04:00
Nat Goodspeed d2763897f2 SL-16220: Fix thread name expression. 2021-10-22 21:51:44 -04:00
Nat Goodspeed 14dae8bc8e SL-16220: Merge branch 'master' into sl-16220 2021-10-22 11:54:18 -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
Nat Goodspeed eda264c282 SL-16220: Add a WorkQueue to be serviced by mainloop.
Make LLAppViewer::idle() call LL::WorkQueue::runFor() to dequeue and run some
or all of the pending responses from worker threads.

Add a MainWorkTime setting to specify the time slice the main loop may devote
each frame to servicing such responses.
2021-10-20 18:38:36 -04:00
Nat Goodspeed cbaba2df56 Increment viewer version to 6.4.24
following promotion of DRTVWR-520
2021-10-13 16:52:44 -04:00
Nat Goodspeed dc972623a9 Merge branch 'SL-16024' into DRTVWR-546 2021-10-08 12:00:21 -04:00
Nat Goodspeed 54d874b123 SL-16024: Resolve bizarre VS compile error. Thanks Callum!
It seems CALLBACK is a macro in some Microsoft header file. Bleah.
2021-10-08 11:52:09 -04:00
Nat Goodspeed 23ac4bda3d SL-16024: Merge branch 'SL-16024' into SL-16024-to-546 2021-10-07 16:47:21 -04:00
Nat Goodspeed c585ddb75e SL-16024: Defend against two threads making "anonymous" WorkQueues.
Also make workqueue_test.cpp more robust.
2021-10-07 16:45:15 -04:00
Nat Goodspeed fb675e8185 SL-16024: Merge branch 'DRTVWR-546' into SL-16024-to-546 2021-10-07 16:07:37 -04:00
Nat Goodspeed 623ac79120 SL-16024: Add LL::WorkQueue for passing work items between threads.
A typical WorkQueue has a string name, which can be used to find it to post
work to it. "Work" is a nullary callable.

WorkQueue is a multi-producer, multi-consumer thread-safe queue: multiple
threads can service the WorkQueue, multiple threads can post work to it.

Work can be scheduled in the future by submitting with a timestamp. In
addition, a given work item can be scheduled to run on a recurring basis.

A requesting thread servicing a WorkQueue of its own, such as the viewer's
main thread, can submit work to another WorkQueue along with a callback to be
passed the result (of arbitrary type) of the first work item. The callback is
posted to the originating WorkQueue, permitting safe data exchange between
participating threads.

Methods are provided for different kinds of servicing threads. runUntilClose()
is useful for a simple worker thread. runFor(duration) devotes no more than a
specified time slice to that WorkQueue, e.g. for use by the main thread.
2021-10-07 15:32:51 -04:00
Nat Goodspeed 6e06d1db60 SL-16024: Make LLCond::get() lock and return by value.
Its previous behavior, returning a const reference without locking, was wrong:
it could return a reference to an object in an inconsistent state if it was
concurrently being modified on another thread.

Locking the mutex and returning a copy by value is the correct behavior.
2021-10-07 15:32:19 -04:00
Nat Goodspeed b554c9eaf4 SL-16024: Adapt llinstancetracker_test.cpp to getInstance() change. 2021-10-07 14:00:39 -04:00
Nat Goodspeed 2cb09dd4a8 SL-16024: Return shared_ptr from LLInstanceTracker::getInstance().
It feels wrong to return a dumb LLInstanceTracker subclass* from getInstance()
when we use std::shared_ptr and std::weak_ptr internally. But tweak consumers
to use 'auto' or LLInstanceTracker::ptr_t in case we later revisit this
decision.

We did add a couple get() calls where it's important to obtain a dumb pointer.
2021-10-07 11:53:45 -04:00
Nat Goodspeed 1ef78e2afa SL-16024: Work around VS bug regarding base-class enum. 2021-10-06 15:28:58 -04:00
Euclid Linden 027ca696bd Merged in euclid-16138 (pull request #720)
SL-16138 avoid redundant shader binds, and related cleanup

Approved-by: Dave Parks
Approved-by: Michael Pohoreski
2021-10-06 18:49:13 +00:00
Dave Houlton 3e99853b29 SL-16138 remove checks for now-mandatory capabilities 2021-10-06 10:59:00 -06:00
Dave Houlton 4c07eaa560 SL-16138 Add timing mark-up to shader fxns 2021-10-06 10:59:00 -06:00
Nat Goodspeed cf70766b45 SL-16024: Fix ThreadSafeSchedule::tryPopFor(), tryPopUntil().
ThreadSafeSchedule::tryPopUntil() (and therefore tryPopFor()) was simply
delegating to LLThreadSafeQueue::tryPopUntil(), with an adjusted timeout since
we want to wake up as soon as the head item, if any, becomes ready. But then
we have to loop back to retry the pop to actually deal with that head item.

In addition, ThreadSafeSchedule::popWithTime() was spinning rather than
properly blocking on a timed condition variable. Fixed.
2021-10-06 12:54:29 -04:00
Nat Goodspeed 955b967623 SL-16024: Add ThreadSafeSchedule, a timestamped LLThreadSafeQueue.
ThreadSafeSchedule orders its items by timestamp, which can be passed either
implicitly or explicitly. The timestamp specifies earliest delivery time: an
item cannot be popped until that time.

Add initial tests.

Tweak the LLThreadSafeQueue base class to support ThreadSafeSchedule:
introduce virtual canPop() method to report whether the current head item is
available to pop. The base class unconditionally says yes, ThreadSafeSchedule
says it depends on whether its timestamp is still in the future.

This replaces the protected pop_() overload accepting a predicate. Rather than
explicitly passing a predicate through a couple levels of function call, use
canPop() at the level it matters. Runtime behavior that varies depending on
an object's leaf class is what virtual functions were invented for.

Give pop_() a three-state enum return so pop() can distinguish between "closed
and empty" (throws exception) versus "closed, not yet drained because we're
not yet ready to pop the head item" (waits).

Also break out protected tryPopUntil_() method, the body logic of
tryPopUntil(). The public method locks the data structure, the protected
method requires that its caller has already done so.

Add chrono.h with a more full-featured LL::time_point_cast() function than the
one found in <chrono>, which only converts between time_point durations, not
between time_points based on different clocks.
2021-10-05 17:31:53 -04:00
Dave Houlton f0e31b6c82 SL-16138 Avoid re-binding a shader which is already bound 2021-10-05 13:29:46 -06:00
Dave Houlton 4778f9497e DRTVWR-546 trigger 2021-10-05 10:05:22 -06:00
Nat Goodspeed a35e266547 SL-16024: Don't use a lambda as default arg for universal reference.
Instead, break out a separate pop_() method that explicitly provides the
lambda to the real pop_() implementation.
2021-10-04 17:21:39 -04:00
Nat Goodspeed ca60fbe72c SL-16024: LLThreadSafeQueue enhancements
Add LL::PriorityQueueAdapter, a wrapper for std::priority_queue to make its
API more closely resemble std::queue for drop-in use as LLThreadSafeQueue's
underlying QueueT container.

Support move-only element types.

Factor out some implementation redundancy: wrap actual push semantics as
push_(), actual pop semantics as pop_(). push(), tryPush() and tryPushUntil()
now call push_(); pop(), tryPop() and tryPopUntil() now call pop_().

Break out tryLock() and tryLockUntil() methods that, if they can lock, run the
passed callable. Then tryPush(), tryPushUntil(), tryPop() and tryPopUntil()
pass lambdas containing the meat of the original method body to tryLock() or
tryLockUntil(), as appropriate.
2021-10-04 16:19:59 -04:00
Euclid Linden 66e597f119 Merged in DRTVWR-541 (pull request #717)
Push autobuild updates made in DRTVWR-541 into -546
2021-10-04 16:55:51 +00:00
Nat Linden 05e01d58b6 Merged in SL-16040 (pull request #709), Nat's changes to allow autobuild with Tracy enabled on TeamCity.
SL-16040: TC viewer builds with Tracy enabled

Approved-by: Euclid Linden
Approved-by: Dave Parks
2021-10-04 16:05:37 +00:00
Nat Goodspeed 1b1ebdf183 SL-16024: Introduce tuple.h with tuple_cons(), tuple_cdr().
These functions allow prepending or removing an item at the left end of an
arbitrary tuple -- for instance, to add a sequence key to a caller's data,
then remove it again when delivering the original tuple.
2021-10-04 11:48:58 -04:00
Nat Goodspeed 7c9aeed97d SL-16024: Enhance LLThreadSafeQueue for use with WorkQueue.
First, parameterize LLThreadSafeQueue's queue type. This allows us to
substitute (e.g.) a std::priority_queue for a particular instance.

Use std::queue for the default queue type, changing the operations invoked on
the queue type from std::deque methods to std::queue methods.

Rename published methods from (e.g.) pushFront() and popBack() to simple
push() and pop(), retaining legacy names as aliases. Not only are the overt
Front and Back unnecessary; they're the opposite of how std::queue uses
std::deque or std::list, so they only confuse the reader.

Break out tryPushUntil() method. We already use that logic internally to
tryPushFor(), so it's just as easy to publish it as its own entry point.

Add tryPopFor() and tryPopUntil() to allow limiting the time we'll wait for a
queue item to become available.
2021-10-01 16:05:23 -04:00
Dave Parks 2148e4c731 SL-16094 Move LLWindowWin32::mainWindowProc and Windows message handling to a background thread to prevent frame stalls in LLWindowWin32::gatherInput 2021-10-01 15:51:12 +00:00
Nat Goodspeed db86ec9176 SL-16040: _aligned_malloc() and _aligned_free() are Microsoft only.
Fortunately we already have platform-independent wrappers in llmemory.h.
2021-09-28 22:09:02 -04:00
Nat Goodspeed 548bfda290 SL-16040: operator new() must never return nullptr. 2021-09-28 16:53:04 -04:00
Nat Goodspeed 3e12a97a7f SL-16040: Honor autobuild_{configure,build}_parameters variables.
The generic build.sh script honors these environment variables to specify
parameters to the autobuild configure and autobuild build steps, respectively.
Support them in the viewer-specific build.sh too.

In the generic build.sh, autobuild_configure_parameters allows specifying
command-line switches either for autobuild or, following --, for the
underlying tool (in our case, CMake). In order to support that variable the
same way here, we insert -- (as before) when autobuild_configure_parameters is
unset or empty, since the rest of the switches *we* specify are for CMake.

That means that, as with the generic build.sh, a non-empty
autobuild_configure_parameters override must precede any switches intended for
CMake with the -- separator.
2021-09-28 16:40:33 -04:00
Dave Parks 675514bdb3 SL-16093 Don't force the console window to be open on developer builds because it causes frame stalls while logging. 2021-09-27 23:56:06 +00:00
Dave Parks 78007d2592 SL-16088 Fix for stall from many calls to glGenBuffers. 2021-09-27 22:35:50 +00:00
Runitai Linden d7dea2dd7a Ignore build-vc160-64 2021-09-24 15:21:35 -05:00
Andrey Lihatskiy 717fe2cc5c DRTVWR-520 Updated dullahan to codeticket build 563968 2021-09-23 10:57:37 +03:00
Runitai Linden 60980a4733 Merge remote-tracking branch 'remotes/origin/DRTVWR-541' into DRTVWR-546 2021-09-22 18:06:58 -05:00
Andrey Lihatskiy 9bcd860f53 SL-15903 SLPlugin entitlements fix 2021-09-23 01:50:05 +03:00
Michael Pohoreski 68be3018ab Merged in SL-16014 (pull request #692)
SL-16014

Approved-by: Euclid Linden
Approved-by: Dave Parks
2021-09-22 22:26:15 +00:00
Ptolemy aa1d3ff8fd Fix merge conflict 2021-09-22 15:14:04 -07:00
Ptolemy 43bca9e85d SL-16014: Fix typo 2021-09-22 14:58:36 -07:00
Runitai Linden 9cff7ebc0c Merge remote-tracking branch 'remotes/origin/DRTVWR-541' into DRTVWR-546
# Conflicts:
#	indra/llcommon/linden_common.h
2021-09-22 16:50:20 -05:00
Ptolemy 5fa9b51029 SL-16014: Add Tracy markup to doFrame() 2021-09-22 14:38:44 -07:00
Ptolemy 2b19015f43 SL-16014: Add Tracy markup for LLEventFilter 2021-09-22 14:38:44 -07:00
Ptolemy 8e4907beee SL-16014: Add Tracy markup for LLVolumeFace 2021-09-22 14:38:43 -07:00