bmjames / scala-optparse-applicative

Scala port of Paolo Capriotti's optparse-applicative library. This repository is no longer maintained; newer versions exist in this fork: https://github.com/xuwei-k/optparse-applicative
BSD 3-Clause "New" or "Revised" License
72 stars 9 forks source link

Very slow to render help message after a library upgrade (0.5 -> 0.6) #15

Closed andreyk0 closed 7 years ago

andreyk0 commented 7 years ago

91.09s user 1.72s system 104% cpu 1:29.04 total (v 0.6) vs 2.15s user 0.13s system 162% cpu 1.403 total (v 0.5, most of the time went to logback init)

It seems to be spending a very long time in findBest now, e.g. stack trace:

"main" #1 prio=5 os_prio=31 tid=0x00007f9394001000 nid=0x1b03 runnable [0x000070000a5a4000]
   java.lang.Thread.State: RUNNABLE
    at net.bmjames.opts.types.RenderDoc$.$anonfun$findBestCore$2(Doc.scala:155)
    at net.bmjames.opts.types.RenderDoc$$$Lambda$311/412925308.apply(Unknown Source)
    at scalaz.Free$.$anonfun$suspend$2(Free.scala:27)
    at scalaz.Free$$$Lambda$52/198099809.apply(Unknown Source)
    at scalaz.Free.$anonfun$resume$2(Free.scala:111)
    at scalaz.Free$$Lambda$315/2073640037.apply(Unknown Source)
    at scalaz.std.FunctionInstances$$anon$1.$anonfun$map$1(Function.scala:77)
    at scalaz.std.FunctionInstances$$anon$1$$Lambda$53/807752428.apply(Unknown Source)
    at scalaz.Free.$anonfun$run$1(Free.scala:263)
    at scalaz.Free$$Lambda$48/1658699134.apply(Unknown Source)
    at scalaz.Free.go2$1(Free.scala:154)
    at scalaz.Free.go(Free.scala:157)
    at scalaz.Free.run(Free.scala:263)
    at net.bmjames.opts.types.RenderDoc$.findBest(Doc.scala:150)

Seems related to kiama removal. Reverted project back to 0.5 for now but would appreciate if there were a better answer to this.

Just to give you and idea - it's not a huge CLI but larger than a "hello world", 2 commands, 14 options in the largest command and a handful of global options.

Thanks!

tpolecat commented 7 years ago

@coltfred any insight here? looks like it was introduced when swapping out kiama

coltfred commented 7 years ago

Gosh, this sounds like the issue I fixed where it was always exploring the whole space.

@andreyk0 I don't suppose you could supply an example which shows the issue? I'll try and take a look at it this weekend.

andreyk0 commented 7 years ago

@coltfred sure, https://github.com/andreyk0/optparse-applicative-slow Please pardon all of the proprietary bits, I just gutted the project to the CLI interface and filled bits that didn't compile with junk.

Thanks a lot for taking a look at this!

coltfred commented 7 years ago

Good news, I can reproduce it. Bad news, I don't have time to figure out why it's broken right now. This could be a case of me choosing to implement an algorithm which both has to be trampolined and that backtracks. I'll at least dig further this week. Thanks so much for reporting this @andreyk0 so we can get it fixed before more people get bit.

andreyk0 commented 7 years ago

Thanks!