Changes between Initial Version and Version 1 of Ticket #34746
- Timestamp:
- Jul 27, 2023, 2:49:52 PM (16 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #34746
- Property Summary High CPU/memory consumtion when a 5xx is raised with a large local variable → High CPU/memory consumption when a 5XX is raised with large local variables
-
Ticket #34746 – Description
initial v1 1 1 Hi! 2 2 3 In a view with large variable in scope, if an exception is raised, the worker will freeze and its memory usage will raise. Here is a minimal example: 4 3 In a view with large variable in its scope, if an exception is raised, the worker will freeze and its memory usage will raise. Here is a minimal example: 5 4 6 5 {{{ … … 20 19 }}} 21 20 22 When calling /compute-lines/ you will notice the issue .21 When calling /compute-lines/ you will notice the issue : the server will take a few seconds to responds while its memory raises by ~1GB. 23 22 24 23 ---- … … 26 25 After a bit of investigations, it turned out it comes from django.utils.log.AdminEmailHandler in the default logging config. This handler will eventually pretty print the whole context of each trace frame from here : https://github.com/django/django/blob/main/django/views/debug.py#L355 27 26 28 This implementation ensures that no more than 4kB are included in the formatted result, but the entire variable will still have to be rendered first. I'm not sure how it could be solved, but maybe reprlibcan be a clue?27 This implementation ensures that no more than 4kB are included in the formatted result, but the entire variable will still have to be rendered first. I'm not sure how it could be solved, but maybe [https://docs.python.org/3/library/reprlib.html] can be a clue?