DescriptionDo not consolidate data in BMPImageDecoder
In BMPImageDecoder, never call SharedBuffer::data(), which potentially
copies all the data. Instead, do the following:
- Read directly from the SharedBuffer when it is safe to do so. e.g.
when only one byte is needed. We already know there is enough data,
and getSomeData will return at least a byte if there is enough data.
- Use a FastSharedBufferReader when we may be on a segment boundary.
As a result, we make fewer copies when decoding BMPs. We never call
SharedBuffer::data(), which copies up to the entire encoded data
received so far. Occasionally we will make small copies when a two or
four byte number is on a segment boundary.
Add a setter to FastSharedBufferReader to update its SharedBuffer, so the
BMPImageReader can have one as a member, which it will reuse across calls.
Remove BIG_ENDIAN, and eliminate another memcpy that was there to support
it.
Using my modified version of ImageDecodeBench (see crrev.com/1145373003),
I see a slight speedup as compared to the old version which relied on
SharedBuffer::data(). (My data can be found here: [1].) This matches my
expectations, since the new version is copying less data.
Using a version of ImageDecodeBench with a premerged buffer (see
crrev.com/1318713005), I still see a speed improvement, although it is
very small. (See sheet 2 of the above spreadsheet).
[1] https://docs.google.com/a/google.com/spreadsheets/d/1GN2FDytKvkdZzV-WF4IEQaYQF65wa4bRxG67bNgpjAE/edit?usp=sharing
BUG=467772
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=201811
Patch Set 1 #Patch Set 2 : Remove some comments. #Patch Set 3 : Read exactly the amount needed in getConsecutiveData #
Total comments: 14
Patch Set 4 : Make FastSharedBufferReader a member #
Total comments: 18
Patch Set 5 : Respond to Peter's comments in patch set 4 #
Total comments: 2
Patch Set 6 : getByte -> readUint8 #Patch Set 7 : Consistent inlining #
Total comments: 1
Patch Set 8 : Fix a comment #Patch Set 9 : Do not use a raw pointer #
Depends on Patchset: Dependent Patchsets: Messages
Total messages: 17 (4 generated)
|