>
> I'm trying to improve some serialization code in NodeJS and was wondering
> if this could be achieved by going down to the native code and using
> multiple threads to parallelize the serialization of multiple objects. For
> example, imagine we need to serialize 1K objects to JSON/OtherFormat -
> split into 4 x 250 batches and use 4 (non-main) threads to serialize the
> objects, then gather the results and return.
>

While I understand that this is tempting, please be aware that only one
thread may be active in one Isolate at any given time. Lifting this
restriction would require huge effort, and/or only apply in limited
circumstances (e.g., when an object has a custom toJSON function, you would
have to bail out somehow, because such a function could cause arbitrary
modifications to any other object).


> However, I'm having a bit of a hard time understanding a few concepts:
>
> 1. when does the GC kick in for an Isolate? my understanding is that *any
> *V8 code executed in an Isolate can trigger GC for that Isolate  - is
> this correct?
>

Any *allocation* on the managed heap can trigger GC. Of course, when you
don't know what code you're calling (e.g., a user-provided function), then
you have to assume that it might allocate. We use DisallowHeapAllocation
scopes to guard sections where we are sure that no allocation (and hence no
GC) can happen.

2. when GC triggers, what happens to pointers that might have been
> extracted from Handle<Object> *and* the Handle is still in scope?
>
> HandleScope scope(isolate);
> Handle<Object> foo = ...
> Object* fooPtr = *foo;
> someCallThatTriggersGC()
> // is fooPtr still valid???
>

Raw pointers will become stale, no matter where they came from. So in this
example, fooPtr will be invalid; foo will still be valid (that's the point
of having Handles).

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CAKSzg3TQRFkgXD1GMGDEAYJS3RSuBW_L-AqpLq2CPc16D30O%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to