Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Issue 137833011: Use Int32x4List to optimize mask/unmask websockets. (Closed)

Created:
6 years, 10 months ago by Anders Johnsen
Modified:
6 years, 10 months ago
Reviewers:
kasperl
CC:
reviews_dartlang.org, Søren Gjesse
Visibility:
Public.

Description

Use Int32x4List to optimize mask/unmask websockets. BUG=

Patch Set 1 #

Total comments: 8

Patch Set 2 : Review update #

Unified diffs Side-by-side diffs Delta from patch set Stats (+73 lines, -21 lines) Patch
M sdk/lib/io/websocket_impl.dart View 1 3 chunks +73 lines, -21 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Anders Johnsen
6 years, 10 months ago (2014-01-29 09:20:20 UTC) #1
kasperl
LGTM! https://codereview.chromium.org/137833011/diff/1/sdk/lib/io/websocket_impl.dart File sdk/lib/io/websocket_impl.dart (right): https://codereview.chromium.org/137833011/diff/1/sdk/lib/io/websocket_impl.dart#newcode201 sdk/lib/io/websocket_impl.dart:201: void _unmask(int index, int payload, Uint8List buffer) { ...
6 years, 10 months ago (2014-01-29 09:47:37 UTC) #2
Anders Johnsen
6 years, 10 months ago (2014-01-29 10:19:04 UTC) #3
https://codereview.chromium.org/137833011/diff/1/sdk/lib/io/websocket_impl.dart
File sdk/lib/io/websocket_impl.dart (right):

https://codereview.chromium.org/137833011/diff/1/sdk/lib/io/websocket_impl.da...
sdk/lib/io/websocket_impl.dart:201: void _unmask(int index, int payload,
Uint8List buffer) {
On 2014/01/29 09:47:37, kasperl wrote:
> payload -> length

Done.

https://codereview.chromium.org/137833011/diff/1/sdk/lib/io/websocket_impl.da...
sdk/lib/io/websocket_impl.dart:203: // Start by alligning to 16 bytes.
On 2014/01/29 09:47:37, kasperl wrote:
> alligning -> aligning

Done.

https://codereview.chromium.org/137833011/diff/1/sdk/lib/io/websocket_impl.da...
sdk/lib/io/websocket_impl.dart:204: final int startOffset = min(BLOCK_SIZE -
(index & 15), payload);
On 2014/01/29 09:47:37, kasperl wrote:
> Maybe replace this whole min computation by checking if the length is less
than
> BLOCK_SIZE. If it is, you can skip the alignment part and the block handling
> part completely.

Done.

https://codereview.chromium.org/137833011/diff/1/sdk/lib/io/websocket_impl.da...
sdk/lib/io/websocket_impl.dart:215: for (int i = 3; i >= 0; i--) {
On 2014/01/29 09:47:37, kasperl wrote:
> Here's an idea: Why don't you turn masking bytes into a Uint8List and make it
> contain the following bytes:
> 
>    [ m0, m1, m2, m3,
>      m0, m1, m2, m3,
>      m0, m1, m2, m3,
>      m0, m1, m2, m3,
>      
>      m1, m2, m3, m0,
>      m1, m2, m3, m0,
>      m1, m2, m3, m0,
>      m1, m2, m3, m0,
> 
>      m2, m3, m0, m1,
>      m2, m3, m0, m1,
>      m2, m3, m0, m1,
>      m2, m3, m0, m1,
> 
>      m3, m0, m1, m2,
>      m3, m0, m1, m2,
>      m3, m0, m1, m2,
>      m3, m0, m1, m2 ]
> 
> You can fill this information in when you read the masking bytes before
calling
> maskDone(). If you create a Int32x4List view of these bytes and fetch the
block
> mask from it using:
> 
>    Int32x4 blockMask = _maskingBlocks[_unmaskingIndex];
> 
> Feel free to experiment with this in another CL.

While the idea is very cool, I'm afraid the build-overhead may be too expensive
in the case of small packages. I'll keep as is, and investigate further in
another Cl.

Powered by Google App Engine
This is Rietveld 408576698