planck-repl / planck

Stand-alone ClojureScript REPL
https://planck-repl.org
Eclipse Public License 1.0
1.03k stars 68 forks source link

Printing AST for defrecord analysis pegs CPU #564

Open mfikes opened 6 years ago

mfikes commented 6 years ago
$ /usr/local/bin/planck
Planck 2.9.0
ClojureScript 1.9.946
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
    Exit: Control+D or :cljs/quit or exit or quit
 Results: Stored in vars *1, *2, *3, an exception in *e

cljs.user=> (cljs.analyzer/analyze nil '(defrecord Herp [derp]))
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp
WARNING: No such namespace: , could not locate .cljs, .cljc, or JavaScript source providing ""
WARNING: Use of undeclared Var /Herp

At this point it hangs.

Reproducible with Lumo 1.7.0

Not reproducible with Planck embedding ClojureScript 1.9.473 on Ubuntu 14.04 (warnings emitted, but quickly spits out AST)

mfikes commented 6 years ago

Not reproducible with Planck 1.17, in the same way in ticket description for Ubuntu. So, this looks like a regression upstream with ClojureScript.

mfikes commented 6 years ago

Close enough to say this is an upstream issue: https://dev.clojure.org/jira/browse/CLJS-2429

mfikes commented 6 years ago

Now we know that this is just down to the ability to print a large map. Since Planck used to be able to print this (using Fipp), I'm wondering if the change to better deal with width with calling Fipp (planck.pprint.width-adjust) is causing Planck to now fail to print this large map.

mfikes commented 6 years ago

Here is a better way to analyze the form:

(require 'planck.core)
(def ast (cljs.js/analyze-str (cljs.js/empty-state planck.core/init-empty-state) "(defrecord Foo [])" nil {:eval cljs.js/js-eval :context :expr} identity))
mfikes commented 6 years ago

Doesn't occur with Planck 2.1.0 on my box, so just need to bisect to find the root cause.

mfikes commented 6 years ago
13c1edd93d1a3eef47d59d4b92fc207429b1da54 is the first bad commit
commit 13c1edd93d1a3eef47d59d4b92fc207429b1da54
Author: Mike Fikes <mike@fikesfarm.com>
Date:   Fri May 26 18:08:38 2017 -0400

    Update to ClojureScript 1.9.562

:040000 040000 a196b9f067ff58919fb37f8f8ebb22992e90d2a1 bf79453e6937c7b80f34c8cd5d215fa337ee3bc1 M  planck-cljs
mfikes commented 6 years ago

Confirmed works fine with

CLJS_COMMIT=r1.9.542 script/build
mfikes commented 6 years ago

Traced it to this upstream commit https://github.com/clojure/clojurescript/commit/d93c4356e7ab78743ae66d8cffe8df54869f0be3

arichiardi commented 6 years ago

I think I saw this happening in lumo as well. In particular every time a namespace with defrecord is compiled, it takes forever.

pyrmont commented 5 years ago

I'm still seeing the hanging behaviour described in the OP using the code example given there. This is in Planck 2.21.0. Should this not be happening any more?

mfikes commented 5 years ago

As far as I know, the root issue hasn't been determined.