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

slow startup #56

Closed
jtorjo opened this issue Nov 28, 2018 · 11 comments
Closed

slow startup #56

jtorjo opened this issue Nov 28, 2018 · 11 comments
Assignees
Milestone

Comments

@jtorjo
Copy link

jtorjo commented Nov 28, 2018

Hi Alex,

First off, insanely awesome lib! Been using it for more than a year now!
Having said that, when there's a LOT of databinding initializations, the startup is really slow.
I basically have a list of databound controls. For 240 controls, it takes roughly 10-12 seconds to startup.

Imagine this code:

foreach (var beat in model.music_beats) {
    var ctrl = new music_beat_ctrl { DataContext = beat, Height = ActualHeight};
    canvas.Children.Add(ctrl);
}

Each music_beat_ctrl is databound, more or less:

<materialDesign:PackIcon Kind="Link" RenderTransformOrigin="0.5,0.5" Width="18" Height="18" Margin="-9 0 0 0"
Visibility="{c:Binding 'linked or highlighted'}"
Foreground="{c:Binding 'highlighted ? media:Brushes.LightSeaGreen : media:Brushes.DimGray'}"
/>

<materialDesign:PackIcon Kind="GuitarElectric" Foreground="DimGray"
Width="{c:Binding 'type == local:beat_type.major ? 18 : 12'}"
Height="{c:Binding 'type == local:beat_type.major ? 18 : 12'}"
Opacity="{c:Binding 'type == local:beat_type.major ? 1 : 0.3'}"
ToolTip="{c:Binding 'type == local:beat_type.major ? 'Major Beat' : 'Minor Beat''}"
/>

While doing profiling, it seems to end up calling DynamicExpresso.Interpretor.constructor 960 times, which ends up with 28800 calls to DynamicExpresso.Interpretor.Reference - I would assume these should be able to be cached somehow?

@Alex141
Copy link
Owner

Alex141 commented Nov 28, 2018

Hi jtorjo,

Thank you :) Yes, I think its really needed to add some cache for parsed expressions. I thought about expressions cache when testing grid scenarios, but is was ok due to wpf optimizations for binding expressions.

I'm preparing edits for that task. If you want, you can provide a minimal example (full xaml + cs) close to your real code, so I can make sure that the performance is better in that case

@Alex141 Alex141 self-assigned this Nov 28, 2018
@jtorjo
Copy link
Author

jtorjo commented Nov 29, 2018

Awesome, will have that done over the weekend at the latest

@Alex141
Copy link
Owner

Alex141 commented Nov 29, 2018

ok, will wait

@jtorjo
Copy link
Author

jtorjo commented Nov 29, 2018

It will take a bit for me to create a simple standalone xaml + cs - that's why I said "over the weekend". Hopefully it will be sooner. Thanks!

@jtorjo
Copy link
Author

jtorjo commented Nov 29, 2018

I've uploaded a standalone example: http://phot-awe.com/test/WpfCalcBinding.zip
Please let me know if it's clear enough

@Alex141
Copy link
Owner

Alex141 commented Nov 29, 2018

Thanks, it's clear enough, very slow :)

@jtorjo
Copy link
Author

jtorjo commented Nov 29, 2018

Hehe ;) glad you could repro :)

Alex141 added a commit that referenced this issue Nov 29, 2018
@Alex141 Alex141 added this to the 2.4.0.0 milestone Nov 29, 2018
@Alex141
Copy link
Owner

Alex141 commented Nov 29, 2018

After adding cache startup was accelerated significantly. On my machine it was 20 seconds in old version and 1 second in new version. The number of created objects significantly reduced also. Very good :)

@Alex141
Copy link
Owner

Alex141 commented Nov 29, 2018

Package was already published. Test it and if you notice more problems with performance, let me know.

@jtorjo
Copy link
Author

jtorjo commented Nov 30, 2018

You rock! So far, works like a charm!
Right now, startup is pretty much instant. Brilliant!

@jtorjo jtorjo closed this as completed Nov 30, 2018
@Alex141
Copy link
Owner

Alex141 commented Dec 1, 2018

Glad to help you :)

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

No branches or pull requests

2 participants