Sunday, April 6, 2008

AdvancedDataGrid performance poll

Hello AdvancedDataGrid users !

I have added two polls to the end of my blog. One for suggesting in what areas should ADG performance improve. Second one for overall performance of ADG in your projects/apps.

Please spare some time out of your busy schedule and take the polls.

I would urge you take both the polls because just taking one poll many not deliver the exact picture. For example if you say vertical scrolling performance needs to be improved we don't know whether the app is hurt by its performance or it is that it would do better with a performance boost.

Thanks for your time !

Of-course if you would like to send me a sample showing poor performance in a particular/general context please do by sending a mail

Update:I am seeing more number of votes on Bad than expected :(

I would appreciate if you leave a comment as to which particular area of ADG you found the performance to be so poor that it forced you turn it down. I am asking this because votes are also going in favor of Good and OK. It would be of great help if I get a pointer in that direction so that we can study that area of the code more and see what performance improvements can be done. Thanks!

35 comments:

Unknown said...

I'd like to add a comment since it wasn't something that was included in the questions. The GroupingCollection class is extremely inefficient. For every single aggregate function (sum, average, etc) the entire collection is looped over. This means that if you add 5 summary rows you are guaranteeing 5 times worse performance just to group the data. There is no reasons all the calculations for all the aggregates shouldn't be done in a single loop over the data. This might not matter when your entire collection consists of a small number of items, but it makes a huge difference when you have a collection of a few thousand items.

Sreenivas said...

Hi Doug,

many thanks for pointing out the performance bottle neck.

-Sreenivas

Nate said...

agree with doug. I have a rather large dataset that sums multiple fields...it takes FOREVER.

Mike Thompson said...

We reported our issue here:

http://bugs.adobe.com/jira/browse/FLEXDMV-1689

Sreenivas said...

Thanks Mike. I took a look at that sample and suggested a 'work-around' which you might use while we figure out the best way to address this issue (and suggestion given by Doug).

Nancy said...

Hello. Sorry to bother you, but you seem to be the person to ask. I'm trying to create a chart using flex and have a way I think I can do it, but I'm wondering if you may know a quicker/better way to use preexisting components. What I would like is a chart that shows a heirarchial drill down relationship. I can get kinda close using AdvancedDataGrid, but the look and feel doesn't work. I lot of wasted space, and I'm trying to show visually the relationships between parents and children with percentages. Much easier if I show.

http://www.wolffebrothers.com/drillDownRelationShip.jpg

example of the chart

Like I said I can get kinda close, and think there may be a way to use the advanceddatagrid with itemrenders etc. Do you have any idea how I would do this. Also the data would be flat and grouped to show the relationship.

Groupings: Type of Food -- Variety of type -- Varieties of Varieties.

The ADG will put all those groupings in one column which wastes a ton of space.

Sreenivas said...

Nancy,

The immediate thoughts say that one needs to build a custom control to display this kind of data. ADG may not suit this requirement as there seems to be multiple children elements within a single row.

Let me think over this.

Thanks
Sreenivas

Nancy said...

Thanks for thinking about it. I've got some ideas I'm working on right now. Because I'm using flat data I'm going to start with writing a function that will take in grouping preferences and spit out an xml version based on my grouping order. When I get that xml file I might be able to use this open source tree map display, or I may write a recursive function that creates H and V boxes so suit the display I'm looking for. Let me know if you come up with any other ideas. If I get this puppy running I'll send to you too.

Thanks,

Sreenivas said...

Hi Nancy,

I think you can use the GroupingCollection to generate the hierarchical data you want. If you want to generate a XML from the collection you can do that too. You can do that by converting it into a HierarchicalCollectionView and iterating over it after opening all nodes.

-Sreenivas

Nancy said...

Oh, that would be a nice shortcut. When I iterate over the HeirachialDataView can I calculate totals of child nodes, attach them as an object to the parent along with the percentage that each node is with respect to its siblings? I guess my question, more broadly, is is there a built in API for iterating? Thanks for your help so far.

Sreenivas said...

HierarchicalCollectionView is a ICollectionView. So you can use ICollectionView.createCursor to get a IViewCursor and use it.

P.S: You may need to borrow ADG code of expandAllNodes to iterate over all nodes. IViewCursor will return only open nodes.

Sreenivas said...

Satish has posted a Tree Chart here.

Nancy said...

I'm back, stumped bad and looking for some advice if you have a little time:>


ok, can't transform a groupingCollection into some sort of Hierarchical data that I can edit. What I'd like to do is pass an advanced data grid a hierarchical data structure with no leaf nodes. I tried creating a groupingCollection from flat data, passing that to a new HierarchicalData instance, but when I look at the data it looks flat and I can't traverse it like I would normally traverse a tree.

var sBs:HierarchicalData = new HierarchicalData(groupingCollP);
var sTs:HierarchicalCollectionView = new HierarchicalCollectionView(sBs);

I also tried just using the grouping collection straight, which when looked at through the debugger is hierarchical. But... when I traverse each node I can only see the children properties, and have to way to add or remove a node which I would then pass back to the adg.

var root:Object = groupingCollP.getRoot();
TraverseTree(root[0]);

I'm also trying stuff like

myXML = new XML(groupingCollP)
traverseTree(myXML);

Man, I can't get it working. So my overall question is does somebody know how I can group flat data using a GroupingCollection and then traverse that collection adding / deleting / modifying nodes as I go. I'm not looking for the traversal algorithm, I have that. I just need to know how to get the data in the correct format.

Thanks a million times a billion for even reading this.

Sreenivas said...

Here is a sample I was trying to write. I have not yet completed it.

It should give you an idea about traversing the GroupingCollection nodes and how to update them.

Nancy said...

(had to take out all xml carrots and put in brackets for this post)

Thanks again for the example. I actually had to do it differently. I am pasting the code to what I did if you are interested. I took the grouping collection and transformed it into an xml document, removing the leaf nodes cause I didn't need them. You could easily incorporate the leaf nodes if you wanted though. So, I have another question for you. How do I use the XML as a dataprovider for adg? I can't find any info on it anywhere, except where people are saying "how do I use xml as a dataprovider", which obviously doesn't work. I've seen a couple tries using the grouping collection on xml but I don't want to group the xml, it is xml.... already grouped the way I want it. Here is my xml file.


[personnel]
[indPersonnel]
[indDetail]
[label]MAN DOG[/label]
[percent]50[/percent]
[count]2[/count]
[indDetail]
[label]CRASH[/label]
[percent]50[/percent]
[count]2[/count]
[/indDetail]
[/indDetail]
[indDetail]
[label]ZONE[/label]
[percent]50[/percent]
[count]2[/count]
[indDetail]
[label]CRASH[/label]
[percent]25[/percent]
[count]1[/count]
[/indDetail]
[indDetail]
[label]STR DOG OUT[/label]
[percent]25[/percent]
[count]1[/count]
[/indDetail]
[/indDetail]
[/indPersonnel]
[/personnel]

I'd like this xml to end up looking like the bottom right hand box in this pdf http://www.wolffebrothers.com/report.pdf

Can you help me?

Below is the code I used to convert grouping collec to xml file. It is based off a function that another adobe engineer wrote to iterate over an xml file.

private function DivideTheBox(level:int,item:Object,childNumber:int)
{

level++;

if(item.children) {

pathArray[level-1] = childNumber;
var diff = pathArray.length - level;
for (var t:int = 0; t [ diff; t++) {
pathArray.pop();
}


if (level != 1) {

var theLabel:String = item.GroupLabel;
var thePercent:String = item.thePercentage;
var theCoun:String = item.theCount;

var newChildNode = new XML([indDetail][label]{theLabel}[/label][percent]{thePercent}[/percent][count]{theCoun}[/count][/indDetail]);

switch (level) {
case 2:
xmlPressures.children()[0].appendChild(newChildNode);
break;
case 3:
xmlPressures.children()[0].children()[pathArray[(level-2)]].appendChild(newChildNode);
break;
case 4:
xmlPressures.children()[0].children()[pathArray[(level-3)]].children()[pathArray[(level-2)]].appendChild(newChildNode);
break;
}

}
else {
xmlPressures.appendChild([indPersonnel][/indPersonnel]);
}

for(var i:int = 0; i[item.children.length; i++) {
DivideTheBox(level,item.children[i],i);
}
}
else {
//if I want to deal with leaf nodes
}
}

Sreenivas said...

I have posted sample code here

You need to make one addition to the xml data. That you can figure out from the sample.

Jacky said...

hi srinivas,
i am having problem regarding row color of Advanced DataGrid. I set RowColor using itemrenderer with overriddern Data method..but when I am scrolling my Advanced DataGrid, All colors mess up .. it displays colors to other rows also..
Please help me out if Possible,,
Thanks in Advance..

With regards,
Janak

TJ Downes said...

OK, so I am a bit slow to the punch on this one, but I've just started using ADG. I agree with Doug, GroupingCollection is great for basic stuff, but very inefficient overall.

My example:

800 records.
The user is allowed to group dynamically by selecting various Grouping fields. Each grouping has a 3 level sub-grouping, resulting in a total of 4 levels of grouping. When the user changes their grouping it results in a delay of approximately 30-40 seconds. Compare this to a SQL statement and we are looking at something many thousands of times slower.

One of the primary purposes I thought the ADG was so cool was that I could allow the client to regroup data on the fly, without the need to requery the server. Unfortunately it looks like the call to the data service is going to be far faster.

Sreenivas said...

I posted a fixed version of GroupingCollection here

http://flexpearls.blogspot.com/2008/06/groupingcollection-with-some-better.html

See if that helps !

Rob McKeown said...

Horizontal scrolling with many columns is very slow.

Tom Gruszowski said...

Ditto on horizontal scrolling & grouping collection (with source code :), I know you are not 'allowed' to release this for your modified version for some political reason.

I would imagine ADG is seriously used by more hard core coders, I've invested more than 100 hours into the grid, it's not a 5 minute demo. I use objects not loose XML, I would like to think that I'm not taking too much of a performance hit simply because you had to code this grid to lowest common denominator.

I would like real focus on efficient object based binding, while I'm able to intercept most things in the grid and handle events based on my custom data provider there are times I had to report to using proxy objects. ONe of these being itemEditedEnd handler that basically forces something like: myRow[nameOfProperty] = newValue. If I hadn't specified dataField in my column this is very difficult to accomplish without serious hacking.

Native right side locking and row level locking & footer row are also HUGE requested features.

Keep up the great work and keep up the frequency and quality of recent posts, yours is probably on e fo the best ADG blogs out there.

DEVSACHIN said...
This comment has been removed by the author.
DEVSACHIN said...

Hi Sreeni,
As I have found ADG contains many features and it is only one compoennt in RIA world that is very capable and useful. Although i am using my custom grid component for a big ERP project and it is using in 98% of my form. I am OK with its features and perfomance. but some times i get problem with variableRow height and rowCount in case of master-detail grid pattern.
Please Solv in next version or suggest us how we manage rowCount when variableRowHeight=true

Thanks
Sachin

DEVSACHIN said...
This comment has been removed by the author.
DEVSACHIN said...

The very good thing with ADG, it is very very flexible component. i got what i want with ADG and according to requirment,I have also done some tweaks in ADG classes.But i also think ADG covers many difficult scenarios (e.g. locaked column, hierarchical data etc) but some scenariois are missout so ,it should be improved. thanks to sreenivas for providing us groupingCollection2 class with better performance.

Sreenivas said...

Thanks for your kind words on ADG ! I have noted your suggestions. Keep your fingers crossed !

DEVSACHIN said...

I have few more that i faced while working with ADG.
1. In ADGitemrenderer, data of a cell is getting scrolled when it is multiline. We have to set mousewheelEnable=false of UITextField of ADGItemRenderer.

2. Click event is captured by UItextField in ADGItemRenderer. So sometime we get ListItemrenderer and sometimes get Uitextfield as object in clickevent

3. When we have Double grid concept (ADG as item renderer) then selectedIndex property is not working properly of master grid.
3. We have many times focus problems in ADG. E.g. I dont think focus of selected row should be moved to header row.

Sreenivas said...

1. Data of a cell is getting scrolled when it is multiline : Are you saying the scrolling is happening even when it is not required ?

2. Click event : Isn't this the expected behavior as the UITextField doesn't cover the entire area of the cell ?

3. ADG as itemRenderer. This is really a big feature if we want to support all the workl fows. At that point of time (and even now I guess) we don't know how many users out there would use this feature to gauge the return on effort investment.

4. Focus: This is a requirement for Accessibility that the selection should move to the header.

DEVSACHIN said...
This comment has been removed by the author.
DEVSACHIN said...

I updated my old post for #2:

1. Data of a cell is getting scrolled when it is multiline : Yes, all multiLine data is showing but if i scroll mousewheel then data is getting scrolled of cell.No vScroll bar here. This issue should be fixed

2. Click event : It is ok now. ListEventITEM_DOUBLE_CLICK solves my problem.

perflexed developer said...
This comment has been removed by the author.
perflexed developer said...

Hi Sreenivas,

Objective:
To show data from the backend in a grid, depending on the data.

Issue:
Vertical scrolling is very slow. Experiencing this proble at 40 rows. At times the row size goes upto a 1000 rows.

Case study:
I am using the ADG for this purpose, and I also have to deal with having the "variableRowHeight=true".

The difficulty is that the ADG is created in the mxml, but the columns and data and then the column renderers for the data are created dynamically from the received backend object (this holds information like the number of columns for the grid, their names, data for the grid and stuff).

So these are the steps that are taken:
1. Create the ArrayCollection for the data provider.
2. Create the columns, as metioned by the backend object.
3. Set the columns array to ADG.columns.
4. Iterate through the first row, to set the item renderers for the columns and their widths.
5. Set the renderers Array to the ADG.rendererProviders Array.

The mxml tag:
"<"controls:AutoSizingAdvancedDataGrid id="dg" sortableColumns="false" showHeaders="true"
dataProvider="{dgDP}" sortExpertMode="true"
selectable="false" variableRowHeight="true"
width="840" styleName="subTaskDG" maxHeight="1000"
draggableColumns="false" wordWrap="true" "/>"


Any help on this matter is solicited. I can provide more information if required.

Thanks.

CRAFT said...

Hoping you can help. I have an advanced datagrid with 12 columns. Every column and every row has an item renderer on it and the data is selectable. I need all this functionality because we are selecting text and providing an in-context menu based on what they select. When we apply the item renderer (even a custom one with nothing in it) the scroll bars become so slow we can't use the DG at all. The ADvDG flows off the screen to the right and below. The number of rows don't seem to make any difference....

any ideas?

Sreenivas said...

Can you send me a sample project showing this problem ?

Anonymous said...

Hi Sreenivas,

Hope you are doing well.

I am confused about ADG performance.
I have used ADG in my application.
ADG columns are created and added at runtime and also set ADGRenderer at runtime while columns are creating.

It is created very perfectly.
But problems occurs while data initialized to ADG dataprovider HierarchicalData variable.
Suddenly ADG performance going too slow.

ADG dataprovider having huge data.

any idea what going wrong with my app.?