#36520: Performance Regression in parse_header_params
---------------------------------+------------------------------------
Reporter: David Smith | Owner: (none)
Type: Bug | Status: new
Component: HTTP handling | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Comment (by Jake Howard):
The `requests` implementation was the most interesting to me, being so
much faster. After plugging it in to Django however, it seems it's not
quite as robust - many of the test cases fail and produce very unexpected
results. `werkzeug`'s implementation appears to be more robust to the
weird edge cases we need to handle, but still isn't perfect.
To revert or not to revert feels difficult. On the one hand, the `cgi`
implementation is faster almost across the board. However, it's a fair bit
of work to maintain, and parser code like that tends to be where security
issues get introduced. `Message().get_params` is slower (at least on the
easy cases), but using `bytes` makes it slightly less slower than it
currently is, is the officially recommended path forward, and could get
improvements as time goes on (removing the need to create a new `Message`
instance each time improves performance quite a bit). Personally, I'd vote
for adding the short-circuit and `bytes` changes over reverting.
As an aside, to integrate `requests` and `werkzeug`'s implementations into
Django, I had to modify how multi-part form parsing worked, since it
passed the entire header to `parse_header_parameters`, rather than just
the value. I doubt it'll be a performance improvement, but probably
something worth cleaning up regardless, especially if we do swap out the
implementation. I can push up a PR if it's useful?
--
Ticket URL: <https://code.djangoproject.com/ticket/36520#comment:17>
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 visit
https://groups.google.com/d/msgid/django-updates/01070198c763e94c-b1ab2177-8c94-41ab-bfb0-29dc45259f59-000000%40eu-central-1.amazonses.com.