Use Content-Length in XHR ArrayBuffer request, maybe introduce X-Decoded-Length

RESOLVED FIXED in mozilla24

Status

()

Core
DOM: Core & HTML
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: vlad, Assigned: vlad)

Tracking

unspecified
mozilla24
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

With bug 866431, the memory usage of ArrayBuffer XHR requests was reduced by reading directly into a growing ArrayBuffer.  We can do even better by trusting Content-Length in the header and using that as the initial allocation size, avoiding realloc fragmentation.

Using just Content-Length would be a big win, because it's unlikely that ArrayBuffer-XHR content will be served with gzip encoding.  But it might be, and there's no good way to handle that; I'd suggest introducing a new X-Decoded-Length header that we'll honor if present for that case.
Assignee: nobody → vladimir
Created attachment 749648 [details] [diff] [review]
use Content-Length, and fix ResetResponse

Simple patch.  Use Content-Length on ArrayBuffer loads if it's specified, up to a max of 1GB.

Also adds a missing reset() to ResetResponse(), which is a bug currently (if the arraybuffer XHR is aborted without the response being read, a subsequent load would keep appending right now).
Attachment #749648 - Flags: review?(bzbarsky)
Comment on attachment 749648 [details] [diff] [review]
use Content-Length, and fix ResetResponse

r=me.

We'll need at least the reset() bits on Aurora, right?
Attachment #749648 - Flags: review?(bzbarsky) → review+
tracking-firefox23: --- → ?
https://hg.mozilla.org/integration/mozilla-inbound/rev/3b0d31eceef1
Yeah, we'll need the reset bits on Aurora, but should just take the whole thing.
https://hg.mozilla.org/mozilla-central/rev/3b0d31eceef1
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
(In reply to Boris Zbarsky (:bz) from comment #2)
> Comment on attachment 749648 [details] [diff] [review]
> use Content-Length, and fix ResetResponse
> 
> r=me.
> 
> We'll need at least the reset() bits on Aurora, right?

Bug 866431 only landed on 24, so what & why do we need something for Aurora here?
Ah, I thought it had landed on 23.  Vlad, do we need anything on Aurora here, or are we all good there?
Flags: needinfo?(vladimir)
Huh, I thought it landed on 23 also.  In that case, nothing needed!
Flags: needinfo?(vladimir)
tracking-firefox23: ? → ---
You need to log in before you can comment on or make changes to this bug.