Commit efb7a90
timers: optimize
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()
- save the arguments and do not build closures for the callbacks
PR-URL: #6436
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>setImmediate()
1 parent a5d8945 commit efb7a90Copy full SHA for efb7a90
File tree
Expand file treeCollapse file tree
4 files changed
+56
-35
lines changedOpen diff view settings
Filter options
- lib
- internal
- test/parallel
Expand file treeCollapse file tree
4 files changed
+56
-35
lines changedOpen diff view settings
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
8 | 8 | |
9 | 9 | |
10 | 10 | |
11 | | - |
| 11 | + |
12 | 12 | |
13 | 13 | |
14 | 14 | |
|
Collapse file
+47-32Lines changed: 47 additions & 32 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
506 | 506 | |
507 | 507 | |
508 | 508 | |
509 | | - |
| 509 | + |
510 | 510 | |
511 | 511 | |
512 | 512 | |
| ||
515 | 515 | |
516 | 516 | |
517 | 517 | |
| 518 | + |
| 519 | + |
| 520 | + |
518 | 521 | |
519 | 522 | |
520 | 523 | |
| 524 | + |
521 | 525 | |
522 | 526 | |
523 | 527 | |
| ||
538 | 542 | |
539 | 543 | |
540 | 544 | |
541 | | - |
| 545 | + |
| 546 | + |
542 | 547 | |
543 | 548 | |
544 | 549 | |
| ||
552 | 557 | |
553 | 558 | |
554 | 559 | |
| 560 | + |
| 561 | + |
| 562 | + |
| 563 | + |
| 564 | + |
| 565 | + |
| 566 | + |
| 567 | + |
| 568 | + |
| 569 | + |
| 570 | + |
| 571 | + |
| 572 | + |
| 573 | + |
| 574 | + |
| 575 | + |
| 576 | + |
| 577 | + |
555 | 578 | |
556 | | - |
557 | | - |
558 | | - |
559 | | - |
560 | | - |
561 | | - |
562 | 579 | |
| 580 | + |
| 581 | + |
| 582 | + |
| 583 | + |
| 584 | + |
| 585 | + |
| 586 | + |
| 587 | + |
| 588 | + |
| 589 | + |
563 | 590 | |
564 | 591 | |
565 | 592 | |
566 | 593 | |
567 | 594 | |
568 | 595 | |
569 | 596 | |
570 | | - |
571 | | - |
572 | | - |
573 | | - |
574 | 597 | |
575 | | - |
| 598 | + |
576 | 599 | |
577 | 600 | |
578 | 601 | |
579 | | - |
580 | 602 | |
581 | 603 | |
582 | | - |
583 | | - |
584 | | - |
| 604 | + |
585 | 605 | |
586 | 606 | |
587 | | - |
588 | | - |
589 | | - |
| 607 | + |
590 | 608 | |
591 | 609 | |
592 | | - |
593 | | - |
594 | | - |
| 610 | + |
595 | 611 | |
596 | 612 | |
597 | 613 | |
598 | | - |
599 | | - |
| 614 | + |
| 615 | + |
| 616 | + |
600 | 617 | |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | 618 | |
606 | 619 | |
| 620 | + |
| 621 | + |
| 622 | + |
| 623 | + |
| 624 | + |
607 | 625 | |
608 | 626 | |
609 | 627 | |
610 | 628 | |
611 | 629 | |
612 | 630 | |
613 | | - |
614 | | - |
615 | | - |
616 | 631 | |
617 | 632 | |
618 | 633 | |
|
Collapse file
test/parallel/test-timers-immediate.js
Copy file name to clipboardExpand all lines: test/parallel/test-timers-immediate.js+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
5 | 5 | |
6 | 6 | |
7 | 7 | |
| 8 | + |
8 | 9 | |
9 | 10 | |
10 | 11 | |
| ||
25 | 26 | |
26 | 27 | |
27 | 28 | |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
28 | 33 | |
29 | 34 | |
30 | 35 | |
31 | 36 | |
| 37 | + |
32 | 38 | |
Collapse file
test/parallel/test-timers-linked-list.js
Copy file name to clipboardExpand all lines: test/parallel/test-timers-linked-list.js+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
103 | 103 | |
104 | 104 | |
105 | 105 | |
106 | | - |
107 | | - |
| 106 | + |
| 107 | + |
108 | 108 | |
109 | 109 | |
110 | 110 | |
0 commit comments