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

Make some Mono sources and aggregators lazier #3081

Merged
merged 25 commits into from Aug 3, 2022
Merged

Conversation

OlegDokuka
Copy link
Contributor

Signed-off-by: Oleh Dokuka odokuka@vmware.com

Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
in case of empty sources flux to mono operators emits a value which in that case may violate backpressure components of RS spec. Thus, this PR reworks implementation and adds lighter ways of checking if there is request using non-volatile field and extra volatile int state

Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
Copy link
Member

@simonbasle simonbasle left a comment

Choose a reason for hiding this comment

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

I know this is in an intermediate state, but I've commented anyway.
I like the direction it is going with the hasRequest/state 👍

things that needs to be addressed in the final revision:

  • scan support of at least TERMINATED, instead of removing the test lines that check this attribute (there is no reason the attribute couldn't be supported thanks to state)
  • test coverage regression: some tests for operator X use one of the modified operators Y (eg. count) to trigger a fusion path. now operator Y doesn't support fusion anymore => the test is deleted 😨. since operator X does support fusion, the case has to be covered which means we need to find an alternative to Y instead of purely deleting the whole test
  • as discussed, you already intend to mutualize some code around QueueSubscription that always negotiate Fuseable.NONE in a common base class, which I think makes sense. this would allow fixing the bug of isEmpty() == false && size() == 0 in one go :) that said, we might want to reconsider some of these fusion deactivation/removal...

Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
@OlegDokuka OlegDokuka marked this pull request as ready for review July 27, 2022 13:05
@OlegDokuka OlegDokuka requested a review from a team as a code owner July 27, 2022 13:05
Copy link
Member

@simonbasle simonbasle left a comment

Choose a reason for hiding this comment

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

shaping up good, this is a big one !
I have found some issues and also added more minor comments / questions

this.aggregator = aggregator;
//noinspection unchecked
this.aggregate = (T) INITIAL_STATE;
Copy link
Member

Choose a reason for hiding this comment

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

this feels a bit hacky but I understand 😅

my concern is that it becomes too easy to add code like actual.onNext(aggregate) while forgetting the aggregate != INITIAL_STATE check beforehand, as this wouldn't trigger any compiler error.

having an Object field instead kinda forces us to at least add an explicit cast, which in turns should raise our awareness (and shouldn't need warning suppression either).

instead of 1 cast, it would mean at least 2 though:

  • when the BiFunction is applied in onNext (with slightly more work, 1 more local variable to track probably)
  • when actual.onNext(r) is called in onComplete

wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

☑️

OlegDokuka and others added 3 commits August 1, 2022 16:29
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
Copy link
Member

@simonbasle simonbasle left a comment

Choose a reason for hiding this comment

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

nice ! finally ready to merge 😄 🎉

@simonbasle simonbasle changed the title Adds support for lazy evaluation to Mono producers Make some Mono sources and aggregators lazier Aug 3, 2022
@simonbasle simonbasle linked an issue Aug 3, 2022 that may be closed by this pull request
1 task
@simonbasle simonbasle added this to the 3.5.0-M5 milestone Aug 3, 2022
@simonbasle simonbasle added type/enhancement A general enhancement wide-change warn/behavior-change Breaking change of publicly advertised behavior labels Aug 3, 2022
@OlegDokuka OlegDokuka merged commit 88587fc into main Aug 3, 2022
@chemicL chemicL deleted the feature/lazy-mono branch April 11, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A general enhancement warn/behavior-change Breaking change of publicly advertised behavior wide-change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lazier Monos: act on first request rather than onSubscribe
2 participants