cups icon indicating copy to clipboard operation
cups copied to clipboard

DC - add feature fmtcache

Open chri50 opened this issue 4 months ago • 3 comments

Regarding: https://github.com/OpenPrinting/cups/issues/940#issuecomment-2050121603 Topic: (n)k printer queues startup time

Similar to the needs described in Issue https://github.com/OpenPrinting/cups/issues/940, I implemented a defensive caching framework that could dramatically improve the startup time of cupsd, especially if the majority of printing queues are based on the same PPD and MIME types

Core testing results: Base: opencups 2.4.7 with cache framework applied , set up 6947 printing queues with four different PPD and 30 MIME types. Core: +400 times improvment

Before: ~32 minutes
After:   ~5 seconds

chri50 avatar Oct 07 '25 11:10 chri50

With CUPS_FORMATS_CACHE_OPT=1, an in-memory cache is enabled that stores the MIME type lists determined by mimeFilter() for each printer model (make_model); this allows subsequent queues with the same model to directly adopt the formats already found instead of performing the costly filter discovery again. Optional add-on ENV:CUPS_CANONICAL_DEST

Please let me know, what you think about. Thx.

chri50 avatar Oct 07 '25 11:10 chri50

I need to set aside some time to look at this, and I have my doubts that this duplicate PPD configuration is all that common.

That said, I'm thinking we could just cache based on the cupsFilter lines in each PPD file vs. hashing the PPD itself. That would offer the same benefits across all PPDs (regardless of whether they are the same) - all PS printers that handle "application/vnd.cups-postscript" will report the same supported document formats, for example. If a printer supports multiple media types (multiple cupsFilter lines) then we can either cache based on the set of supported media types (e.g. "image/urf+image/jpeg" for an AirPrint printer) or merge the cached lists of source types that can be filtered (that should be a little faster but I'm not sure whether the optimization would be worthwhile...)

michaelrsweet avatar Oct 07 '25 19:10 michaelrsweet

Thank you so much for sharing your thoughts. I just wanted to mention that I don't assume this PR will be accepted as is. I totally agree with you that the root cause triggering this investigation is not very common, but it is for me at least!-) I really appreciate your suggestion, and I'll try to address the cupsFilter instead of the entire PPD.

Thx.

chri50 avatar Oct 08 '25 19:10 chri50

Closing this one since we ended up with a different implementation to provide this speedup. Thanks!

michaelrsweet avatar Dec 15 '25 16:12 michaelrsweet