Bug 1383404 - Part 3. SourceBuffer::mChunks should be an AutoTArray instead of FallibleTArray. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Tue, 01 Aug 2017 06:59:11 -0400
changeset 372188 8d5e41b9498b971f3e4b0f704fa8cd81ccdac10e
parent 372187 d8223b2142a9d5834e56f96598d07e9b50843e67
child 372189 729621d1ffac9f5c761222c3ab3df08e97530040
push id93233
push useraosmond@gmail.com
push dateTue, 01 Aug 2017 10:59:33 +0000
treeherdermozilla-inbound@41faadcda947 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1383404
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1383404 - Part 3. SourceBuffer::mChunks should be an AutoTArray instead of FallibleTArray. r=tnikkel We should use AutoTArray instead because telemetry shows that the vast majority of images loaded (95%+) contain only a single chunk when decoding finishes. Even if part 2 of this bug increases the number of images loaded with multiple chunks, we still call SourceBuffer::Compact after the decode is complete, which typically will reduce the number of chunks to 1 (unless memory is very low and we fail to consolidate the chunks). Thus it should be rare to contain more than 1 chunk on anything but a temporary basis, and we can easily save the malloc overhead. Note that SourceBuffer::AppendChunk still uses the fallible variant of nsTArray::AppendElement.
image/SourceBuffer.h
--- a/image/SourceBuffer.h
+++ b/image/SourceBuffer.h
@@ -489,17 +489,17 @@ private:
   //////////////////////////////////////////////////////////////////////////////
   // Member variables.
   //////////////////////////////////////////////////////////////////////////////
 
   /// All private members are protected by mMutex.
   mutable Mutex mMutex;
 
   /// The data in this SourceBuffer, stored as a series of Chunks.
-  FallibleTArray<Chunk> mChunks;
+  AutoTArray<Chunk, 1> mChunks;
 
   /// Consumers which are waiting to be notified when new data is available.
   nsTArray<RefPtr<IResumable>> mWaitingConsumers;
 
   /// If present, marks this SourceBuffer complete with the given final status.
   Maybe<nsresult> mStatus;
 
   /// Count of active consumers.