Most actual calls to "new" and "delete" will be happening in V8, and I 
would assume they already make heavy use of memory pools and similar 
methods.

On the Javascript side as well, doing pooling can go a long way to 
improving performance and reduce the amount of time spent in object 
initialization and the garbage collector.  Especially with objects like 
what backs the Buffer class, where allocating one of those in Javascript 
requires jumping into native code, using pooling can help tremendously 
(and, in fact, Node's Buffer objects are relatively light-weight wrapper 
objects around a pool of SlowBuffer objects, so this is already happening).

In previous projects we've found pooling to greatly help when we had an 
object with native components (such as a large Buffer, or custom native 
classes), and also found it to help even with pure-JS objects which did any 
significant setup/allocations in their constructors.  If you're making 
thousands of some kind of objects a second, then it may benefit from being 
pooled so that it is not constantly generating garbage.  However, the 
generational garbage collector in V8 is a complicated and finicky beast and 
this can have adverse effects as well, since these pooled objects and the 
things they reference will be in "old" generations which are not garbage 
collected as efficiently and could slow down overall performance.  It's 
hard to know whether or not pooling will actually speed up a given 
situation, so the only thing to do is, if it seems like something is 
generating a lot of garbage, try adding pooling and measure how the overall 
application performance changes (due to the nature of the garbage 
collector, the performance increase/decrease will likely show up in 
unrelated parts of the application, so just profiling the changed code will 
not be as accurate as measuring the entire application's performance).

  Jimb Esser

On Sunday, June 28, 2015 at 9:55:06 AM UTC-7, Manjula Peiris wrote:
>
> Hi,
>
> I am currently checking whether we can improve the Node.js runtime 
> (server) performance by reducing the number of calls to "new" and "delete" 
> to allocate/deallocate dynamic memory. For example I am looking for 
> something similar to memory pools used in Apache HTTPD (
> http://www.apachetutor.org/dev/pools). If you have any pointers please 
> let me know.
>
> Thanks,
> Manjula.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/589b7ddc-6a68-47a9-95ab-11489c9b40dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to