Bug 1191691

Summary: cups-browsed very inefficient
Product: Red Hat Enterprise Linux 7 Reporter: Tim Waugh <twaugh>
Component: cups-filtersAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: unspecified Docs Contact:
Priority: high    
Version: 7.1CC: jscotka, psklenar, zkabelac
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: cups-filters-1.0.35-18.el7 Doc Type: Bug Fix
Doc Text:
Cause: Local and remote CUPS schedulers were asked for information repeatedly with no cache. Consequence: Excess load was placed on local and remote CUPS schedulers. Fix: The information is now cached during each poll. Result: CUPS scheduler load is reduced.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 12:08:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1110700, 1191021    

Description Tim Waugh 2015-02-11 18:34:35 UTC
Description of problem:
Upstream revisions 7314--7324 fix several inefficient code paths in cups-browsed:

- when listening for CUPS Browsing packets, cupsGetDests() is called each time a packet is received, fetching the entire list of local printers
- when using BrowsePoll, cupsGetDests() is called for each remote printer discovered
- when sending CUPS Browsing packets, cupsGetDests() is called each BrowseInterval

The fixes (a) fix IPP notification handling and (b) use it to track changes in local printers. If there are no changes, recomputing is avoided.

This takes load off cupsd as well as cups-browsed.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.Run 'cupsctl --debug-logging' (as root)
2.Run 'cups-browsed --debug' (as root)
3.Watch /var/log/cups/error_log to see how many times CUPS-Get-Printers is requested

Actual results:
Happens in the situations described above.

Expected results:
Only happens after changes to the local printers.

Additional info:
Recommend just using the latest utils/cups-browsed.c. It also fixes several instances of searching through lists for things that should be in hash tables, etc.

Comment 1 Zdenek Kabelac 2015-06-05 07:55:27 UTC
I'd add couple comments here -

cups-browsed seems to be the only 'permanent'daemon process which is able to keep my fan spinning.

IMHO - it really should do any  'ipp' processing only when it's really queried for some list of printers.

i.e.  I print something just few times per month - yet - long office printer list is processed with poor slow CPU hunger parser every minute.
And not just that - even my '/etc/hosts' file with longer list of blocked sites seems to be scanned every minute because of this.

Would be very cool to see 'browsed' only collecting list of printers addresses - and processing them just when needed  (thus just following systemd design) - I've no problem to get the list of printers some miliseconds later...

Comment 2 Tim Waugh 2015-06-08 16:25:17 UTC
FWIW: The "right" way of doing this is not to use cups-browsed at all. It is only there for applications that do not use libcups (and its client-side DNS-SD discovery), and instead use their own discovery by querying the local cupsd process, expecting that cupsd does discovery (it doesn't, since 1.6).

If all the applications did it this way, discovery would be entirely on demand.

Comment 5 errata-xmlrpc 2015-11-19 12:08:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.