replete-repl / replete-ios

ClojureScript REPL iOS app
Eclipse Public License 1.0
395 stars 25 forks source link

Improve startup #6

Closed mfikes closed 9 years ago

mfikes commented 9 years ago

Currently startup can take a very long time on older devices. Hopefully something simple is being done wrong that can be fixed to improve this.

Also, the current stopgap fix is to disable the Eval button until the REPL is initialized. Perhaps better UI can be done here.

mfikes commented 9 years ago

IRC conversation with David:

[10:46:12]  <mfikes>    dnolen: You mentioned performance. While Goby-based apps load the JS on older devices on the order of 380 ms, Replete can take up to 45 seconds on old devices. I'm planning on digging into it and'll let you know if I find anything interesting.
[10:51:29]  <dnolen>    mfikes: you mean using the bootstrapped thing to load the JS right?
[10:53:25]  <dnolen>    mfikes: if so, yeah, bootstrapped thing is at least an order of magnitude slower.
[10:53:42]  <mfikes>    dnolen: Yes. Classroom Checkout used concatenated old-style JS, and Replete uses bootstrapped JS (following Joel Martin's Node example).
[10:54:13]  <dnolen>    Bottlenecks in tools.reader and analyzer and compiler
[10:54:15]  <mfikes>    dnolen: Cool. I could also be doing something stupid (failing to track loaded libs, or somesuch). Will find out,.
[10:55:13]  <dnolen>    There's just a lot of issues with the generated code. It's one big inner loop and we need to audit the output to verify we're generating good code.
[10:55:29]  <mfikes>    dnolen: On an iPhone 6 it only takes about 8 seconds. So no big deal for newer devices.
[10:55:30]  <dnolen>    Minor tweaks to tools.reader gave 4X perf boost
[10:55:48]  <dnolen>    I suspect similar results when I get around to analyzer and compiler
[10:56:15]  <dnolen>    A realistic goal would be 2X of JVM
[10:56:19]  <mfikes>    dnolen: Cool. I think mobile will be the guinea pig for perf of boostrapped stuff :)
[10:56:48]  <dnolen>    Agreed
[10:56:49]  <mfikes>    dnolen: Joel's Node bootstrapped REPL starts up nearly instantly for me.
[10:56:56]  <mfikes>    (On a computer.)
[10:57:04]  <dnolen>    Yep
mfikes commented 9 years ago

Likely solution: Let iOS parse JSON and use transit:

[10:11 AM]  <mfikes>    dnolen: FWIW, the Replete iOS launch perf is not evaluation of JS, but instead dominated by the reading in the `cache.edn` files. :)
[10:12 AM]  <dnolen>    mikes: yeah will probably want to evaluate using transit for this
[10:13 AM]  <dnolen>    20-30x faster
mfikes commented 9 years ago

Without yet trying Transit, one easy experiment could lead to a solution if Transit fails for any reason: Manually copying the EDN into the CLJS source (inlining it).

On an iPad 3, reading the EDN takes about 30 seconds, where instead having it in the replete.core namespace causes that file to take about 4 seconds longer to read.

For real-world use, on the iPad 3, between the time you see the keyboard and input area and the time you can eval, about 7 seconds transpire. On the iPhone 6 is is about 2 seconds or less. (Which is great considering it will take a little time for the user to enter the first sexp.)