GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 3.x: unbounded requests from first, take and others · Issue #6569 · ReactiveX/RxJava

3.x: unbounded requests from first, take and others #6569

New issue
Copy link
New issue
Copy link
Closed
Closed
3.x: unbounded requests from first, take and others#6569
Copy link
Labels
3.xDiscussion
Milestone
3.0

Description

@davidmoten
davidmoten
opened on Jul 12, 2019
Issue body actions

In 2.x we talked about some surprising request patterns from operators like first, take and others where despite only one or a limited number of items being needed, Long.MAX_VALUE was requested of upstream and then cancelled after the desired number arrived (#5077). I believe this was a micro-optimization performance boost that improved the Scrabble benchmarks. Any change to the pattern was rejected based on it being a breaking API change.

In essence I'd like us not to be opinionated about the effect on the upstream of over-requesting (particularly over a network boundary). By over-requesting we are fundamentally losing information that can be useful to optimizing upstream processing. An example that springs to mind is that requesting a large number may be translated to an api call to a remote upstream that does a full sort (O(nlogn)) whereas requesting only one can be implemented upstream with a max scan (O(n)). This of course assumes one and only request to create the stream so is not a run-of-the-mill streaming case. I'd also suggest we are not opinionated about the ability of upstream to respond to cancellation (upstream may be performing cpu intensive actions in third-party libraries that aren't cancellable).

I think the effect on the benchmarks of reverting to naturally bounded requests where obvious (first, take, etc) will be very small.

Can we revisit this one for 3.x?

Activity

  1. akarnokd commented on Jul 12, 2019

    @akarnokd
    akarnokd
    on Jul 12, 2019
    Member
    More actions

    Okay, let's make limit the default and change first/single.

    What about the lambda subscribe?

  2. akarnokd
    added
    3.x
    Discussion
    on Jul 12, 2019
  3. akarnokd
    added this to the 3.0 milestone on Jul 12, 2019
  4. davidmoten commented on Jul 26, 2019

    @davidmoten
    davidmoten
    on Jul 26, 2019
    CollaboratorAuthor
    More actions

    Thanks @akarnokd, so I'm suggesting we constrain upstream requests for:

    • elementAt
    • elementAtOrError
    • first (calls elementAt)
    • firstOrError (calls elementAt)
    • take
    • single(default)
    • singleOrError
    • blockingSingle(default) calls single(default)
    • blockingSingle (calls singleOrError)

    limit can then be an alias for take.

    What about the lambda subscribe?

    You've lost me, what are you referring to?

  5. akarnokd commented on Jul 26, 2019

    @akarnokd
    akarnokd
    on Jul 26, 2019
    Member
    More actions

    There is no reason to have limit separately then.

    lambda subscribe requests max value.

  6. davidmoten commented on Jul 26, 2019

    @davidmoten
    davidmoten
    on Jul 26, 2019
    CollaboratorAuthor
    More actions

    lambda subscribe requests max value.

    Yes, that seems reasonable to me. Why would it be otherwise?

  7. davidmoten commented on Jul 26, 2019

    @davidmoten
    davidmoten
    on Jul 26, 2019
    CollaboratorAuthor
    More actions

    There is no reason to have limit separately then.

    ok by me

  8. akarnokd commented on Jul 26, 2019

    @akarnokd
    akarnokd
    on Jul 26, 2019
    Member
    More actions

    You were worrying about overrequesting over the network boundary. A straight subscribe would do that too for your case. I'm fine with it as is.

  9. davidmoten commented on Jul 26, 2019

    @davidmoten
    davidmoten
    on Jul 26, 2019
    CollaboratorAuthor
    More actions

    You were worrying about overrequesting over the network boundary. A straight subscribe would do that too for your case. I'm fine with it as is.

    I'm fine with it also.

  10. davidmoten commented on Jul 26, 2019

    @davidmoten
    davidmoten
    on Jul 26, 2019
    CollaboratorAuthor
    More actions

    Would you like a PR for these changes? You are welcome to do it yourself if you want to, but I can help if useful.

  11. akarnokd commented on Jul 26, 2019

    @akarnokd
    akarnokd
    on Jul 26, 2019
    Member
    More actions

    I'm still waiting for #6589 but you can go ahead and create a PR.

  12. davidmoten commented on Jul 28, 2019

    @davidmoten
    davidmoten
    on Jul 28, 2019
    CollaboratorAuthor
    More actions

    I'm happy to wait for #6589 before starting the PR

  13. davidmoten
    added 5 commits that reference this issue on Sep 12, 2019

    3.x: constrain upstream requests from take (ReactiveX#6569)

    d4f4277

    3.x: constrain upstream requests from take (ReactiveX#6569)

    aa4b52e

    3.x: constrain upstream requests from take (ReactiveX#6569)

    c2d9279

    3.x: constrain upstream requests from take (ReactiveX#6569)

    c499746

    3.x: constrain upstream requests from take (ReactiveX#6569)

    426c817
  14. akarnokd
    added a commit that references this issue on Sep 13, 2019

    3.x: constrain upstream requests from take (#6569) (#6650)

    0c50f0a
  15. davidmoten
    closed this as completedon Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xDiscussion

    Type

    No type

    Projects

    No projects

      Milestone

      • 3.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.