On Tue, Nov 19, 2013 at 9:00 PM, Trevor Norris <[email protected]>wrote:
> On Tuesday, November 19, 2013 2:04:45 AM UTC-8, Dmitry Lomov wrote: >> >> Here is the change: https://code.google.com/p/v8/source/detail?r=15205 >> Instead of weak handles, I taught our GC to free array buffer backing >> store when array buffers die. >> > > That's awesome. Something like that is exactly what I originally wanted as > an extension of Object::SetIndexedPropertiesToExternalArrayData() where a > user could pass in a fourth optional bool that told the Object to > automatically clean up the attached external memory when the Object was > GC'd. > Note that this is not so easy. V8's GC does not visit garbage; therefore there is a special machinery in place to visit dying ArrayBuffers (all ArrayBuffers are in a weak list, which requires a special in-object field and GC additional GC machinery to maintain them) > > Oh well. Not like it matters much now. :) > > >> Off the top of my head, this smells like GC kicking in, although it does >> not explain why this is not reproducible with a native callback below. Can >> you share code for these benchmarks? >> > > Sure. It's pretty basic: > > var ITER = 1e6; > var SIZE = 16 * 1024; > // This size runs over 4x faster in Node > //var SIZE = 32 * 1024; > var t = -Date.now(); > > for (var i = 0; i < ITER; i++) { > new Uint8Array(SIZE); > } > > t += Date.now(); > > console.log((t * 1e6 / ITER).toFixed(1)); > > I can't exhibit the same problem in d8 that exists in Node. But in Node on > my machine the 16KB allocations run in ~1800ns/op while the 32KB > allocations run in ~500ns/op. Here's Node's ArrayBuffer::Allocator > implementation: http://git.io/bK_aAA > > Also, I was incorrect. The issue does still occur if called using the C++ > API. Testing your hypothesis about GC I ran the tests using --prof and got > the following: > > 16KB size: > > [GC]: > ticks total nonlib name > 536 29.1% > > 32KB size: > > [GC]: > ticks total nonlib name > 224 46.9% > > Here are the full logs for both runs: > https://gist.github.com/trevnorris/7551538 > > Let me know if there's any other information that would be helpful. :) > > -- > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
