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

[Bug]: ReactiveProperty very slow with many subscriber #3935

Open
DevEngineReq opened this issue Nov 21, 2024 · 0 comments
Open

[Bug]: ReactiveProperty very slow with many subscriber #3935

DevEngineReq opened this issue Nov 21, 2024 · 0 comments
Labels

Comments

@DevEngineReq
Copy link

Describe the bug 🐞

Recently we moved the ReactiveProperty from Reactive.Bindings.ReactiveProperty to ReactiveUI.ReactiveProperty.
Now we encountered massiv performance problems for the following use case.

If you subscribe a ReactiveProperty very often, the application will freeze. It is very performace intensiv.
With Reactive.Bindings.ReactiveProperty it was not a problem.

Example

public class BasicComparisonViewModel
{

    private readonly SourceCache<BasicViewModel, int> cache = new(static x => x.Id);

    // ReactiveUI => slow
    public ReactiveProperty<int> Property => new (42);

    // System.Reactive => fast
    //public Reactive.Bindings.ReactiveProperty<int> Property => new Reactive.Bindings.ReactiveProperty<int>(42);

    public BasicComparisonViewModel()
    {
        this.cache.Edit(x =>
        {
            for(var i = 0; i < 3000; i++)
            {
                x.AddOrUpdate(new BasicViewModel(i, this));
            }
        });
    }
}

internal class BasicViewModel
{
    public int Id { get; }

    public BasicViewModel(int id, BasicComparisonViewModel vm)
    {
        this.Id = id;

        vm.Property.Subscribe();
    }
}

Our measurements
Reactive.Bindings.ReactiveProperty: ~3ms
ReactiveUI.ReactiveProperty: ∞

Step to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Reproduction repository

https://github.com/reactiveui/ReactiveUI

Expected behavior

This should happen...

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

No response

Additional information ℹ️

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant