[commit: ghc] wip/gc/misc-rts, wip/gc/nonmoving-nonconcurrent, wip/gc/preparation: rts: Add Note explaining applicability of selector optimisation depth limit (1ed35cb)
git at git.haskell.org
git at git.haskell.org
Thu Feb 21 15:12:03 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branches: wip/gc/misc-rts,wip/gc/nonmoving-nonconcurrent,wip/gc/preparation
Link : http://ghc.haskell.org/trac/ghc/changeset/1ed35cb0d7b6f5172b50294d554ca1d95ae59372/ghc
>---------------------------------------------------------------
commit 1ed35cb0d7b6f5172b50294d554ca1d95ae59372
Author: Ben Gamari <ben at well-typed.com>
Date: Tue Jul 3 19:58:37 2018 -0400
rts: Add Note explaining applicability of selector optimisation depth limit
This was slightly non-obvious so a note seems deserved.
>---------------------------------------------------------------
1ed35cb0d7b6f5172b50294d554ca1d95ae59372
rts/sm/Evac.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c
index 2890319..45431fe 100644
--- a/rts/sm/Evac.c
+++ b/rts/sm/Evac.c
@@ -39,7 +39,19 @@
copy_tag(p, info, src, size, stp, tag)
#endif
-/* Used to avoid long recursion due to selector thunks
+/* Note [Selector optimisation depth limit]
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * MAX_THUNK_SELECTOR_DEPTH is used to avoid long recursion of
+ * eval_thunk_selector due to nested selector thunks. Note that this *only*
+ * counts nested selector thunks, e.g. `fst (fst (... (fst x)))`. The collector
+ * will traverse interleaved selector-constructor pairs without limit, e.g.
+ *
+ * a = (fst b, _)
+ * b = (fst c, _)
+ * c = (fst d, _)
+ * d = (x, _)
+ *
*/
#define MAX_THUNK_SELECTOR_DEPTH 16
@@ -1252,6 +1264,7 @@ selector_loop:
// recursively evaluate this selector. We don't want to
// recurse indefinitely, so we impose a depth bound.
+ // See Note [Selector optimisation depth limit].
if (gct->thunk_selector_depth >= MAX_THUNK_SELECTOR_DEPTH) {
goto bale_out;
}
More information about the ghc-commits
mailing list