diff --git a/CHANGES.md b/CHANGES.md index 91f0271afb..805ed3965b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,8 +3,10 @@ ## Features/Changes * Misc: update testsuite to OCmaml 5.2 * Misc: CI uses opam.2.2 and no longer use sunset repo -* Runtime: change Sys.os_type on windows (Cygwin -> Win32) * Compiler: speedup global_flow/global_deadcode pass on large bytecode +* Runtime: change Sys.os_type on windows (Cygwin -> Win32) +* Runtime: backtraces are really expensive, they need to be be explicitly + requested at compile time (--enable with-js-error) or at startup (OCAMLRUNPARAM=b=1) ## Bug fixes * Runtime: fix parsing of unsigned integers (0u2147483648) diff --git a/runtime/jslib.js b/runtime/jslib.js index 54ba52d344..23e5a1a994 100644 --- a/runtime/jslib.js +++ b/runtime/jslib.js @@ -164,6 +164,10 @@ function caml_wrap_exception(e) { //Requires: caml_record_backtrace_env_flag //Requires: caml_record_backtrace_runtime_flag function caml_maybe_attach_backtrace(exn, force) { + // Backtraces are very expensive, we only enable them when explicitly requested + // at compile-time (--enable with-js-error) or at startup with OCAMLRUNPARAM=b=1. + // Libraries such as Base unconditionally enable backtraces (programmatically) but + // it's way to slow. Here, we force the end-user to opt-in to backtraces. if(caml_record_backtrace_env_flag && caml_record_backtrace_runtime_flag) return caml_exn_with_js_backtrace(exn, force); else return exn