Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    getPrintHTML and exportClientData slow and memory intensive

    I'm having an issue with the performance of getPrintHTML() and exportClientData() on some of my grids with larger datasets ( ~4000-5000 rows). It takes a long time and a lot of memory to execute either command. I've put together a test case derived from the builtinds sample that uses the supplyItem DS to create a tree of similar size to my application. I'm using the 10/26 nightly build but had the same issue with the 10/16 build.

    In my setup (FF 24, Chrome), it takes approximately:
    • 20 – 90 seconds to export the CSV
    • 12-24 seconds to get the print HTML and the memory usage grows by about 150MB! In chrome, the tab seems to hang for a while after generating.

    Code:
            VLayout layout = new VLayout();
            layout.setHeight(300);
            layout.setWidth(600);
            
            final TreeGrid grid = new TreeGrid();
            DataSource ds = DataSource.get("supplyItem");
            grid.setTreeRootValue("NULL");
            grid.setTreeFieldTitle("itemName");
            grid.setDataSource(ds);
    
            IButton button = new IButton("export");
            button.addClickHandler(new ClickHandler() {
    
                            @Override
                            public void onClick(ClickEvent event) {
                                            DSRequest req = new DSRequest();
                                            req.setExportAs(ExportFormat.CSV);
                                            req.setExportToClient(true);
                                            req.setExportDisplay(ExportDisplay.WINDOW);
                                            grid.exportClientData();
                                            
                            }} );
            IButton printHTML= new IButton("GetPrintHTML");
            printHTML.addClickHandler(new ClickHandler() {
    
                                            @Override
                                            public void onClick(ClickEvent event) {
                                                            PrintProperties pp = new PrintProperties();
                                                            grid.getPrintHTML( pp, new PrintHTMLCallback() {
    
                                                                            @Override
                                                                            public void setHTML(String html) {
                                                                                            Window win = new Window();
                                                                                            HTMLPane pane = new HTMLPane();
                                                                                            pane.setWidth(1000);
                                                                                            pane.setHeight(600);
                                                                                            pane.setContents(html);
                                                                                            win.addItem(pane);
                                                                                            win.setAutoSize(true);
                                                                                            win.setAutoCenter(true);
                                                                                            win.draw();
                                                                            }}  );
                                                            
                                            }} );
            grid.setUseAllDataSourceFields(true);
            grid.setAutoFetchData(false);
            ds.fetchData(null,new DSCallback() {
    
                            @Override
                            public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                                            Tree tree = new Tree();
                                            tree.setParentIdField("category");
                                            tree.setIdField("itemName");
                                            tree.setRootValue("NULL");
    
                                            for ( Record r : dsResponse.getData() ) {
                                                            if ( tree.find("itemName",r.getAttribute("category")) == null) {
                                                                            TreeNode newR = new TreeNode();
                                                                            newR.setAttribute("itemName", r.getAttribute("category"));
                                                                            newR.setAttribute("category", "NULL");
                                                                            newR.setAttribute("isFolder", true);
                                                                            tree.linkNodes(new TreeNode[] { newR } );
                                                            }
                                                            r.setAttribute("isFolder", false);
                                                            TreeNode t = new TreeNode();
                                                            Record.copyAttributesInto(t,r,r.getAttributes());
                                                            tree.linkNodes(new TreeNode[] { t });
                                            }
                                            tree.openAll();
                                            grid.setData(tree);
                                            
                            }} );
            layout.setMembers(grid,button,printHTML);
            layout.draw();
    In order to successfully export - I did need to increase the maxFormContentSize in jetty, as the uploaded form is larger than the default 400KB - though almost all of the time is spent on the client before the upload...

    #2
    This is not surprising for so many rows, consider the volume of work being done, and the fact that it has to be broken up into smaller chunks of processing to avoid getting "script running slowly" dialogs.

    That said, it's possible there's room to optimize - consider the Feature Sponsorship program if speeding up gigantic exports is key for your organization.

    Comment

    Working...
    X