#35232: Cache Options.verbose_name_raw
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
Type: | Johnson
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Adam Johnson:
Old description:
> Another candidate for caching, like #35230, following the same system
> check profiling.
>
> The `Model._meta.verbose_name_raw` property returns the stringified
> version of the `verbose_name` attribute whilst temporarily disabling
> translations. It is only used in `django.contrib.auth` for creating
> permission names.
>
> I found this property was taking ~15 of the total runtime for system
> checks on a project with 118 models. calls. Turning it into a
> `cached_property` and adding a no-translation fast path saves nearly all
> this cost, with the below results.
>
> Before: 520 calls taking 10ms
> After: 105 calls taking ~0ms
New description:
Another candidate for caching, like #35230, following the same system
check profiling.
The `Model._meta.verbose_name_raw` property returns the stringified
version of the `verbose_name` attribute whilst temporarily disabling
translations. It is only used in `django.contrib.auth` for creating
permission names.
I found this property was taking ~15% of the total runtime for system
checks on a project with 118 models. calls. Turning it into a
`cached_property` and adding a no-translation fast path saves nearly all
this cost, with the below results.
Before: 520 calls taking 10ms
After: 105 calls taking ~0ms
--
--
Ticket URL: <https://code.djangoproject.com/ticket/35232#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018dc8a9b536-ff787a10-ca30-49c4-816d-dd7fbcc1f697-000000%40eu-central-1.amazonses.com.