]> git.kaiwu.me - njs.git/commit
Make Error.stack faster.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 29 Jan 2026 02:36:39 +0000 (18:36 -0800)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 5 Feb 2026 23:32:12 +0000 (15:32 -0800)
commit869876c43b45e8c45d251630e4052e86daafbaf4
tree622d7fde66b8f93b846aa1454a94ee93fe03e714
parent4edef59f796f3af4601034cbe4adc9c38300123e
Make Error.stack faster.

Previously, error.stack reported full names for native function (for
example Array.prototype.map -> map), but it was achieved by iteration
through a global object which is slow.

The fix is to report only function name at hand, this loses a bit
of verbosity but make it ~100 times faster.

make benchmark
before
        ...
exception.stack: 38.421µs, 26027 times/s
exception.native.stack: 226.711µs, 4410 times/s
after
        ...
exception.stack: 1.239µs, 807356 times/s
exception.native.stack: 2.419µs, 413339 times/s
src/njs_builtin.c
src/njs_error.c
src/njs_function.c
src/njs_vm.h
src/test/njs_benchmark.c
src/test/njs_unit_test.c
test/shell_test_njs.exp