Long compilation time on deeply nested constructs with (debug 3)

Bug #1563355 reported by eddy on 2016-03-29
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Hi all,

at work we are doing some macro-stuff that results in rather deeply nested progn's let's and company.
Such code results in very high compilation time when compiled with debug support.
For example:

  (defmacro gen-nested (level)
         `(or (read)
              ,(if (= 0 level)
                   `(gen-nested ,(1- level)))))

  (defun test (level)
    (dolist (dbg '(0 3))
        `(lambda () (declare (optimize (debug ,dbg)))
            (gen-nested ,level))))))

  (test 400))

Evaluation took:
  0.090 seconds of real time
  0.089890 seconds of total run time (0.077907 user, 0.011983 system)
  [ Run times consist of 0.025 seconds GC time, and 0.065 seconds non-GC time. ]
  100.00% CPU
  1 lambda converted
  304,234,186 processor cycles
  22,656,112 bytes consed

Evaluation took:
  22.075 seconds of real time
  22.057742 seconds of total run time (22.048788 user, 0.008954 system)
  [ Run times consist of 0.044 seconds GC time, and 22.014 seconds non-GC time. ]
  99.92% CPU
  2 lambdas converted
  75,015,059,835 processor cycles
  75,344,704 bytes consed

Note the difference in timings: 0.09s w/o debugging instrumentations, 22s with debugging instrumentations.

We were able to trace the problem down to the following commit:

Author: Stas Boukarev <email address hidden> 2015-02-07 18:00:35
Committer: Stas Boukarev <email address hidden> 2015-02-07 18:00:35
Parent: c12b72591adbf77d62762de23bd557dd946cc536 (Make type caches perform better.)
Branches: master, remotes/origin/master
Follows: sbcl-1.2.8
Precedes: sbcl-1.2.9

    More complete fix for listing local variables around inlined functions.

    Walk up call-lexenvs to find visible variables, not just one level.

    Fixes lp#1419205

In the function leaf-visible-to-debugger-p from the debug-dump.lisp
this commit introduces extremely non-linear amount of traversals of lexenv's inside the visible-in-call-lexenv label.
Undoing the commit fixes the compilation time issue, however associated test
:variables-surrounding-inlined-code.2 from debug.impure.lsp is failing.

It seems clear that information for leaf-visible-to-debugger-p should be somehow cached,
but we do not feel confident enough to suggest any solution.

If someone more experienced with translator structure can propose a solution sketch we can try to implement it ourselves
and provide a patch.

Best Regards,

Complying with the bug report rules:

[eddy@kml10 sbcl]$ sh run-sbcl.sh --version
(running SBCL from: .)

[eddy@kml10 sbcl]$ uname -a
Linux **** 3.19.3-200.fc21.x86_64 #1 SMP Thu Mar 26 21:39:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

[eddy@kml10 sbcl]$ sh run-sbcl.sh
(running SBCL from: .)
This is SBCL, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* *features*


eddy (eddyz87) wrote :
eddy (eddyz87) on 2016-03-29
tags: added: debugger
eddy (eddyz87) wrote :

Missed the hash of the commit at question:


Stas Boukarev (stassats) wrote :

In f6eb53a67ce39fe6047a15f00158cfb7c73659f3

Changed in sbcl:
status: New → Fix Committed
Stas Boukarev (stassats) on 2016-04-28
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers