Hi Ben, thanks for your reply. Somehow I didn't get the notification for it. I've enabled logging and found that it's MarkSweepCompact that's taking long. In each nodejs process in the past one hour, MarkSweepCompact occurs almost exactly once per minute. About 1/3 of them take longer than 100ms. Because my project is a service to other internal nodejs apps, a request that takes more than 100ms to finish returns ETIMEDOUT on client side. I'm willing to sacrifice average response time a bit to reduce max response time. Can I reduce max_old_space_size to make MarkSweepCompact run more often but quicker each time?
Thanks On Sunday, February 21, 2016 at 6:25:19 AM UTC-8, Ben Noordhuis wrote: > > On Sat, Feb 20, 2016 at 7:37 PM, Haitao Li <[email protected] <javascript:>> > wrote: > > I have a node.js app with dependencies on 50+ modules. A worker process > > consumes about 1G memory, as shown in RES column of "top" command > output. > > CPU load is light. Ever since I upgraded node.js from 0.10 to 4.2.3, I > > noticed the response time increased quite a bit. I can't totally blame > > nodejs because I also upgraded a few modules with it. Most requests are > > completed within 100ms, but a fraction of them can take more than 300ms. > > During the first couple of hours after server starts, everything looks > > normal. Then delays start to occur at different places. That makes me > > believe it's related to memory usage. CPU profiling didn't reveal > anything > > interesting. > > > > > > Questions: > > > > 1. Can GC cause delays of more than 100ms? > > Yes, it can. Run with `--trace_gc` (and perhaps `--trace_gc_verbose`) > to find out if that happens. It prints collection times to stdout. > > > 2. How do I find out what objects are allocated for processing one > request? > > If there is a way to disable gc, then I can take snapshots before and > after > > the request to compare. But if gc kicks in during that process I lose > track > > of what were allocated then subsequently released by gc. > > There is no way to completely disable the garbage collector but you > can (indirectly) tweak its frequency through the > `--max_semi_space_size=<mb>` and `--min_semi_space_size=<mb>` flags > (and, to some extent, `--max_old_space_size=<mb>` too.) A larger new > space means fewer minor garbage collection cycles. > > If you combine that with `--expose_gc` and call gc() at opportune > times, you have some influence on when the garbage collector runs. > Hope that helps! > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/d5c9fba2-ef41-44c4-9bfb-9601c20a64b0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
