c++ - How can I maintain zero-copy in a native node module? -


i'm writing native node module in-process database features zero-copy data lookups. i'd module have ability. in other words, when data database, i'd pass data v8 without need copy memory or need parse something.

how can this?

so far, ways have seen involved either parsing , forth between json (pretty waste of resources in case) or instantiating v8 data structures , copying data them.

note: in case wondering, zero-copy data lookup means (in nutshell) database engine not need copy memory when retrieves data.

i think found solution, although rather limited.

interesting documentation can found here: https://developers.google.com/v8/ (overview) , http://izs.me/v8-docs/main.html (api docs)

seems v8 has externalstringresource class can used purpose:
http://izs.me/v8-docs/classv8_1_1string_1_1externalstringresource.html

node has buffer class can used similar ends:
http://nodejs.org/api/buffer.html

by using above 2 classes, possible implement zero-copy in native node module strings , byte arrays. unfortunately seems (at time i'm writing this) isn't possible objects.

edit

in case okay having zero-copy ability string or buffer properties of object (but not whole object itself), can implemented using interceptors or accessors in v8 api.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -