Bug 119671 - FEComponentTransfer could be faster
Summary: FEComponentTransfer could be faster
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P4 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-12 00:15 PDT by Jinwoo Jeong
Modified: 2013-08-14 00:48 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.67 KB, patch)
2013-08-12 01:01 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (2.22 KB, patch)
2013-08-12 18:59 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (2.28 KB, patch)
2013-08-12 23:54 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff
Patch (2.33 KB, patch)
2013-08-13 00:06 PDT, Jinwoo Jeong
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jinwoo Jeong 2013-08-12 00:15:11 PDT
Change using SET method to direct accessing.
Comment 1 Jinwoo Jeong 2013-08-12 01:01:02 PDT
Created attachment 208515 [details]
Patch
Comment 2 Jinwoo Jeong 2013-08-12 01:14:21 PDT
In this case, the type of pixelArray->data() is unsigned char.
It means we can avoid calling of SET function.

And I measured the spent time of before and after patching when visit http://www.w3.org/TR/filter-effects/examples/feComponentTransfer.svg.

Before adopting this patch, the function spent 190(ms).
After patching, it spent only 35(ms).
So this could reduce 80% of spent time.

Below is about testing environment.
OS: Ubuntu 12.04 64bit
CPU: Intel Core i7-3770 CPU @ 3.40GHz
Memory: 8,123,696 kB
Comment 3 Chris Dumez 2013-08-12 10:46:42 PDT
Comment on attachment 208515 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=208515&action=review

> Source/WebCore/ChangeLog:7
> +

Missing changelog. Please explain what you did and why it is better / faster.

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:-171
> -            unsigned char c = pixelArray->item(pixelOffset + channel);

Removing the char variable reduces the readability a bit IMHO.
Comment 4 Dean Jackson 2013-08-12 12:57:19 PDT
Comment on attachment 208515 [details]
Patch

+1 to Christophe's review.
Comment 5 Jinwoo Jeong 2013-08-12 18:59:24 PDT
Created attachment 208582 [details]
Patch
Comment 6 Jinwoo Jeong 2013-08-12 19:03:36 PDT
Ok, I inserted some comment in ChangeLog.
But the code that you checked is the deletion part of my changes.
Comment 7 Chris Dumez 2013-08-12 22:53:35 PDT
(In reply to comment #6)
> Ok, I inserted some comment in ChangeLog.
> But the code that you checked is the deletion part of my changes.

Does keeping the 'char c' local variable really affect performance when building in release with -O2 or -O3? This would be surprising. What makes your code really faster is avoiding the call to set() and therefore skipping data validation (since you already know the data is fine).
Comment 8 Chris Dumez 2013-08-12 22:57:10 PDT
Comment on attachment 208582 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=208582&action=review

The change looks good overall.

> Source/WebCore/ChangeLog:8
> +        Use direct writing to target data instead of calling SET function.

SET -> Uint8ClampedArray::set()

> Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp:-171
> -            unsigned char c = pixelArray->item(pixelOffset + channel);

could we maybe keep "unsigned char c = data[pixelOffset + channel];" just to improve readability a bit. It shouldn't affect performance but let me know if I'm wrong.
Comment 9 Jinwoo Jeong 2013-08-12 23:54:58 PDT
Created attachment 208600 [details]
Patch
Comment 10 Chris Dumez 2013-08-12 23:59:12 PDT
Comment on attachment 208600 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=208600&action=review

> Source/WebCore/ChangeLog:11
> +        The SET function has index checking code, value checking code and value casting code.

nit: Please update other uses of SET in the changelog as well

> Source/WebCore/ChangeLog:14
> +        Thus all works in SET function is duplicated.

duplicated -> redundant

> Source/WebCore/ChangeLog:15
> +        So deletion of calling SET function do not reduce stability, but improve the performance.

Removing the call to set() does not reduce stability but improves performance.
Comment 11 Jinwoo Jeong 2013-08-13 00:06:37 PDT
Created attachment 208601 [details]
Patch
Comment 12 Chris Dumez 2013-08-13 00:18:15 PDT
Comment on attachment 208601 [details]
Patch

Looks good, thanks. r=me but please let Dean take a final look before landing as he was reviewing this as well.
Comment 13 Jinwoo Jeong 2013-08-13 00:49:04 PDT
CC'ing Dean, could you take a final look ? I would land this patch :)
Comment 14 Jinwoo Jeong 2013-08-13 17:42:15 PDT
Dean, if you don't have time to review this patch until tonight, I will ask another committer for landing this patch.
Comment 15 Dirk Schulze 2013-08-14 00:24:36 PDT
Comment on attachment 208601 [details]
Patch

(In reply to comment #14)
> Dean, if you don't have time to review this patch until tonight, I will ask another committer for landing this patch.

Looks good.
Comment 16 WebKit Commit Bot 2013-08-14 00:48:18 PDT
Comment on attachment 208601 [details]
Patch

Clearing flags on attachment: 208601

Committed r154042: <http://trac.webkit.org/changeset/154042>
Comment 17 WebKit Commit Bot 2013-08-14 00:48:21 PDT
All reviewed patches have been landed.  Closing bug.