-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marky update loop event handling #1860
base: openxr-experimental
Are you sure you want to change the base?
Marky update loop event handling #1860
Conversation
Update the logic to skip the unknown event type (which is not valid) and also use the MAX enum value so it never gets actually hit.
Update the "received_events_" variable to the name of "previously_received_unhandled_events_" to be clearer.
Update how many events are stripped from the list of previously received events from 100 to 300 so that we don't keep hitting it as often.
Add the initial framework for tracking events and behaving differently for different events.
If we fail to encounter an event during a loop, reduce the future time we wait for it. But, only if we allow the reduction of that.
Assert on a missed event if we're supposed to, but not if we're ok with missing the event.
Add some clearer comments and log messages.
CI gfxreconstruct build queued with queue ID 292992. |
CI gfxreconstruct build # 5266 running. |
CI gfxreconstruct build queued with queue ID 293015. |
We don't want to increase the sleep time. That would mean we wait longer than we want for previously missed events. Only reduce the retry limit so we don't get the longer sleep times.
b370cc6
to
0e7d890
Compare
CI gfxreconstruct build queued with queue ID 293060. |
Accidentally included a submodule update in last run. Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much nicer, a couple nits, a functional question, and a storage question or two.
@@ -826,15 +848,15 @@ void OpenXrReplayConsumerBase::Process_xrPollEvent(const ApiCallInfo& | |||
XrEventDataBuffer* capture_event = eventData->GetPointer(); | |||
|
|||
// We received events that haven't been handled yet already, so see if this one is in the list already | |||
for (size_t ii = 0; ii < received_events_.size(); ++ii) | |||
for (size_t ii = 0; ii < previously_received_unhandled_events_.size(); ++ii) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that size
and []
are O(1) for std::deque. The erase will be O(n) since you are potentially shuffling within the blocks that.
Linked list std::list would be O(1) per-item inserted/deleted for insert/delete as is size (since '11), but you'd need to use iterators in the for loop.
{ | ||
GFXRECON_LOG_WARNING("Previously received event %s (0x%x, %u)", | ||
GFXRECON_LOG_WARNING("Previously received unhandled event %s (0x%x, %u)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INFO "Using previously received event of type ..." ?
// If we have not previously started tracking the event behavior for this event type, start tracking it. | ||
if (event_behavior_tracking_.find(capture_event->type) == event_behavior_tracking_.end()) | ||
{ | ||
event_behavior_tracking_[capture_event->type] = EventBehaviorTracking(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::unordered_map::operator[]
automatically inserts a default initialized entry, when key is not found. So this block is unneeded.
What would be useful instead is a reference EventBehaviorTracking &behavior_tracking = event_behavior_tracking_[capture_event->type]
given that '[]' is best O(1) is worst case O(n). and that same dereference is done many times below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that about the initialize. Thanks.
uint32_t current_reduction = event_behavior_tracking_[capture_event->type].current_timeout_reduction; | ||
if (current_reduction >= retry_limit) | ||
{ | ||
retry_limit = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be one, or we won't even look for the event once. We're not going to drop anything, as we save anything other
that we get in previously_received_unhandled_events_
(unless we think there's going to be a storm of missing events)
received_events_.push_back(*out_eventData); | ||
// If this was a valid event, but not the one we're interested in, record | ||
// it to a list of received events for us to use later. | ||
previously_received_unhandled_events_.push_back(*out_eventData); | ||
GFXRECON_LOG_WARNING("Recording event for later %s (0x%x, %u)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INFO
// events to make room for more without bloating the list size. | ||
// TODO: Perhaps do this more elegantly? | ||
if (received_events_.size() > 1000) | ||
if (previously_received_unhandled_events_.size() > 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1000 and 300 should be const statics of the ReplayConsumer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe like 5000, and 500?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched to constants. And I set them to 2000 and 500. I don't like it to get too big because they are large structures.
@@ -484,7 +484,7 @@ class OpenXrReplayConsumerBase : public OpenXrConsumer | |||
|
|||
VulkanReplayConsumerBase* vulkan_replay_consumer_ = nullptr; | |||
|
|||
std::vector<XrEventDataBuffer> received_events_; | |||
std::deque<XrEventDataBuffer> previously_received_unhandled_events_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XrEvenDataBuffer
are large, and maybe shuffled. Do we want to store a unique_ptr to them instead (or use std::list to ensure no shuffling occurs)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a list now based on your suggestion.
CI gfxreconstruct build # 5270 running. |
CI gfxreconstruct build # 5270 passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more little nit.
{ | ||
// Do we allow the event to waited on less and less each time we fail to | ||
// properly receive the event? | ||
bool allow_timeout_reduction{ true }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for better packing int, bool, bool
Decoded_XrSessionCreateInfo* decoded_info = createInfo->GetMetaStructPointer(); | ||
SessionData& session_data = AddSessionData(*session->GetPointer()); | ||
Decoded_XrSessionCreateInfo* decoded_info = createInfo->GetMetaStructPointer(); | ||
SessionData& session_data = AddSessionData(*session->GetPointer()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional white space change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I reverted this. My clang changed it. I'll revert again.
CI gfxreconstruct build queued with queue ID 295086. |
CI gfxreconstruct build # 5284 running. |
CI gfxreconstruct build # 5284 passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.