Le 26/02/2022 à 13:51, Han-Wen Nienhuys a écrit :
The Scheme compilation felt much slower, and for C++ ccache takes away
a lot of the pain of recompiles. It also appears to be
single-threaded? I admit not having timed it in detail.
OK, I have very good news regarding compilation speed.
Tests are done with
rm -rf out/share/lilypond/current/guile/ && time out/bin/lilypond
(I have GUILE_AUTO_COMPILE=1 in my environment.)
* master and Guile 2
real 0m58,877s
user 0m58,773s
sys 0m0,124s
Execution time on MSDM.ly:
real 0m18,870s
user 0m18,727s
sys 0m0,470s
* Guile 2, with attached patch disabling all optimizations:
real 0m16,791s
user 0m16,700s
sys 0m0,056s
Execution time on MSDM.ly:
real 0m18,702s
user 0m18,517s
sys 0m0,509s
* Guile 3, with fixes from
https://gitlab.com/lilypond/lilypond/-/merge_requests/1230
real 1m25,302s
user 1m27,644s
sys 0m1,543s
Execution time on MSDM.ly:
real 0m19,533s
user 0m19,268s
sys 0m0,549s
* Guile 3, with https://gitlab.com/lilypond/lilypond/-/merge_requests/1230
plus second attached patch disabling optimizations:
real 0m3,538s
user 0m3,510s
sys 0m0,108s
(!!)
Execution time on MSDM.ly:
real 0m19,571s
user 0m19,387s
sys 0m0,573s
For one thing, Guile's optimization make about zero difference for the
speed of the resulting LilyPond executable. For another, disabling
optimizations in Guile 2 already results in a good speedup (1min
to 20s), and while Guile 3 is even slower than Guile 2 at the default
optimization level (1m30), with optimizations disabled it becomes
near instant (3.5s).
Guile 3 being far better at compilation speed with zero optimizations
apparently comes from what is described in
http://wingolog.org/archives/2020/06/03/a-baseline-compiler-for-guile
On the other hand, it does look like Guile 3 is a little slower
than Guile 2 on execution time (5%).
What do you think?
Jean
From 864143100d232e663b8f0aa8e236b9187d1a48bc Mon Sep 17 00:00:00 2001
From: Jean Abou Samra <j...@abou-samra.fr>
Date: Sat, 26 Feb 2022 13:43:37 +0100
Subject: [PATCH] Disable optimizations (Guile 2)
---
lily/guile-init.cc | 18 ++++++++++++++++++
lily/include/lily-imports.hh | 3 +++
lily/lily-imports.cc | 3 +++
3 files changed, 24 insertions(+)
diff --git a/lily/guile-init.cc b/lily/guile-init.cc
index 2dfae879e4..8d9d1d4bcf 100644
--- a/lily/guile-init.cc
+++ b/lily/guile-init.cc
@@ -59,6 +59,24 @@ ly_init_ly_module ()
for (vsize i = scm_init_funcs_->size (); i--;)
(scm_init_funcs_->at (i)) ();
+#if GUILEV2
+ SCM opts = SCM_EOL;
+ for (const char *name : {
+ "precolor-calls?", "rotate-loops?", "licm?", "specialize-numbers?",
+ "resolve-self-references?", "type-fold?", "cse?", "peel-loops?",
+ "prune-bailouts?", "elide-values?", "specialize-primcalls?", "inline-constructors?",
+ "contify?", "prune-top-level-scopes?", "eliminate-dead-code?", "simplify?",
+ "partial-eval?"
+ })
+ {
+ SCM kwd = scm_symbol_to_keyword (ly_symbol2scm (name));
+ opts = scm_cons (kwd, scm_cons (SCM_BOOL_F, opts));
+ }
+
+ Guile_user::f_auto_compilation_options = opts;
+#endif
+
+
Cpu_timer timer;
if (is_loglevel (LOG_DEBUG))
{
diff --git a/lily/include/lily-imports.hh b/lily/include/lily-imports.hh
index 6b4ad24880..00d2bd5933 100644
--- a/lily/include/lily-imports.hh
+++ b/lily/include/lily-imports.hh
@@ -28,6 +28,9 @@ extern Scm_module module;
typedef Module_variable<module> Variable;
extern Variable apply;
+#if GUILEV2
+extern Variable f_auto_compilation_options;
+#endif
extern Variable equal;
#if GUILEV2
extern Variable f_default_port_encoding;
diff --git a/lily/lily-imports.cc b/lily/lily-imports.cc
index ca4a3aa015..09d4abe6d4 100644
--- a/lily/lily-imports.cc
+++ b/lily/lily-imports.cc
@@ -24,6 +24,9 @@ namespace Guile_user
Scm_module module ("guile-user");
Variable apply ("apply");
+#if GUILEV2
+Variable f_auto_compilation_options ("%auto-compilation-options");
+#endif
Variable equal ("=");
Variable less ("<");
Variable plus ("+");
--
2.32.0
From 0852cc6277a911da4237b2bf013a45988db8b5d0 Mon Sep 17 00:00:00 2001
From: Jean Abou Samra <j...@abou-samra.fr>
Date: Sat, 26 Feb 2022 14:20:37 +0100
Subject: [PATCH] Guile 3: set optimization level to 0
---
lily/guile-init.cc | 3 +++
lily/include/lily-imports.hh | 8 ++++++++
lily/lily-imports.cc | 7 +++++++
3 files changed, 18 insertions(+)
diff --git a/lily/guile-init.cc b/lily/guile-init.cc
index 2dfae879e4..641d0fc657 100644
--- a/lily/guile-init.cc
+++ b/lily/guile-init.cc
@@ -59,6 +59,8 @@ ly_init_ly_module ()
for (vsize i = scm_init_funcs_->size (); i--;)
(scm_init_funcs_->at (i)) ();
+ Compile::default_optimization_level (to_scm (0));
+
Cpu_timer timer;
if (is_loglevel (LOG_DEBUG))
{
@@ -78,6 +80,7 @@ void
ly_c_init_guile ()
{
Guile_user::module.import ();
+ Compile::module.import ();
Lily::module.boot (ly_init_ly_module);
Srfi_1::module.import ();
Syntax::module.import ();
diff --git a/lily/include/lily-imports.hh b/lily/include/lily-imports.hh
index 6b4ad24880..30e0104436 100644
--- a/lily/include/lily-imports.hh
+++ b/lily/include/lily-imports.hh
@@ -45,6 +45,14 @@ extern Variable symbol_p;
extern Variable the_root_module;
}
+namespace Compile
+{
+extern Scm_module module;
+typedef Module_variable<module> Variable;
+
+extern Variable default_optimization_level;
+}
+
namespace Display
{
extern Scm_module module;
diff --git a/lily/lily-imports.cc b/lily/lily-imports.cc
index ca4a3aa015..acf01d4264 100644
--- a/lily/lily-imports.cc
+++ b/lily/lily-imports.cc
@@ -38,6 +38,13 @@ Variable symbol_p ("symbol?");
Variable the_root_module ("the-root-module");
}
+namespace Compile
+{
+Scm_module module ("system base compile");
+
+Variable default_optimization_level ("default-optimization-level");
+}
+
namespace Display
{
Scm_module module ("lily display-lily");
--
2.32.0