Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3x faster setImmediate #6436

Closed
wants to merge 12 commits into from
Closed

Commits on Apr 28, 2016

  1. timers: linkedlist optimizations

    use L.create() factory to create access-optimized linkedlist objects
    Andras committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    44243ad View commit details
    Browse the repository at this point in the history
  2. timers: 3x faster setImmediate

    Save the setImmediate callback arguments into an array instead of a
    closure, and invoke the callback on the arguments from an optimizable
    function.
    
      60% faster setImmediate with 0 args (15% if self-recursive)
      4x faster setImmediate with 1-3 args, 2x with > 3
      seems to be faster with less memory pressure when memory is tight
    
    Changes:
    - use L.create() to build faster lists
    - use runCallback() from within tryOnImmediate
    - create immediate timers with a function instead of new
    - just save the arguments and not build closures for the callbacks
    Andras committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    d005b81 View commit details
    Browse the repository at this point in the history
  3. timers: 3x faster clearImmediate

    Instead of unlinking from the immediate queue immediate on clear,
    put off the unlink until processImmediate where it's more efficient.
    
      3x faster clearImmediate processing
    
      The the benefits stack with the setImmediate speedups, ie total gain
      of 3.5x with 0 arguments and 4-5x with 1-3 args.
    
    Changed the code to defer unlinking from the immediate queue until
    processImmediate consumes the queue anyway.
    Andras committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    ad3bcb8 View commit details
    Browse the repository at this point in the history
  4. timers: setImmediate benchmarks

    Timings for sequential and concurren setImmediate with and without
    arguments, and set + clearImmediate.
    Andras committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    1f82a29 View commit details
    Browse the repository at this point in the history
  5. timers: code review edits

    Andras committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    49b2611 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c12ba47 View commit details
    Browse the repository at this point in the history

Commits on Apr 29, 2016

  1. timers: code review edits

    Andras committed Apr 29, 2016
    Configuration menu
    Copy the full SHA
    6dcbd83 View commit details
    Browse the repository at this point in the history

Commits on May 1, 2016

  1. Configuration menu
    Copy the full SHA
    197aac2 View commit details
    Browse the repository at this point in the history

Commits on May 2, 2016

  1. timers: speed up another 2x setImmediate() with > 3 args

      220% faster yet setImmediate with 4 args,
      240% with 5,
      260% with 6
    
    Changed the code to copy arguments into a dynamically extended array
    instead of preallocating the exact size.  It seems f.apply(obj, args)
    runs much faster in node v6 if the args array was extended at run-time
    as opposed to preallocated the correct size.
    
    This behavior is new in node v6.0.0; v5.10.1 was 4x faster to apply an
    args array created the exact size.  (Node v5 and v4 were the other way
    around, faster to .apply static sized arrays, and slower if dynamically
    grown.)
    
        // faster to copy args, but v6 slow to .apply them:
        var argv = new Array(arguments.length - 1);   // exact size
        for (var i = 1; i < arguments.length; i++)
          argv[i - 1] = arguments[i];
    
        // slower to copy args, but v6 much faster to .apply them:
        var argv = new Array();                       // grow as needed
        for (var i = 1; i < arguments.length; i++)
          argv[i - 1] = arguments[i];
    Andras committed May 2, 2016
    Configuration menu
    Copy the full SHA
    4b54cd7 View commit details
    Browse the repository at this point in the history

Commits on May 6, 2016

  1. timers: code review edits

    Andras committed May 6, 2016
    Configuration menu
    Copy the full SHA
    8179d32 View commit details
    Browse the repository at this point in the history
  2. timers: code review edits

    Andras committed May 6, 2016
    Configuration menu
    Copy the full SHA
    77e0443 View commit details
    Browse the repository at this point in the history

Commits on May 7, 2016

  1. Configuration menu
    Copy the full SHA
    0e75f1f View commit details
    Browse the repository at this point in the history