puppetlabs / ruby-hocon

A Ruby port of the Typesafe Config library.
Apache License 2.0
34 stars 30 forks source link

Hocon.load takes exponential time to load with += seperator #89

Open musiaht opened 8 years ago

musiaht commented 8 years ago

Encountering a problem with Hocon.load and Hocon.ConfigFactory.load_file; when loading a file with more than 5 '+=' to a key it will take exponentially longer with each concatenation.

For example, a file with the following will take more than 30 minutes to load.

asdf.s += 'asdf'
asdf.s += 'asdf.asd.asd.afs.asf.a.sf.asf.asf.asf.a.sf.'
asdf.s += 'asdf.qwe.qwe.q.we.qwe.qw'
asdf.s += 'asdf.q.weqwe.qwe.qwe.'
asdf.s += 'asdf.qweq.weq.e.qwe.'
asdf.s += 'asdfqeqweqwe.qwe'
asdf.s += 'asdf.asfd.asf.af'
asdf.s += 'asd.asdfasff'
asdf.s += 'asdf.asdfsadf'
asdf.s += 'asd.aaaaaf'
asdf.s += 'asd.fdsgwer.f'
asdf.s += 'asdf.lkjp.poiu.zsdf'
asdf.s += 'asdf.erwerwer.werwer'
asdf.s += 'asdf.llfllwelpwelr.sdf'
asdf.s += 'asdf.asdfasdf'
asdf.s += 'asdf.sdfsdfppowerwer'
asdf.s += 'asdf.ggggg'

It looks like we can get away with converting that into an array, but I am wondering if this can be fixed?

cprice404 commented 8 years ago

@musiaht thanks for the info. A couple of suggestions that might make it more likely that we can spend some time looking into it:

  1. Would you mind filing an issue for this on our Jira issue tracker? Issues there tend to get a little more visibility. Apologies that we don't have a link to that in the README here, we'll get that added.
  2. It would be helpful to know if this performance issue also exists in the upstream Java library. For the most part this library is a direct port of that code, so if we know the perf issue is not present there then we could look to see if there's something different about our implementation.
musiaht commented 8 years ago

Thanks @cprice404,

I have filed the issue at https://tickets.puppetlabs.com/browse/HC-96.

I haven't taken a detailed look at the Java upstream library; but from what I've seen with the Play! framework (https://www.playframework.com/) it doesn't look like it does. I am assuming that the same Java library is used as they're both typesafe projects.

Common configurations would load modules against the 'play.modules.enabled' variable.