pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Speed up StyleContextStack.autopush() for large tables

Open estanglerbm opened this issue 1 year ago • 4 comments

Speed up StyleContextStack.autopush() for large tables by skipping slower creation of styleOverrideObject and just using the item itself.

Three tests are updated to handle the change in behavior.

Implements #2732

estanglerbm avatar Jun 17 '24 08:06 estanglerbm

Looks like the two build errors are build (not code) issues?

Error: Unable to find Node version '12.x' for platform darwin and architecture arm64.

estanglerbm avatar Jun 17 '24 22:06 estanglerbm

Error: Unable to find Node version '12.x' for platform darwin and architecture arm64.

It is error in GitHub Action, no problem.

According to your edits, you remove style properties filtering. This is unwanted behavior.

liborm85 avatar Jun 18 '24 05:06 liborm85

Right. The style properties filtering is really slow over many table rows. Other methods (reduce, destructuring, etc.) don't seem to speed it up. [Reduce is slower, destructuring same speed.]

StyleContextStack.autopush() is used only in StyleContextStack.auto(), and only to push items, do callback, and then pop those items. So this is about a tradeoff; seems like little benefit of filtering for this operation, and the speedup is significant (especially because DocMeasure.measureTable() ends up calling StyleContextStack.auto() twice per row, which is another issue).

I can't find any code that would end up enumerating the style context stack, and none of the callbacks appear to be under user control, so I don't think this change would really leak info. If this tradeoff is unacceptable, then this PR is not needed. Or perhaps a different StyleContextStack.auto(), or different measureNode(), is needed for table rows.

estanglerbm avatar Jun 20 '24 00:06 estanglerbm

I don't know if this filtering is necessary.

liborm85 avatar Jun 21 '24 14:06 liborm85

It doesn't really seem to matter. Merged. Thanks.

liborm85 avatar Jul 30 '24 15:07 liborm85