Report generation takes too much time .
-
Hi,
My report takes more than 1 hour to generate pdf. Further, I am checking 1 year of data only. Normally user requirement is to download more than 3 years of data. So far I attached my workspace below and kindly tell me how to improve performance and download it within 4 minutes.playground link.
https://playground.jsreport.net/w/Karthik22296/Tqbb0VFuThe data itself is 18mb.
when I ran with the original data this issue came up.
Timeout Error: pdf generation not completed after 3600000ms
Error: Timeout Error: pdf generation not completed after 3600000ms at Timeout. (E:\Karthikeyan\V2\jsReport\node_modules\jsreport-chrome-pdf\lib\conversion.js:192:19) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)+0 Starting rendering request 15 (user: null)
+207 Rendering template { name: Booking - Booking Log, recipe: chrome-pdf, engine: handlebars, preview: false }
+339 Inline data specified.
+340 Resources not defined for this template.
+341 Base url not specified, skipping its injection.
+393 Replaced assets ["style.css"]
+409 Replaced assets ["/assets/County Logo's/denver.jpg","/assets/County Logo's/orange.png","/assets/County Logo's/sacramento.png","/assets/County Logo's/slo.png","/assets/County Logo's/logo-demo.png"]
+410 Rendering engine handlebars
+2692 Compiled template not found in the cache, compiling
+2763 Pdf utils adding group field, value: "COJL"
+19467 Executing recipe chrome-pdf
+21626 Starting child request to render pdf header
+21631 Starting rendering request 16 (user: null)
+21632 Rendering anonymous template { recipe: html, engine: handlebars }
+21632 Inline data specified.
+21633 Resources not defined for this template.
+21634 Base url not specified, skipping its injection.
+21729 Replaced assets ["/assets/County Logo's/denver.jpg","/assets/County Logo's/orange.png","/assets/County Logo's/sacramento.png","/assets/County Logo's/slo.png","/assets/County Logo's/logo-demo.png"]
+21731 Rendering engine handlebars
+24576 Compiled template not found in the cache, compiling
+24652 Executing recipe html
+24654 Skipping pdf utils operations because template is rendered with non-pdf recipe.
+24655 Skipping storing report.
+24664 Rendering request 16 finished in 3034 ms
+24708 Starting child request to render pdf footer
+24733 Starting rendering request 17 (user: null)
+24757 Rendering anonymous template { recipe: html, engine: handlebars }
+24758 Inline data specified.
+24759 Resources not defined for this template.
+24760 Base url not specified, skipping its injection.
+24786 Replaced assets ["/assets/County Logo's/denver.jpg","/assets/County Logo's/orange.png","/assets/County Logo's/sacramento.png","/assets/County Logo's/slo.png","/assets/County Logo's/logo-demo.png"]
+24819 Rendering engine handlebars
+27658 Compiled template not found in the cache, compiling
+27716 Executing recipe html
+27737 Skipping pdf utils operations because template is rendered with non-pdf recipe.
+27744 Skipping storing report.
+27776 Rendering request 17 finished in 3043 ms
+28645 Converting with chrome HeadlessChrome/76.0.3803.0 using dedicated-process strategy
+2562992 Running chrome with params {"printBackground":true,"marginTop":"3.4cm","displayHeaderFooter":true,"marginBottom":"1cm","headerTemplate":"\r\n \r\n","footerTemplate":"\r\n \r\n \r\n \r\n \r\n
\r\n Page of \r\n
\r\n \r\n","margin":{"top":"3.4cm","bottom":"1cm"}}
-
Than you for the demo.
I see you have 6 items in your input data. How many items you have in your final result sets, so I can multiply the items and test the final set?
-
just multiply the contents in the "data:[ ]"
-
yes, I am asking how many items you have there in the end.
-
Sure.In the Data[ ] list "INC[ ]" array has a list of 40000 indexes.
-
ok so I do something like this with a custom script to multiply data
function beforeRender(req, res) { for (let i = 0; i < 400; i++) { req.data.Data[0].INC.push(req.data.Data[0].INC[0]) } }
With 400 more items, it takes 10s to chrome to do the html conversion and produces 146 pages.
With your expected data, 40 000 items, it is 100x more so you expect the result of 14 600 pages?This will be very hard to optimize to 4min. The majority of the rendering time is used by chrome to do the html->pdf conversion and this is something we have no influence on. You could try to replace the table elements with divs which are typically faster, but you would lose some layout features table provides.
One option is to split the big report to the chunks and do the printing in parallel to employ all the cpu cores, because chrome typically uses just cone core. I uploaded here a demo how it could work, please check it out and let me know if you have some good results with it
https://1drv.ms/u/s!AogtKyPn-GjbhLZ0wLCCU6HHdZAyQw?e=ENQWx6
-
I checked with that parallel script with large data. it results in me showing error like .
Error: Render cycle detected. Template at /Atims Reports/System/Active Roster/Active Roster - Detail/Active Roster - Detail was rendered previously in this render request (hierarchy: /Atims Reports/System/Active Roster/Active Roster - Detail/Active Roster - Detail -> /Atims Reports/System/Active Roster/Active Roster - Detail/Active Roster - Detail). Please verify that reporter.render is not causing cycle
at process.<anonymous> (E:\V2SOURCE\JS REPORT\node_modules\script-manager\lib\worker-processes.js:55:23)
at process.emit (events.js:200:13)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
-
Please try to share a minimal demo in playground that replicates the issue.
-
Hi, now I achieved it through .net itself so I get JSON data and assign it into an object array. further, I divide them into multiple chunks finally I pass the list of array objects into the report and merge the report parallelly. In my case, I am using chrome PDF. we had JSON data inside the "Data" object at the end of report we fetch {{Data. length}} to take count of persons. But now after dividing data into multiple chunks. Total count repeating for every chunk data. How I can resolve the issue. I need total counts at the end of the report at once only.
-
I'm not sure I get exactly what you do.
But seems like you just add some extra variable to the last chunk and based on that display the total count or not.
-
Hi,
Exactly the same scenario only I am trying. adding one extra variable in the last chunk based on what I am trying to display. But in these, I am facing one difficulty. I have to fetch the count of the "Total person" value from the stored procedure itself. Normally, We return Json structure result in the Stored procedure. So Count function making some difficulties in querying. Instead of there is any chance to write a script in the jsreport. kind of After render process and merge all the chunks and find out the length of the total count.
-
maybe you get the answer here https://jsreport.net/learn/pdf-utils#usage-in-script