Message from discussion
Array reads faster than Buffer reads ???
Received: by 10.66.81.39 with SMTP id w7mr1636564pax.1.1349367570412;
Thu, 04 Oct 2012 09:19:30 -0700 (PDT)
X-BeenThere: nodejs@googlegroups.com
Received: by 10.68.242.38 with SMTP id wn6ls11201129pbc.8.gmail; Thu, 04 Oct
2012 09:19:20 -0700 (PDT)
Received: by 10.68.242.74 with SMTP id wo10mr2450919pbc.9.1349367560392;
Thu, 04 Oct 2012 09:19:20 -0700 (PDT)
Date: Thu, 4 Oct 2012 09:19:19 -0700 (PDT)
From: Jimb Esser <wastel...@gmail.com>
To: nodejs@googlegroups.com
Message-Id: <b8450b3e-5fcc-43d2-9c32-69a11781ca7f@googlegroups.com>
In-Reply-To: <266d7086-65e8-4fb7-9531-83a954580bbd@googlegroups.com>
References: <b10a992e-a24e-4d7c-b4ca-09647d7353df@googlegroups.com>
<CAHQurc91c1xBw8O7xssgOrrjBHOzKuwi0ukcFp0cvS3t5r4Zgw@mail.gmail.com>
<f7479d4a-b0f2-4638-a03a-608614e4ea96@googlegroups.com>
<CAHQurc9MMvmrbNMhMSBxK6n3AG0ejSp8ehX+PFE=3ZxFs-fQAA@mail.gmail.com>
<266d7086-65e8-4fb7-9531-83a954580bbd@googlegroups.com>
Subject: Re: [nodejs] Array reads faster than Buffer reads ???
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_2449_18070263.1349367559942"
------=_Part_2449_18070263.1349367559942
Content-Type: multipart/alternative;
boundary="----=_Part_2450_5762632.1349367559942"
------=_Part_2450_5762632.1349367559942
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
If you want *really* fast buffer access for larger integer types and float
types, you can set up a native module that
calls SetIndexedPropertiesToExternalArrayData a few times on your Buffer
and gives you a native indexed view into the buffer for whatever primitive
type you want to read (much, much, much faster than trying to read a float
byte-by-byte and assemble it). We do this in our internal networking
buffers, and got quite a speed-up compared to combining bytes in JS (though
either are *way* faster than calling into native methods to do the read,
except maybe with floats). Note: for un-aligned reads (e.g. reading a
64-bit float from 3 bytes within a buffer), I think this only works on some
platforms, but those platforms include x86 and x64, which is all we care
about in our case.
Jimb Esser
Cloud Party
On Wednesday, October 3, 2012 5:38:38 PM UTC-7, NodeNinja wrote:
>
>
>
> On Thursday, October 4, 2012 5:44:16 AM UTC+5:30, Ben Noordhuis wrote:
>>
>> They won't, they're there mostly for convenience*.
>>
>
> Now that's an* eye opener* Ben!
> I hope that line finds its way to the documentation.
> Many thanks!!
>
>
>
>
------=_Part_2450_5762632.1349367559942
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
If you want *really* fast buffer access for larger integer types and float =
types, you can set up a native module that calls SetIndexedPropertiesT=
oExternalArrayData a few times on your Buffer and gives you a native indexe=
d view into the buffer for whatever primitive type you want to read (much, =
much, much faster than trying to read a float byte-by-byte and assemble it)=
. We do this in our internal networking buffers, and got quite a spee=
d-up compared to combining bytes in JS (though either are *way* faster than=
calling into native methods to do the read, except maybe with floats). &nb=
sp;Note: for un-aligned reads (e.g. reading a 64-bit float from 3 bytes wit=
hin a buffer), I think this only works on some platforms, but those platfor=
ms include x86 and x64, which is all we care about in our case.<div><br></d=
iv><div> Jimb Esser</div><div> Cloud Party<br><br>On Wednesday,=
October 3, 2012 5:38:38 PM UTC-7, NodeNinja wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid=
;padding-left: 1ex;"><br><br>On Thursday, October 4, 2012 5:44:16 AM UTC+5:=
30, Ben Noordhuis wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0=
;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">They won't,=
they're there mostly for convenience*.<br></blockquote><div><br></div><div=
>Now that's an<b> eye opener</b> Ben!</div><div>I hope that line finds its =
way to the documentation.</div><div>Many thanks!!</div><div><br></div><div>=
<br></div><div><br></div></blockquote></div>
------=_Part_2450_5762632.1349367559942--
------=_Part_2449_18070263.1349367559942--