Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2023-01-05 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Ready for
  limitedstream, performance |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"57f5669d23fe17d940887e1e3ce694c7366a6330" 57f5669d]:
 {{{
 #!CommitTicketReference repository=""
 revision="57f5669d23fe17d940887e1e3ce694c7366a6330"
 Refs #33865 -- Improved implementation of FakePayload.

 FakePayload is a wrapper around io.BytesIO and is expected to
 masquerade as though it is a file-like object. For that reason it makes
 sense that it should inherit the correct signatures from io.BytesIO
 methods.

 Crucially an implementation of .readline() is added which will be
 necessary for this to behave more like the expected file-like objects as
 LimitedStream will be changed to defer to the wrapped stream object
 rather than rolling its own implementation for improved performance.

 It should be safe to adjust these signatures because FakePayload is
 only used internally within test client helpers, is undocumented, and
 thus private.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701858392547e-2073b2cd-93ec-4568-9046-3ae671c41b56-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2023-01-05 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Ready for
  limitedstream, performance |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"95182a8593f87046999fc50c4f4161843d68273c" 95182a85]:
 {{{
 #!CommitTicketReference repository=""
 revision="95182a8593f87046999fc50c4f4161843d68273c"
 Refs #33865 -- Corrected signature of ExplodingBytesIO.read().

 These subclasses of io.BytesIO should inherit the correct signature.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018583925455-7127e101-a0d5-4208-a1f3-47d6188d7d90-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2023-01-05 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  wsgi,| Triage Stage:  Ready for
  limitedstream, performance |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"b47f2f5b907732d80b164f1f361ae39da94a3fa6" b47f2f5]:
 {{{
 #!CommitTicketReference repository=""
 revision="b47f2f5b907732d80b164f1f361ae39da94a3fa6"
 Fixed #33865 -- Optimized LimitedStream wrapper.

 The current implementation of LimitedStream is slow because .read()
 performs an extra copy into a buffer and .readline() performs two
 extra copies. The stream being wrapped is already typically a BytesIO
 object so this is unnecessary.

 This implementation has largely been untouched for 12 years and,
 inspired by a simpler implementation in werkzeug, it was possible to
 achieve the following performance improvement:

 LimitedStream.read() (single line):
   Mean +- std dev: [bench_limitedstream-main] 286 ns +- 6 ns
   -> [bench_limitedstream-patch] 227 ns +- 6 ns: 1.26x faster
 LimitedStream.readline() (single line):
   Mean +- std dev: [bench_limitedstream-main] 507 ns +- 11 ns
   -> [bench_limitedstream-patch] 232 ns +- 8 ns: 2.18x faster
 LimitedStream.read(8192) (single line):
   Mean +- std dev: [bench_limitedstream-main] 360 ns +- 8 ns
   -> [bench_limitedstream-patch] 297 ns +- 6 ns: 1.21x faster
 LimitedStream.readline(8192) (single line):
   Mean +- std dev: [bench_limitedstream-main] 602 ns +- 10 ns
   -> [bench_limitedstream-patch] 305 ns +- 10 ns: 1.98x faster
 LimitedStream.read() (multiple lines):
   Mean +- std dev: [bench_limitedstream-main] 290 ns +- 5 ns
   -> [bench_limitedstream-patch] 236 ns +- 6 ns: 1.23x faster
 LimitedStream.readline() (multiple lines):
   Mean +- std dev: [bench_limitedstream-main] 517 ns +- 19 ns
   -> [bench_limitedstream-patch] 239 ns +- 7 ns: 2.16x faster
 LimitedStream.read(8192) (multiple lines):
   Mean +- std dev: [bench_limitedstream-main] 363 ns +- 8 ns
   -> [bench_limitedstream-patch] 311 ns +- 11 ns: 1.17x faster
 LimitedStream.readline(8192) (multiple lines):
   Mean +- std dev: [bench_limitedstream-main] 601 ns +- 12 ns
   -> [bench_limitedstream-patch] 308 ns +- 7 ns: 1.95x faster

 Geometric mean: 1.59x faster
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018583925496-c07c3e0e-efc7-483d-9d83-2860b4e39c20-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2023-01-05 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Ready for
  limitedstream, performance |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"7a1543d9f6dd3cac32f0579d8d3b9128c427f531" 7a1543d]:
 {{{
 #!CommitTicketReference repository=""
 revision="7a1543d9f6dd3cac32f0579d8d3b9128c427f531"
 Refs #33865 -- Made RequestsTests.test_set_encoding_clears_GET use
 FakePayload.

 The input stream, wsgi.input, must be a file-like object. The existing
 implementation of LimitedStream was lax and allowed an empty string to
 be passed incorrectly.

 See https://wsgi.readthedocs.io/en/latest/definitions.html#envvar-
 wsgi.input
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701858392542c-6a2acb24-a721-4f8e-a61b-88f0f1a79062-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2023-01-05 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Ready for
  limitedstream, performance |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018582843498-1b5aeb39-9f2d-4666-923e-d611d0086990-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2023-01-04 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Accepted
  limitedstream, performance |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * needs_better_patch:  1 => 0


Comment:

 Marking ready for review again. See my comments on the ticket. I don't
 ''think'' we need to do anything further, and if we do it should be a
 separate ticket.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701857ca3e013-ee0eb717-1ea6-45e4-b312-3dc20caad7ed-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-10-27 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Accepted
  limitedstream, performance |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Anvesh Mishra):

 * cc: Anvesh Mishra (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701841a08f353-2849488e-f076-4c46-9f57-247e6adea3c9-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-08-03 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Accepted
  limitedstream, performance |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


Comment:

 Per Florian's and Nick's comments.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018265043f6d-a7ff8d26-c77d-4126-97a4-482fe7708659-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-25 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Accepted
  limitedstream, performance |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * cc: Ivan Sagalaev, Florian Apolloner (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701823438f8b1-783b7955-34d9-4a1c-ade9-9771c0c5be82-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Accepted
  limitedstream, performance |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * needs_better_patch:  1 => 0


Comment:

 Issues should now be resolved.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822d9dcae2-8d872237-839c-478b-a6c7-8283430cfd98-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Accepted
  limitedstream, performance |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822cb04b79-cfcfc2cd-1d9a-47e5-bc08-16008eb969f2-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:  Accepted
  limitedstream, performance |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Unreviewed => Accepted


Comment:

 Tentatively accepted for future investigation.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822c76cc3e-0ce71de3-3976-47a8-a1f9-03cba580384c-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:
  limitedstream, performance |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Nick Pope):

 Attached benchmark script and output.

 (Although output attached is from a different run/machine to that in the
 description, it's in the same ballpark. Very much an improvement.)

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822c07f139-ec67163b-426d-4d94-ad6f-2bf90d95c2a0-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:
  limitedstream, performance |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * Attachment "bench_limitedstream-patch.json" added.


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822c062805-4b8ca949-87be-4f4b-884a-59c1cad4085b-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:
  limitedstream, performance |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * Attachment "bench_limitedstream-a46dfa87d0.json" added.


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822c05a14e-159940f1-848b-4c53-aa93-3e1d8c2d576a-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:
  limitedstream, performance |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * Attachment "bench_limitedstream.py" added.


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822c055161-52c1b3f1-7052-4bc1-962a-61e53980519d-00%40eu-central-1.amazonses.com.


Re: [Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
 Reporter:  Nick Pope|Owner:  Nick Pope
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  HTTP handling|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:  wsgi,| Triage Stage:
  limitedstream, performance |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Nick Pope):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/15872 PR]

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822c046896-7944f26a-e217-40a5-8280-792dc252cfe6-00%40eu-central-1.amazonses.com.


[Django] #33865: Optimize django.core.handlers.wsgi.LimitedStream

2022-07-23 Thread Django
#33865: Optimize django.core.handlers.wsgi.LimitedStream
-+-
   Reporter:  Nick Pope  |  Owner:  Nick Pope
   Type: | Status:  assigned
  Cleanup/optimization   |
  Component:  HTTP   |Version:  dev
  handling   |   Keywords:  wsgi,
   Severity:  Normal |  limitedstream, performance
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 The current implementation of `LimitedStream` is slow because `.read()`
 performs an extra copy into a buffer and `.readline()` performs two extra
 copies. We're already typically wrapping a `BytesIO` object so this is
 unnecessary.

 This implementation has largely been untouched for 12 years and, inspired
 by a simpler implementation in `werkzeug`, I was able to achieve the
 following performance improvement:

 {{{
 LimitedStream.read() (single line): Mean +- std dev: [bench_limitedstream-
 main] 286 ns +- 6 ns -> [bench_limitedstream-patch] 227 ns +- 6 ns: 1.26x
 faster
 LimitedStream.readline() (single line): Mean +- std dev:
 [bench_limitedstream-main] 507 ns +- 11 ns -> [bench_limitedstream-patch]
 232 ns +- 8 ns: 2.18x faster
 LimitedStream.read(8192) (single line): Mean +- std dev:
 [bench_limitedstream-main] 360 ns +- 8 ns -> [bench_limitedstream-patch]
 297 ns +- 6 ns: 1.21x faster
 LimitedStream.readline(8192) (single line): Mean +- std dev:
 [bench_limitedstream-main] 602 ns +- 10 ns -> [bench_limitedstream-patch]
 305 ns +- 10 ns: 1.98x faster
 LimitedStream.read() (multiple lines): Mean +- std dev:
 [bench_limitedstream-main] 290 ns +- 5 ns -> [bench_limitedstream-patch]
 236 ns +- 6 ns: 1.23x faster
 LimitedStream.readline() (multiple lines): Mean +- std dev:
 [bench_limitedstream-main] 517 ns +- 19 ns -> [bench_limitedstream-patch]
 239 ns +- 7 ns: 2.16x faster
 LimitedStream.read(8192) (multiple lines): Mean +- std dev:
 [bench_limitedstream-main] 363 ns +- 8 ns -> [bench_limitedstream-patch]
 311 ns +- 11 ns: 1.17x faster
 LimitedStream.readline(8192) (multiple lines): Mean +- std dev:
 [bench_limitedstream-main] 601 ns +- 12 ns -> [bench_limitedstream-patch]
 308 ns +- 7 ns: 1.95x faster

 Geometric mean: 1.59x faster
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701822c007bc8-8facb69d-d28c-4963-aa2b-f0fe0b7335c0-00%40eu-central-1.amazonses.com.