Skip to content
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

ChatThrottleLib: Allow direct sending while in a blocked state #18

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Meorawr
Copy link
Contributor

@Meorawr Meorawr commented May 8, 2024

With the changes to support the concept of a blocked queue, there's a slight latency defect possible when CTL is in a state where its priorities consist solely of blocked queues.

The direct submission checks in the Send functions eagerly return false in the case where the 'bQueueing' boolean is set, and force their data to be queued up for submission ~potentially up to 0.08s later.

The problem is that this boolean is only ever cleared in the case where CTL has no data whatsoever left in any queue, including blocked ones. This means that if CTL only has blocked queues the boolean remains set, we force messages that could be perfectly sendable right away on other unblocked prefixes to be queued up unnecessarily.

This attempts to resolve the issue as follows;

  • Firstly, we now clear the 'bQueueing' flag in the OnUpdate function if we enter a state where there's no data that can be immediately sent. This means that the flag is unset if we only consist of blocked queues.
  • The OnUpdate function restores the 'bQueueing' flag when transitioning back from a fully-blocked state to a sendable state.
  • The direct send checks have been split out to a new function and in addition to checking the state of 'bQueueing', now also check if a named queue exists within a certain priority bracket. If it does, then we do not directly send the message.

The new check is required to deal with cases where a caller attempts to send a message on a blocked queue while 'bQueueing' is false - as we don't want to directly send a message ahead of everything else in the queue that it's supposed to belong to.

With the changes to support the concept of a blocked queue, there's a
slight latency defect possible when CTL is in a state where its
priorities consist solely of blocked queues.

The direct submission checks in the Send functions eagerly return false
in the case where the 'bQueueing' boolean is set, and force their data
to be queued up for submission ~potentially up to 0.08s later.

The problem is that this boolean is only ever cleared in the case where
CTL has no data whatsoever left in any queue. This means that if CTL has
only blocked (and as such, totally idle) queues the boolean remains set,
and we force messages that could be perfectly sendable right away to
instead be queued up unnecessarily.

This attempts to resolve the issue as follows;

- Firstly, we now clear the 'bQueueing' flag in the OnUpdate function if
  we enter a state where there's no data that can be *immediately* sent.
  This means that the flag is unset if we only consist of blocked
  queues.

- The OnUpdate function restores the 'bQueueing' flag when transitioning
  back from a fully-blocked state to a sendable state.

- The direct send checks have been split out to a new function and in
  addition to checking the state of 'bQueueing', now also check if a
  named queue exists within a certain priority bracket. If it does, then
  we do not directly send the message.

The new check is required to deal with cases where a caller attempts to
send a message on a specific queue while 'bQueueing' is false - as we
don't want to directly send a message ahead of everything else in the
queue that it's supposed to belong to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant