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

Processors.newPublisherProcessor simplify duplicate terminal check #2148

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

Scottmitch
Copy link
Member

Motivation:
Processors.newPublisherProcessor checks in the thread generating
data if a terminal has already been observed, and discards duplicates.
However the consumer thread also has the same logic which is required
because we cannot deliver signals to the Subscriber after a terminal
signal is delivered.

Modifications:

  • Keep the required check in the queue consumer thread which filters
    out duplicate terminal events, remove the check in the producer
    thread. If there is a strict limit applied to the queue size
    this may impact how many items the queue needs to hold.

Result:
Less atomic operations, 1 less class in the hierarchy, and less
memory consumed by Processors.newPublisherProcessor.

Motivation:
Processors.newPublisherProcessor checks in the thread generating
data if a terminal has already been observed, and discards duplicates.
However the consumer thread also has the same logic which is required
because we cannot deliver signals to the Subscriber after a terminal
signal is delivered.

Modifications:
- Keep the required check in the queue consumer thread which filters
  out duplicate terminal events, remove the check in the producer
  thread. If there is a strict limit applied to the queue size
  this may impact how many items the queue needs to hold.

Result:
Less atomic operations, 1 less class in the hierarchy, and less
memory consumed by Processors.newPublisherProcessor.
TerminalNotification.class, "terminal");

@Nullable
private volatile TerminalNotification terminal;
Copy link
Member Author

Choose a reason for hiding this comment

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

@NiteshKant - are there any hard requirements for filtering out duplicate terminals before the queue, or does this change make sense?

@Scottmitch
Copy link
Member Author

build failure attributed to #1894

Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

Good to have confirmation from @NiteshKant, otherwise LGTM

@bondolo bondolo added the performance Optimizes performance or reduces overhead label Mar 21, 2022
@Scottmitch
Copy link
Member Author

discussed with @NiteshKant offline. got lgtm and will merge.

@Scottmitch Scottmitch merged commit 998fd00 into apple:main Mar 22, 2022
@Scottmitch Scottmitch deleted the processor_terminal branch March 22, 2022 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Optimizes performance or reduces overhead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants