I have some performance related questions about Silverlight Enterprise app development - silverlight

I have some performance related questions about SL Enterprise app development.
-We have 10.000 rows binding to an ItemsSource control. (A total of 100.000+ UIElements when databound)
Q1.How to do this binding in another thread? Because Silverlight gets stuck while the binding happens.
Q2.Any other ways to do this that you suggest with the same visual flexibility like we have in an ItemsControl.
-We are pulling a total of 60MB (unzipped binary serialized XML) data from server and letting our SL users use it for a period of 20 minutes.
Q1.We have some memory leaks and getting hard time to figure out what’s staying in the memory? Do we have a tool to show this?
According to our latest test UIElements are the ones filling the memory. We have 5 nested Itemscontrols, tracking a lot of “loaded” events of inner control in order to fill the appropriate values with calculations. As far as I see virtualization is not working on Items control.
Thanks for all your time.

If you are using the DataGrid, Virtualization should be on by default.
Pulling that much data at one time might also pose a problem. I'd try to find some sort of solution that involves server-side paging.
EDIT:
Just saw that you are using an ItemsControl. The biggest performance boost you'll see (before even getting server paging to work) would be to get virtualization working. Here's a good article about doing it with a generalized ItemsControl (It also addresses your problem with events not firing correctly):
http://blogs.claritycon.com/blogs/lee_roth/archive/2009/09/16/custom-panels-in-silverlight-wpf-part-4-virtualization.aspx

Related

Silverlight performance issue!

I have a serious Performance issue in my Silverlight project, when I run my project the CPU usage is going up 80% - 90%
the computer go down!!!, these are the major feature of the project:
1- We are using Silverlight 4.
3- We are using MVVM pattern, which means all data source, states are Binding with the properties in the View Model.
4- Most of the controls are created dynamicly in code.
5- We have a reference for the Main control in the Main view model which is the container of all generated control.
6- In our controls we have many of layouts (Grids).
7- We have Main view model which is the container of all children view models in the system.
8- We have lots of states and animations.
9- We don't use the Relay commands, we are using the regular commands and events, so we raise the event and handle it's parent (we have lots of events).
Is there any of the above causes the performance problem??? I thinks that there is a issue in the Silverlight itself, is there any Silvelight 4 update for performance.
I appreciate any help,
Thanks
A complex application is likely to have performance issues to resolve. The use of data-binding and various events, while great for structuring your application, can make it hard to see what's going on. The control flow may not be obvious, for example code may be executing multiple times due to cascading events/property changes.
I'd recommend using a profiler to see what is consuming most CPU time - JetBrains DotTrace is one I've used with Silverlight, see other questions for more. Then you can focus on the problem areas.
If your application is becoming progressively slower over time, it would be worth investigating whether there are memory leaks also.
Are you using DropShadowEffect anywhere? In which case, you might want to try removing them. I've had this issue once. A template included a DropShadowEffect which made the CPU max out, removing it solved the problem.
In my experience, your 9th point is usually the culprit.
Make sure that you release the event handlers in your classes when you're done with them. In almost all cases where I've seen performance degradation in Silveright or WPF is was the improper handling of event delegates.
As one of the comments pointed out, use a performance profiler and you'll most likely see that the event handlers are consuming an inordinate amount of RAM...meaning that they're sticking around after they're supposed to, and responding to events.
So the performance issue stems from having many objects or controls staying in memory and responding to events.
That's my best guess.
Hope it helps.

Telerik vs. Infragistics for Silverlight

Yes, this is certainly a duplicate question, but I wanted to get some fresh takes.
My impression is that Telerik is a much more complete suite, but I'm really really turned off by the responsiveness of their controls. It just seems "clunky" in terms of responsiveness (I have a very fast computer and video card). Scrolling in a grid and transitions chunk, even in their latest demos where they claim to have good performance. I do like that their WPF suite matches their SL one in terms of API.
Infragistics has fewer controls and less theming possibilities, but their controls are very responsive. Scrolling in a grid is fluid, as are their combo menus and all the other controls.
I checked out ComponentOne and their controls seem analogous to Telerik's in terms of the points mentioned above but are a little less "pretty".
Any thoughts from other users of these suites? Basically, what I'm looking for is a suite that will be highly performant and responsive, relatively customizable from a theming standpoint, and have enough functionality to develop a LOB SL application without having to use multiple suites to satisfy the majority of common requirements.
Telerik by far has the slowest (clunky) controls. We've downloaded datagrids from many of the control companies (Infragistics, ComponentOne, Telerik, etc) and found Telerik's to be the slowest as far as loading and refreshing hundreds of thousands to a million rows. I can't speak much for the rest of the controls tho. Testing speed and memory consumption, we found the C1Flexgrid was fastest, followed by Infragistics xamGrid, then Microsofts grid, C1Datagrid and last was Telerik's radGridView.
If you think about this, would you really ever want to load 100's of thousands to 1 million records in a grid or any control for that matter? Well unless you're trying to come up with some marketing fodder?
I don't know of a monitor that could load that many at once to look at. Even if it could, maybe I'm just slow but I can only process them a couple at a time.
What can an average user look at and process. 10 records, maybe 20.
I could see maybe wanting to load a 100 or so and not have to page to get new recors, but thousands or millions? Personally I'm going to require filter capabilities and paging and if I have a developer trying to load 1 million records into a grid, we're going to have to have a sit down because the performance of a grid or any other control is not the issue.
Let's look at a multi billion $ company who has a site and it's sole purpose is to return data to a users. I'm referring to Google. Do a search and you get back around 10 records. I just did a search and got 21,400,00 results. If I don't find what I'm looking for in the first page or two (20 records), I know I didn't filter good enough. I'm not not sifting through a million records.
So that puts your performance back to your logic of retrieving records and giving your users the correct ability to filter down the data they really need at the time.
How fast one grid shows 1.5 million records seems like fodder for "bench racing" and who cares if it's sluggish scrolling because why pull back that many records to start with?
I apologize if I'm missing the point and you're just having fun with bench racing. But I read you are talking about real world, LOB applications and if that's the case then we need to be realistic about the scenarios.
We use the Telerik grid and it performs just fine for real world LOB app. Again though the users we write for can't look at or process 1.5 millions at once nor would they care too.
Also as you're finding out in this thread their support is second to none and I'll take that anyday from a any company we buy a these types of products from over whether they can load a million records in a grid or not. Telerik, Infragistics or whoever.
For anybody serious about real world scenarios and trying to find a quality suite, the first thing to realize is who's on this thread trying to answer questions about their products.
Please have a look at the following demo which binds 1.5 million rows to a grid with sorting and filtering enabled:
http://labs.infragistics.com/silverlight/lobsamples/2010.3/#/Samples/Grid/Performance/GridLargeResultSet
The "Virtual Collection" is another performance feature:
http://labs.infragistics.com/silverlight/lobsamples/2010.3/#/Samples/VirtualCollection/Scrolling/xamGridScrolling
Disclaimer: I am a Technical Evangelist with Infragistics
I suggest you to check the Performance section in our demos for more info about how the grid will perform with large data and/or real-time updates. Here are several examples:
http://demos.telerik.com/silverlight/#GridView/Performance
http://demos.telerik.com/silverlight/#GridView/UIVirtualization
http://demos.telerik.com/silverlight/#GridView/RealTimeUpdate
http://demos.telerik.com/silverlight/#DataVirtualization/FirstLook

Loading a datagrid with large amounts of data in silverlight?

I am breaking up my project in small sections and one of the sections involves loading a grid with possibily lots of records (could be up to 1000s of records in the database).
Ideally I would like some sort of mechanism where as the users scrolls the grid, more data is retrieved.
I have read that certain controls (datapager with RIA) do this but I would like to know how I could implement this myself or do something similiar?
I was thinking about first loading 50 records at a time and when the user gets to scroll near the 50th record, then get another 50 as a start and so on. Not sure how I do this but this does not feel right or whether I should load ids of records in the grid and then get each row to load itself via an async thread but then I am hitting my database for each record?
Thanks
JD.
Sounds like you are describing data virtulization. Xceed seems to be working on a commercial control with this capability but to date have not realeased anything(see Xceed DataGrid for Silverlight Tech Preview! ). For some ideas from the WPF world on doing this you can check out:
Data virtualization
How can I improve on existing WPF data virtualization solutions?
I have just published a couple of articles with some sample code describing how to do stealth paging/data virtualization in silverlight without using any third-party components.
Read the introductory post to find out about the sample, and then follow up with Digging into VirtualCollection.

WPF listview / gridview performance horrible, suggestions

I have a window using a WPF ListView/GridView bound to an ObservableCollection. The performance is utterly horrific. The application chokes trying to load 300-400 items and CPU usage spikes each time an item is added/removed/modified. Profiling doesn't reveal anything obvious.
Anyone have any suggestions?
Check these properties out:
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True"
You need to virtualize your ListView's ItemSource as explained in this article: WPF: Data Virtualization on CodeProject by Paul McClean
First guess, are you making use of complex data templates for each ListViewItem? This might be anything from lots of images, to (old) BitmapEffects, to even lazy-loaded properties that fetch data on demand from a database (which may cause you to perform many db calls to render each visual, depending on how your data model works).
Second guess, is the list itself able to run its load/add/modified/removed routines quickly (meaning the problem occurs when rendering the data), or does the list itself do those jobs slowly (indicating the list is having some kind of issue).
have you tried virtualization as recommended in this question??
WPF ListView Very Slow Performance - Why? (ElementHost, or Other Reason?)
And the obvious one, make sure you have upgraded to .net 3.5 SP1, there were a lot of performance gains there.
Also it may be worth looking into the WPF datagridview control as a lot of the performance work in .net 3.5 SP1 were so the datagridview would have good performance on large datasets.
http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25047
I had similar problems. Setting MaxHeight to a value larger than the ListView's actual height solved it instantly for me, thanks to this answer here, but I still fail to understand how it worked.

Is DataGrid a necessity in WPF?

I have seen a lot of discussions going on and people asking about DataGrid for WPF and complaining about Microsoft for not having one with their WPF framework till date. We know that WPF is a great UI technology and have the Concept of ItemsControl,DataTemplate, etc,etc to make great UX. Even WPF has got a more closely matching control- ListView, which can be easily templated to give better UX than a traditional Datagrid like display. And I would say a readymade DataGrid control will kill or hide a lot of creativity and it surely will decrease the innovations in User Experience field.
So what is your opinion about the need of DataGrid in WPF as a Framework component? If you feel it is necessary then is it just because the world is so used to the DatGrid way of data display for many years?
Some other threads having the discussion about DatGrid are here and here
Link to WPF ToolKit - Latest WPF DatGrid
DataGrids are excellent for displaying large amounts of tabular data bound to a backing store.
But what happened in the WinForms world was that people often used them for everything that required a multi-element scrolling list. Souped-up third-party DataGrids soon became available that allowed columns and fields to contain buttons and ComboBoxes and icons, etc.
The DataGrid became a workhorse because there was a need for something it could be coaxed into behaving like. Similar happened to DataTables before generic collections came along--and when you're using lots of DataTables, presenting it in the UI with a DataGrid is the path of least resistance.
I think that when WPF came out, a lot of programmers like me were still thinking in this fashion, and sought out WPF ports of the DataGrid concept.
Can't think of a better control to display tabular data, especially in business apps where you don't want to reinvent the wheel by templating/developing a (Headered)ItemsControl to make it behave like the good old DGV. I'm sure you saw this.
Nobody is disputing that you can make a DataGrid control in WPF yourself. The same can probably be said about WinForms, although it would be more difficult. I've implemented some functionality with ListView - presenting tabular data is easy, you could even say it's well supported. However, the amount of code, manually written code, needed to make an editing ListView is enormous.
The business applications usually require editing of many tables, and you don't want to be creative, you want to be quick. That's why DataGrid is needed in my opinion.
Yes DataGrids will never go away as essential business UI components. People love their spreadsheets and we want to share in that love!
Note that MS are shipping these extra controls - they have created the WPF Toolkit on CodePlex to provide a fast-turnaround, open-source style of deployment.
It already includes a DataGrid and Calendar.
Yes it is!
Among many other controls that ms failed to deliver. (Datepicker, NumericControl)
MS should first give us the tools to get the job done, that is the least i expect from a programming enviroment with the hype of wpf.
It is essential, but you can achieve nearly the same effect with a ListView that is using a GridView, can't you?
After working with WPF for about 2 years now. I would say that a DataGrid is really just a glorified ListBox (since [almost] everything in WPF is styleless).
One could style a ListBox to take an Entity of some sort and show a "record" control for each entry. Depending on how flexible these are made, they could automatically adjust based on the entity passed.

Resources