Skip to content

Conversation

akarnokd
Copy link
Collaborator

  • Inline the relevant parent fields into the sinks
  • Use a more efficient recursive scheduling disposable-tracking scheme
  • Delegate to base.Run where applicable.

private IDisposable _loopDisposable;
private IStopwatch _watch;

public void Run()
public void Run(IObservable<TSource> source, IScheduler scheduler)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

scheduler is only needed to get the StartStopwatch before the operator executes.

{
if (_queue.Count > 0)
{
ForwardOnNext(_queue.Dequeue());
recurse(this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you elaborate more on the issue with this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is the very same situation with Range and ToObservable: the Action-based recursive scheduling is more expensive.

https://github.com/dotnet/reactive/pull/684/files#diff-76edecc51f6af371eae34be29849253aR62

Copy link
Collaborator

Choose a reason for hiding this comment

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

Any possibility to optimize the action based recursive scheduling? The syntax is much less noisy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see how. It has to maintain some state across schedules. There was an optimization for it in #617, particularly the InvokeRec1State which holds a CompositeDisposable and creates a SingleAssignmentDisposable for each schedule invocation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would local functions help? You can capture the state without needing a delegate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that still makes an allocation just like a capturing delegate would upon each invocation.

Copy link
Contributor

@clairernovotny clairernovotny Jun 29, 2018

Choose a reason for hiding this comment

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

Yes, it does still have a state variable for the capture, but no delegate variable. depends on the use case

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the issue here is, why does the action based scheduling have to keep track of all the schedulings in a CompositeDisposable. Seems odd, at least for tail recursion.

@akarnokd
Copy link
Collaborator Author

Is there something else needed for this PR?

@danielcweber danielcweber merged commit 0d4e94c into dotnet:master Jun 29, 2018
@akarnokd akarnokd deleted the TakeLastImprovements branch June 29, 2018 17:28
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.

3 participants