FAQ
I've been profiling my code and the most expensive function reported
is the C++ function _chmod. It appears about 4 times as often as my
most expensive Javascript function.

My program doesn't use the filesystem. It's very simple. It prints
one line to the console and only has 2 "require" calls that aren't my
code: underscore, and EventEmitter2 (require("events") exhibits the
same problem).

I've done some grepping through node and its dependencies, and I'm
scratching my head. _chmod is apparently called by many functions and
I don't see anything in common between them.

Is this an internal node.js thing? Is it anything to be concerned
about or is there anything I can do to prevent it? Any insight would
be greatly appreciated.

Thanks!

Example:

499 8.8% _chmod
69 13.8% LazyCompile: *Player.draw /my/project/path/
player.js:192
38 55.1% Function: Player.doCleanup /my/project/path/
player.js:119
36 94.7% LazyCompile: *Player.doPlay /my/project/path/
player.js:99
36 100.0% LazyCompile: *Player.onPlayChosen /my/project/
path/player.js:168
36 100.0% LazyCompile: *EventEmitter.emit /my/project/
path/node_modules/eventemitter2/lib/eventemitter2.js:242

Player.draw /my/project/path/player.js:192 is as follows

Player.prototype.draw = function(n) {
var card, drawn, _i, _len;
drawn = this.take(n);
for (_i = 0, _len = drawn.length; _i < _len; _i++) {
card = drawn[_i];
this.hand[card.id] = card;
}
return drawn;
};

this.take(n) returns an array. this.hand is an object initialized
using curly brackets. card.id is an integer.

--
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

  • Ben Noordhuis at Mar 16, 2012 at 9:42 pm

    On Fri, Mar 16, 2012 at 19:57, Patrick Quinn wrote:
    I've been profiling my code and the most expensive function reported
    is the C++ function _chmod.  It appears about 4 times as often as my
    most expensive Javascript function.

    My program doesn't use the filesystem.  It's very simple.  It prints
    one line to the console and only has 2 "require" calls that aren't my
    code: underscore, and EventEmitter2 (require("events") exhibits the
    same problem).

    I've done some grepping through node and its dependencies, and I'm
    scratching my head.  _chmod is apparently called by many functions and
    I don't see anything in common between them.

    Is this an internal node.js thing?  Is it anything to be concerned
    about or is there anything I can do to prevent it?  Any insight would
    be greatly appreciated.

    Thanks!

    Example:

    499    8.8%  _chmod
    69   13.8%    LazyCompile: *Player.draw /my/project/path/
    player.js:192
    38   55.1%      Function: Player.doCleanup /my/project/path/
    player.js:119
    36   94.7%        LazyCompile: *Player.doPlay /my/project/path/
    player.js:99
    36  100.0%          LazyCompile: *Player.onPlayChosen /my/project/
    path/player.js:168
    36  100.0%            LazyCompile: *EventEmitter.emit /my/project/
    path/node_modules/eventemitter2/lib/eventemitter2.js:242

    Player.draw /my/project/path/player.js:192 is as follows

    Player.prototype.draw = function(n) {
    var card, drawn, _i, _len;
    drawn = this.take(n);
    for (_i = 0, _len = drawn.length; _i < _len; _i++) {
    card = drawn[_i];
    this.hand[card.id] = card;
    }
    return drawn;
    };

    this.take(n) returns an array.  this.hand is an object initialized
    using curly brackets.  card.id is an integer.
    On what platform is this? _chmod looks like a function from the Windows CRT.

    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Patrick Quinn at Mar 16, 2012 at 10:36 pm
    OSX Lion
    On Friday, March 16, 2012 5:42:19 PM UTC-4, Ben Noordhuis wrote:
    On Fri, Mar 16, 2012 at 19:57, Patrick Quinn wrote:
    I've been profiling my code and the most expensive function reported
    is the C++ function _chmod. It appears about 4 times as often as my
    most expensive Javascript function.

    My program doesn't use the filesystem. It's very simple. It prints
    one line to the console and only has 2 "require" calls that aren't my
    code: underscore, and EventEmitter2 (require("events") exhibits the
    same problem).

    I've done some grepping through node and its dependencies, and I'm
    scratching my head. _chmod is apparently called by many functions and
    I don't see anything in common between them.

    Is this an internal node.js thing? Is it anything to be concerned
    about or is there anything I can do to prevent it? Any insight would
    be greatly appreciated.

    Thanks!

    Example:

    499 8.8% _chmod
    69 13.8% LazyCompile: *Player.draw /my/project/path/
    player.js:192
    38 55.1% Function: Player.doCleanup /my/project/path/
    player.js:119
    36 94.7% LazyCompile: *Player.doPlay /my/project/path/
    player.js:99
    36 100.0% LazyCompile: *Player.onPlayChosen /my/project/
    path/player.js:168
    36 100.0% LazyCompile: *EventEmitter.emit /my/project/
    path/node_modules/eventemitter2/lib/eventemitter2.js:242

    Player.draw /my/project/path/player.js:192 is as follows

    Player.prototype.draw = function(n) {
    var card, drawn, _i, _len;
    drawn = this.take(n);
    for (_i = 0, _len = drawn.length; _i < _len; _i++) {
    card = drawn[_i];
    this.hand[card.id] = card;
    }
    return drawn;
    };

    this.take(n) returns an array. this.hand is an object initialized
    using curly brackets. card.id is an integer.
    On what platform is this? _chmod looks like a function from the Windows
    CRT.
    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Ben Noordhuis at Mar 16, 2012 at 11:00 pm

    On Fri, Mar 16, 2012 at 23:36, Patrick Quinn wrote:
    OSX Lion
    Okay, can you post your full code?

    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Patrick Quinn at Mar 16, 2012 at 11:13 pm
    My full code is about 1000 lines spread over a dozen files. Is there some
    subset that would be helpful?

    The snippet above is representative of what I'm seeing in the profiler. I
    can send more snippets if that's useful. The program doesn't receive any
    user input. Its only output is a single console.log statement (and
    removing that does nothing for the problem). It doesn't open files, read
    directories, open sockets, or really do anything fancy whatsoever. It just
    loops a few thousand times simulating random hands from a card game. As I
    mentioned, the only external libraries I use are events and underscore.
    On Friday, March 16, 2012 7:00:00 PM UTC-4, Ben Noordhuis wrote:
    On Fri, Mar 16, 2012 at 23:36, Patrick Quinn wrote:
    OSX Lion
    Okay, can you post your full code?
    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Ben Noordhuis at Mar 16, 2012 at 11:26 pm

    On Sat, Mar 17, 2012 at 00:13, Patrick Quinn wrote:
    My full code is about 1000 lines spread over a dozen files.  Is there some
    subset that would be helpful?
    Principle of exclusion: if you strip your program down to the core,
    does it still happen?

    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Patrick Quinn at Mar 17, 2012 at 1:04 am
    No, it doesn't. I'm currently trying to find the problem by progressively
    rebuilding the application. While I do that... is there anything in the
    node.js runtime environment (no libraries) that could cause a program to
    spend 10%-25% of its execution time in _chmod?
    On Friday, March 16, 2012 7:26:15 PM UTC-4, Ben Noordhuis wrote:
    On Sat, Mar 17, 2012 at 00:13, Patrick Quinn wrote:
    My full code is about 1000 lines spread over a dozen files. Is there some
    subset that would be helpful?
    Principle of exclusion: if you strip your program down to the core,
    does it still happen?
    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Ben Noordhuis at Mar 17, 2012 at 1:11 am

    On Sat, Mar 17, 2012 at 02:04, Patrick Quinn wrote:
    No, it doesn't.  I'm currently trying to find the problem by progressively
    rebuilding the application.  While I do that... is there anything in the
    node.js runtime environment (no libraries) that could cause a program to
    spend 10%-25% of its execution time in _chmod?
    Not in node.js itself, the core itself doesn't touch files, it only reads them.

    Something you could try is to run your app through dtruss. It's a tool
    that logs syscalls, maybe it can tell what's getting chmod'ed.

    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Patrick Quinn at Mar 21, 2012 at 1:36 am
    Quick update: I found the problem.

    I was being a little clever with prototype inheritance. I had a master
    instance of certain objects. At the start of every game, I'd create a new
    class/function whose prototype pointed to said instance. I set up ~6 of
    these ad hoc classes per game, and I called new on them maybe 20 times. I
    figured that'd would be quick, but it ate a good chunk of my execution
    time. I'm still not sure precisely why this ended up calling _chmod, but
    altering that code sped things up and caused _chmod to drop out of the
    profile.

    Thanks for the help.
    On Friday, March 16, 2012 9:11:25 PM UTC-4, Ben Noordhuis wrote:
    On Sat, Mar 17, 2012 at 02:04, Patrick Quinn wrote:
    No, it doesn't. I'm currently trying to find the problem by
    progressively
    rebuilding the application. While I do that... is there anything in the
    node.js runtime environment (no libraries) that could cause a program to
    spend 10%-25% of its execution time in _chmod?
    Not in node.js itself, the core itself doesn't touch files, it only reads
    them.

    Something you could try is to run your app through dtruss. It's a tool
    that logs syscalls, maybe it can tell what's getting chmod'ed.
    --
    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 nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedMar 16, '12 at 9:21p
activeMar 21, '12 at 1:36a
posts9
users2
websitenodejs.org
irc#node.js

2 users in discussion

Patrick Quinn: 5 posts Ben Noordhuis: 4 posts

People

Translate

site design / logo © 2017 Grokbase