Closed tillkamppeter closed 2 years ago
[master a42fe51] Fix 100% CPU bug when cleaning out old jobs (Issue #218)
[v1.2.x 1557965] Fix 100% CPU bug when cleaning out old jobs (Issue #218)
Thank you very much, it works!
So it was permanent cleaning of the job lists.
The Snap Store is rebuilding all my 4 retro-fitting Printer Application Snaps now ... (do not forget LPrint and hp-printer-app, Mike ...).
Found another 100%-CPU problem in pappl-retrofit, so for the retro-fitting Printer Applications this needs to get updated, too. Snap Store rebuilding all my 4 retro-fitting Printer Application Snaps again ...
Fortunately there was no Avahi bug involved ...
Describe the bug When a Printer Application is running as server, after some operations it takes 100% CPU. Operations can be printing a job/the test page but also admin operations like identifying the printer, polling defaults/accessories from the printer (PostScript Printer Application), ... usually any operation which interacts with the printer and can be easily triggered by the web interface of the Printer Application.
Investigating what actually takes the 100% CPU is the thread which is spawned to register the services (system, each printer) with Avahi, so that they get advertised via DNS-SD. The main thread registers the services at Avahi via Avahi's API functions and Avahi spawns a thread as it does a Threaded Poll. This thread is the one grabbing 100% CPU (I have found it out by running the Printer Application under the
operf
utility and processing the results withoprofile
, then I have also started the Printer Application undergdb
, interrupted with Ctrl+C, and stack-traced to see what the threads are for). The main thread, once having registered the services and going into the main loop, spawns a thread by itself for each inquiry, but these threads cleanly finish (also in a complex Printer Application using pappl-retrofit) not leaving any runaway thread and stays idling around when one stops doing operations. Independent of this, the Avahi thread ramps up to 100% CPU after the first operation and if not, after the 3rd, 4th, 5th ... operation. Once up to 100% CPU it stays there. The problem is not caused by libpappl-retrofit or libcupsfilters, as it also occurs with the example Printer Application which comes with PAPPL, too.To Reproduce
top
in a terminal window./testpappl
).https://localhost:8000/
if no other Printer Application is running, otherwise port 8001, 8002, ...).top
output. After some seconds the CPU occupation oftestpappl
ramps up to 100%. If not, repeat step 4. After a maximum of ~5 times it should occur, in most cases right at the first time.NOTE: It is possible that it only occurs when the queue points to a real printer. If the sample queues which come with
testpappl
do not make the bug getting reproduced, create a new queue with a real printer (USB or network) and do the steps with this one.Expected behavior CPU consumption of a Printer Application should be negligibly small when the Printer Application is idle.
System Information: