On Sat, Aug 17, 2013 at 9:27 PM, Laurent Fortin <[email protected]> wrote: > Hi, > > Let's say I want to boost the SlowBuffer size like this: > > // set to 1 Mb > Buffer.poolSize = 1024 * 1024; > > Is it a good practice for boosting performance, if there is lots of memory > available?
The answer to that question is 'definitely maybe'. Or maybe 'sometimes'. Or possibly 'it depends'. Performance vs. memory consumption is a rather intricate issue with a lot of variables. The best answer I can give you is 'benchmark your application and see for yourself'. That said, recent-ish Linux kernels have a feature called 'transparent huge pages'[1] that - in theory - lets you cut down on the number of page faults if you allocate memory in 4 MB chunks (PAE-enabled systems also allow 2 MB chunks.) I've tested it extensively in the past and yes, it does shave off a few percent from our (admittedly somewhat contrived) benchmarks. I've toyed with the idea of changing the pool size to 4 MB but the downside is that you potentially cling on to a lot more memory that way. Imagine that you create a new SlowBuffer, slice off a single-byte normal Buffer and store a reference to that one-byte buffer somewhere - that prevents the entire SlowBuffer from being reclaimed by the garbage collector. That pattern is more common than you might expect. Many websocket frameworks work this way. Last but not least, while transparent huge pages can reduce the number of page faults in your application, the page faults it does incur are massively more expensive now. Instead of having to swap in 4 kB from persistent storage, it now has to swap in 4 MB. Ergo, YMMV. [1] http://lwn.net/Articles/423584/ -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: 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 post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
