Commit 4562805
build: speed up compilation of mksnapshot output
Incremental compilation of Node.js is slow. Currently on a powerful
Linux machine, it takes about 5.8 seconds to compile
`gen/node_snapshot.cc` with g++.
As in the previous PR which dealt with `node_js2c`, we add a new build
define `NODE_MKSNAPSHOT_USE_STRING_LITERALS` which is used by
`node_mksnapshot`. When this flag is set, we emit string literals
instead of array literals for the snapshot blob and for the code cache,
i.e.:
```c++
// old: static const uint8_t X[] = { ... };
static const uint8_t *X = "...";
```
I only enabled the new flag on Linux/macOS, since those are systems that
I have available for testing. On my Linux system with gcc, it speeds up
compilation of this file by 3.7s (5.8s -> 2.1s). On my Mac system with
clang, it speeds up compilation by 1.7s (3.4s -> 1.7s).
Again, the right thing here is probably to generate separate files for
the snapshot blob and for each code cache output, but this is a nice
intermediate speedup.
Refs: #47984
Refs: #48160
PR-URL: #48162
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>1 parent 9875885 commit 4562805
2 files changed
+67
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
872 | 872 | | |
873 | 873 | | |
874 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
875 | 878 | | |
876 | 879 | | |
877 | 880 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
745 | | - | |
746 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
747 | 782 | | |
748 | 783 | | |
749 | | - | |
| 784 | + | |
750 | 785 | | |
| 786 | + | |
751 | 787 | | |
752 | | - | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
753 | 791 | | |
754 | 792 | | |
755 | 793 | | |
756 | | - | |
| 794 | + | |
757 | 795 | | |
758 | 796 | | |
759 | 797 | | |
| |||
767 | 805 | | |
768 | 806 | | |
769 | 807 | | |
770 | | - | |
771 | | - | |
772 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
773 | 819 | | |
774 | 820 | | |
775 | 821 | | |
776 | | - | |
| 822 | + | |
| 823 | + | |
777 | 824 | | |
778 | | - | |
| 825 | + | |
779 | 826 | | |
780 | 827 | | |
781 | | - | |
782 | | - | |
783 | 828 | | |
784 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
785 | 836 | | |
786 | 837 | | |
787 | 838 | | |
| |||
808 | 859 | | |
809 | 860 | | |
810 | 861 | | |
811 | | - | |
| 862 | + | |
812 | 863 | | |
813 | 864 | | |
814 | 865 | | |
| |||
0 commit comments