anasera3 / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

[Performance improvements] recursive frame tree #76

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What would you like dompdf to do:
Please use a global stack, instead of recursive frames.

Currently the frame class build a sibling/child tree in itself. No wonder
it takes so much memory to build large PDF files. You get recursive object
tree, which takes huge amount of memory and slows the process down.

Take a look at the example file for information on what I mean. The example
file is from a xdebug trace on a large HTML page, with images and tables
and stuff.

Doesn't matter what engine is used, because it's in dompdf.

I suggest using something like this:
{{{
Frame_Tree -> public static $_free_stack;

Frame ->
        protected $_first_child = "frame-" . uniqid();
        protected $_last_child = "frame-" . uniqid();
        protected $_prev_sibling = "frame-" . uniqid();
        protected $_next_sibling  = "frame-" . uniqid();
}}}

With free_stack as associative array with unique id's on where the elements
are.

I hope you understand what I mean.

Keep in mind that uniqid() function can kill performance as well. So maybe
there are better function to handle this. But creating a global stack,
removes the recursion part and makes a huge difference on memory usage.

Original issue reported on code.google.com by michiele...@gmail.com on 5 Oct 2009 at 12:32

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 24 May 2013 at 3:00