Re: [hybi] I-D Action: draft-ietf-hybi-thewebsocketprotocol-13.txt

Tobias Oberstein <tobias.oberstein@tavendo.de> Wed, 07 September 2011 15:41 UTC

Return-Path: <tobias.oberstein@tavendo.de>
X-Original-To: hybi@ietfa.amsl.com
Delivered-To: hybi@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C468621F8C3A for <hybi@ietfa.amsl.com>; Wed, 7 Sep 2011 08:41:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.507
X-Spam-Level:
X-Spam-Status: No, score=-2.507 tagged_above=-999 required=5 tests=[AWL=0.091, BAYES_00=-2.599, HTML_MESSAGE=0.001]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y45FjJ+bXpmk for <hybi@ietfa.amsl.com>; Wed, 7 Sep 2011 08:41:52 -0700 (PDT)
Received: from EXHUB020-1.exch020.serverdata.net (exhub020-1.exch020.serverdata.net [206.225.164.28]) by ietfa.amsl.com (Postfix) with ESMTP id 608CA21F8B0D for <hybi@ietf.org>; Wed, 7 Sep 2011 08:41:51 -0700 (PDT)
Received: from EXVMBX020-12.exch020.serverdata.net ([169.254.3.209]) by EXHUB020-1.exch020.serverdata.net ([206.225.164.28]) with mapi; Wed, 7 Sep 2011 08:43:41 -0700
From: Tobias Oberstein <tobias.oberstein@tavendo.de>
To: Joel Martin <hybi@martintribe.org>
Date: Wed, 07 Sep 2011 08:42:19 -0700
Thread-Topic: [hybi] I-D Action: draft-ietf-hybi-thewebsocketprotocol-13.txt
Thread-Index: Acxtc1RGh6mQ+xt6TVyFSc4ImU5B8wAALCEA
Message-ID: <634914A010D0B943A035D226786325D422C0F6D6AF@EXVMBX020-12.exch020.serverdata.net>
References: <20110831184207.1514.64093.idtracker@ietfa.amsl.com> <0fc901cc6878$1681eec0$0a00a8c0@Venus> <CAH9hSJb2rH+fX0AnekYxsEkHKzb15aHrg_hDQw1baWLiWBF-3w@mail.gmail.com> <17b501cc6d31$3016d6d0$0a00a8c0@Venus> <C2CBF8E1-ADC8-48F9-AB82-B98151A36A81@bbn.com> <634914A010D0B943A035D226786325D422C0F6D564@EXVMBX020-12.exch020.serverdata.net> <CAO228Ns7HDhRFusX7z5uGxwudp7Vj+BnE2A=Pg_oSwU4f80ExQ@mail.gmail.com>
In-Reply-To: <CAO228Ns7HDhRFusX7z5uGxwudp7Vj+BnE2A=Pg_oSwU4f80ExQ@mail.gmail.com>
Accept-Language: de-DE, en-US
Content-Language: de-DE
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: de-DE, en-US
Content-Type: multipart/alternative; boundary="_000_634914A010D0B943A035D226786325D422C0F6D6AFEXVMBX02012ex_"
MIME-Version: 1.0
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] I-D Action: draft-ietf-hybi-thewebsocketprotocol-13.txt
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 07 Sep 2011 15:41:55 -0000

yes, it's plain Python, not over strings, but bytearrays, which gives some boost.

Compared to C/C++ the whole thingy is somewhere 3x slower worst-case .. not bad, but slower.

Using NumPy is a nice tip .. I'll have a look at your code.

I've been looking at

http://stackoverflow.com/questions/2119761/simple-python-challenge-fastest-bitwise-xor-on-data-buffers

also, but did not find time yet to see if it helps.

Thanks again,
Tobias

Von: buskanaka@gmail.com [mailto:buskanaka@gmail.com] Im Auftrag von Joel Martin
Gesendet: Mittwoch, 7. September 2011 17:32
An: Tobias Oberstein
Cc: Richard L. Barnes; Len Holgate; hybi@ietf.org
Betreff: Re: [hybi] I-D Action: draft-ietf-hybi-thewebsocketprotocol-13.txt

On Wed, Sep 7, 2011 at 8:31 AM, Tobias Oberstein <tobias.oberstein@tavendo.de<mailto:tobias.oberstein@tavendo.de>> wrote:
at least for the Python/Twisted implementation I can say that - even after
quite some optimization experiments - the masking is the bottleneck.

I notice you are doing the unmasking directly using python code (https://github.com/oberstet/Autobahn/blob/master/lib/python/autobahn/websocket.py#L635). Have you tried doing the unmask by offloading it to something like numpy? If not, you might try something like this:

    numpy.bitwise_xor(data, mask)

You'll need to handle modulus 4 data (since numpy.bitwise_xor wants the data to be modulus the mask), but that's the general idea. Here is how I do it in websockify: https://github.com/kanaka/websockify/blob/6e263063c2b63642a0e17cb91d6b9f6c9365c0c0/websocket.py#L293  My main test is noVNC which doesn't send much data from client to server, but I think numpy will do the unmask significantly faster than doing the XOR in python code directly.

Regards,

Joel Martin (kanaka)