Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(fetch): improve body mixin methods #3109

Closed
wants to merge 1 commit into from

Conversation

tsctx
Copy link
Member

@tsctx tsctx commented Apr 13, 2024

Optimize arrayBuffer of Body mixin.

  • main
benchmark                 time (avg)             (min … max)       p75       p99      p999
------------------------------------------------------------ -----------------------------
• small (length 512)
------------------------------------------------------------ -----------------------------
Response#arrayBuffer  32'459 ns/iter  (9'500 ns … 13'394 µs) 35'000 ns    167 µs    550 µs
Response#text         12'947 ns/iter     (9'100 ns … 567 µs) 13'400 ns 35'100 ns    258 µs

summary for small (length 512)
  Response#text
   2.51x faster than Response#arrayBuffer

• middle (length 8192)
------------------------------------------------------------ -----------------------------
Response#arrayBuffer  28'777 ns/iter  (11'700 ns … 2'818 µs) 24'500 ns    118 µs    326 µs
Response#text         23'271 ns/iter    (11'800 ns … 724 µs) 19'300 ns 99'300 ns    258 µs

summary for middle (length 8192)
  Response#text
   1.24x faster than Response#arrayBuffer

• long (length 131072)
------------------------------------------------------------ -----------------------------
Response#arrayBuffer     300 µs/iter  (53'700 ns … 3'534 µs)    280 µs  1'559 µs  3'187 µs
Response#text            322 µs/iter     (120 µs … 3'235 µs)    299 µs  2'027 µs  3'152 µs

summary for long (length 131072)
  Response#arrayBuffer
   1.07x faster than Response#text
  • this patch
benchmark                 time (avg)             (min … max)       p75       p99      p999
------------------------------------------------------------ -----------------------------
• small (length 512)
------------------------------------------------------------ -----------------------------
Response#arrayBuffer  20'018 ns/iter   (9'500 ns … 4'492 µs) 15'800 ns    102 µs    415 µs
Response#text         13'385 ns/iter    (10'100 ns … 478 µs) 13'200 ns 38'900 ns    214 µs

summary for small (length 512)
  Response#text
   1.5x faster than Response#arrayBuffer

• middle (length 8192)
------------------------------------------------------------ -----------------------------
Response#arrayBuffer  22'374 ns/iter  (10'900 ns … 2'683 µs) 18'800 ns 97'200 ns    335 µs
Response#text         22'599 ns/iter    (12'200 ns … 487 µs) 21'500 ns 97'700 ns    284 µs

summary for middle (length 8192)
  Response#arrayBuffer
   1.01x faster than Response#text

• long (length 131072)
------------------------------------------------------------ -----------------------------
Response#arrayBuffer     216 µs/iter  (38'100 ns … 3'201 µs)    200 µs    984 µs  2'929 µs
Response#text            314 µs/iter     (119 µs … 3'251 µs)    290 µs  2'046 µs  3'122 µs

summary for long (length 131072)
  Response#arrayBuffer
   1.46x faster than Response#text

@tsctx tsctx marked this pull request as draft April 13, 2024 11:38
@tsctx tsctx force-pushed the perf/improve-body-mixin branch 2 times, most recently from 6ec3801 to 02e8b73 Compare April 13, 2024 11:46
@codecov-commenter
Copy link

codecov-commenter commented Apr 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.06%. Comparing base (7a94682) to head (54fa2b2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3109   +/-   ##
=======================================
  Coverage   94.06%   94.06%           
=======================================
  Files          89       89           
  Lines       24327    24331    +4     
=======================================
+ Hits        22883    22887    +4     
  Misses       1444     1444           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tsctx tsctx force-pushed the perf/improve-body-mixin branch from e233243 to 93a4deb Compare April 13, 2024 11:56
@tsctx tsctx marked this pull request as ready for review April 13, 2024 11:57
@tsctx tsctx force-pushed the perf/improve-body-mixin branch 2 times, most recently from e85abc7 to 54fa2b2 Compare April 13, 2024 13:45
Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I prefer one or two more approvals.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tsctx
Copy link
Member Author

tsctx commented Apr 15, 2024

Suppressed by #3117

@tsctx tsctx closed this Apr 15, 2024
@tsctx tsctx deleted the perf/improve-body-mixin branch April 15, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants