-
Notifications
You must be signed in to change notification settings - Fork 750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance problem since html2pdf 4.0.3 => 5.0.1 #230
Comments
OK I modified "exemple07a.php" in /examples/res/, to increase the number of lines. Same thing => time becomes cray. I tried to add tables (with one line) instead of one table with many rows, same crazy processing time. |
OK I switched back to v4.03 and won't change it unless I'm forced to. |
i wil check this on the last version, thanks for the report |
Hi I would like to generate a pdf but I do not understand the latest version. |
Hi there, I encounter the same problem, as explicitly explained by @michauk . Thanks for your work. |
Hello, Sorry to spam about it, but it's an issue that need fix, really. Thanks for your work. |
We had a similar problem. For us it was because the call of "TCPDF::_destroy" took too long. The reason for this were 2 million files in the temporary folder searched by "TCPDF::_destroy" due to a failure in the session cleaning process. Once the folder was cleaned everything worked fine. PHP v7.0.29-1~dotdeb+8.1 (Debian 3.16.51-3+deb8u1 x86_64) |
Hi, i need some metrics on different environments. Who can launch it ? |
My metrics: |
Hello, To avoid any waste of time, can you provide some deploiement instructions, please ? |
sure git clone https://github.com/spipu/html2pdf.git -b performance html2pdf_performance
cd html2pdf_performance
composer install --no-dev
cd performance
php ./full.php |
Thanks ! Sorry, another problem :/.
|
Hi, this is my metrics :
I'm on Ubuntu for Windows (WSL), I run the script with PHP 5.6 (production version). |
@jomofcw i fix the instructions |
It's OK, thanks ^^. So my metrics (using PHP7 on Debian environment with near default configuration) : |
Hello, My metrics (Debian 9.5 - PHP 7.0.30):
|
PHP7.0 Ubuntu 16.04 PHP7.2 Ubuntu 16.04 PHP7.1.6 Windows 10 |
Are there any News to this Issue? Local PHP: 7.2.9 Thanks in advance! |
Any news on this issue? |
With html2pdf 5.2.1 Same problem as @michauk, but like @DiisMami it works fine on local installation with:
It doesn't work fine on web host with:
My metrics on local: My metrics on web host: PS: sorry if my english is bad |
Hello,
Each function which is calling this createSubHTML() put the return of createSubHTML() in a variable $sub, and often destroy it (the $sub) after having used it. (your function _destroySubHTML doesn't work here, so I made the unset($sub) manualy.) Each time createSubHTML() is called, I log a lack between 10ms and 20ms depending on our server charge. The complete generation of my PDF (1 page, some html tables nested) take 11 202.8ms (~11sec) (sorry for my english, i'm FR) |
Hello, Finaly found the way to solve the problem. The problem is not that much the fact that you clone the whole object, but the __destroy methods of each class linked to this object, when it is remove by the garbage collector.
|
By the way, this file cleaning should be executed ONCE, at the real end of the script using HTML2PDF. So i've surcharged MyPDF.php, with __destruct and _destroy functions, with the glob removing commented (see my precedent post). In Html2Pdf.php, i added the tmp_file cleaning in the magical __destruct() of Html2Pdf, like this :
Hope this will help ;) |
Thanks it works good! Could you open a PR? |
Done. Instead of modifying tcpd.php, i changed MyPDF.php, surcharging tcpdf's __destruct magic method. |
Be carreful with the code above, if you want to execute more than 1 instance of html2pdf, one instance could delete files of the other one while the 2nde instance is not yet finished. |
modified. PR done. |
It's mostly a tcpdf issue then I'd recommend making a PR there |
I don't think it's a tcpdf issue... Html2pdf makes lot of recursive instantiation of tcpdf class, that's the real problem... And tcpdf has to clean up its variables once the instance is destroyed.. |
Okay I got what's happening, the ID of the cloned object is the same so it's trying to cleanup the same ID over and over again, it's still an issue in the scope of tcpdf but that can have a hotfix here as well |
I made a PR on Tcpdf, you can hotfix this on Mypdf class on your PR and revert the rest |
Any news about this, please ? This is the only thing that avoid me from using html2pdf v5 :'(. |
I'm personally switching to https://github.com/mpdf/mpdf and advise everybody here to do the same, it's very easy to switch from one to another, |
I have tested meritel's core hack and it brings a massive performance boost indeed, thank you. I suggest to implement this, however, I know that the task is probably first of all with tcpdf, I'll try and suggest it there, too. |
FYI: My tcpdf PR has been merged |
Thanks @Tofandel - that means future installations of html2pdf as well as tcpdf should have it included right? (sorry to ask like a beginner, but in terms of github I am...) |
It was also included in the new release, it means that if you run |
I am having the same issue with V5.2.1. I have reverted back to 4.03. I will have to check out MPDF someday, but for now 4.03 is working good, I just really wanted to use the |
Hey, |
Yeah, 4.6.1 was better but still not as fast as 4.03 Yeah, I had to fix the countable issue too. |
My Metrics on shared web hosting cPanel Version | 86.0 (build 30) 1|62|10495 |
Hello there,
I upgraded from html2pdf 4.0.3 to latest 5.* some days ago. On a Debian standard server (php 5.6...), in order to prepare the Debian upgrade (from Jessie to Stretch, I'm a bit late). I think I read somewhere that I had to upgrade html2pdf to 5 to get it running on php 7. In any case, it surely is a good thing to upgrade this tool along with the distro.
I encountered a big performance problem I didn't have before.
Mainly, my PDF is a [sometimes] big table (many rows, a few columns) with basic stuff in it (amount, date, reference...)
With html2pdf 5, I need 1.5-2 seconds to generate that table (1 page) for only ~70 lines. Time increases exponentially with the number of lines (the server is a big one with, no performance problem, tuning/monitoring it myself blah blah blah).
Before that, for approx. 3000 lines, I needed a few seconds (maybe 5 or 10, I don't remember, but it was reasonnable).
I started to debug this and reduced a copy of my code to just this table with no PHP/mysql processing, I just copied/pasted my table content. I activated setDebugMode to check.
Maybe I missed something simple (or my html code is dirty?), but I can't find why. I tried to remove every style attribute, it's a bit faster, but still slow and exponentially slower.
If anyone has any idea, I'd appreciate.
Here you can find an example with only this table content (+ a footer) with the style attributes (I put it on all TD which is maybe a bad idea. And the same without any style nowhere.
You can copy/paste some TR/TD some generate hundreds of lines and check the processing time.
examples.zip
Regards,
Jacques M.
The text was updated successfully, but these errors were encountered: