PerformanceHighlight of Weekly #001

Barcode and QR images cached per transaction

Reports that repeat the same barcode or QR code on every page now render each image once per transaction. The benchmark shows about 600× faster rendering on a 900-page report.

Versions18.019.020.0
ModulesBase base
AppFramework & technical

Pull requests and commits

BranchPull requestCommit
18.0odoo/odoo#289135 ↗67c42b39af ↗
19.0odoo/odoo#289261 ↗18ba6489e5 ↗
20.0odoo/odoo#290113 ↗b0dd490955 ↗

Commit message

[PERF] base: cache barcode/QR PNG rendering per transaction

Reports with hundreds of pages and repeated barcodes/QR codes (same
document number, same lot code on every page) re-ran reportlab's
createBarcodeDrawing and PNG encoding for every occurrence, even when
type, value and options were identical. That rendering is CPU-bound
and dominates report generation time on large documents.

Cache the rendered PNG in self.env.cr.cache, scoped to the current
transaction like the existing per-request caches in account_move.py
and account_account.py, bounded with the existing LRU helper used by
the registry caches. frozendict makes the kwargs dict hashable without
a lossy tuple conversion.

A registry-wide ormcache was considered and dropped: barcode rendering
never needs invalidation, and sharing the existing 'default' LRU(8192)
cache would evict unrelated entries under this new load.

Benchmark, 900 pages x 4 barcodes/page, 4 distinct combos: ~600x
speedup, uncached render dominated by reportlab's C-extension drawing.

My stack

Pick the versions and apps you run. Weekly digests, this week's table and All changes then show only what concerns you. Saved in this browser.

Versions
Apps
Modules