Menu

Cutting Per-Request Work in Horilla's Breadcrumbs Context Processor
📰

Cutting Per-Request Work in Horilla's Breadcrumbs Context Processor

DEV Community: django·Robert Markovski·1 day ago
#oj7QogAJ
#devtodjango#devto#dev#every#request
Reading 0:00
15s threshold

A Django performance fix, sharpened by one precise review request.

Short answer

Horilla's breadcrumbs() context processor runs on every rendered page. It loaded every Employee row, and every active Candidate row, as full model objects just to read their IDs, then wrote the list to the session on almost every request. The fix fetches IDs with values_list , builds querysets only in the branch that needs them, and writes to the session only when the list changes. It was merged as PR #1180 and closed issue #1038 .

The problem

Horilla is an open-source HR management system built with Django. Issue #1038 reported high latency in a Locust load test, with some requests taking "even 40 secs".

Root cause

The maintainer summarized it in review: " breadcrumbs() is a context processor, so it runs on every rendered request, and before this change it unconditionally evaluated Employee.objects.all() and Candidate.objects.filter(is_active=True) ...…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.