18 Nov 2014

Parallel image decoding implementation


1 Abstract
Drawing ideas from previous work on parallel image decoders, we present a new parallel image decoders design and implementation in which multiple images are decoded concurrently. 
2 Introduction
The current implementation of WebKit decodes images on the main thread. When image data is received from network, it is accumulated in a buffer. Later, when WebKit needs to paint an image or retrieve frame data, it synchronously decodes the image from the accumulated buffer.
If we make image decoding off the main thread, the main thread can spend more time in loading, parsing, scripting and layout while image decoding threads decode images in the background.
Zoltan Horvath proposed a design and implementation of parallel image decoders in Bug 69515 - [Qt] Parallel imagedecoders (https://bugs.webkit.org/show_bug.cgi?id=69515). Zoltan’s work is limited in that it render images only when the whole image is decoded. Also it used a dedicated worker instead of thread pools, so it could utilize only one additional core. His experiments show that the implementation suffers from severe performance regression in page load tests (Methanol run with 24 locally mirrored sites from Alexa top 100).
Our implementation resolved the several issues of the previous work. First, we render images while images are being decoded. This behaviour matches the current sequential image decoding implementation. Second, we used a pool of worker threads instead of a dedicated worker, so that we can decode multiple images simultaneously and fully utilize multi-cores. Third, we avoid the locking overhead as much as possible by copying raw data to and from the decoder thread. When we decode image in the main thread (e.g., when the image size is small), we avoid the locking overhead entirely. Fourth, we passed all the layout tests. We have no conformance regression regarding image decoding.




No comments:

Post a Comment