Closed cheald closed 10 years ago
Hrm; Travis broke on JRuby, but it's because of an inability to use racc. I'm having trouble figuring out where my change might've broken that; the previous build passed just fine, so I'm somewhat confused there. Perhaps a Travis change? The previous build (which did pass) was almost a month ago.
Are you sure that this patch doesn't affect the runtime of gtg?
It's been a while since I was into this code, but I was measuring the culumative cost of the Journey code with request_profiler and kcachegrind. I'm travelling today, but when I get a chance, I'll run patched/unpatched and generate some useful numbers for inspection.
@cheald Is this patch still valid? We're also looking into improving performance of Journey (particularly when rendering views with lots of links in Rails 3.2.14). Even a 9% improvement in load time would be nice :smile:
I think it should be - I'm currently running it in production on our Rails 3.2.16 app.
Awesome! We'll try it out.
Journey is merged at Rails, and the stable branch is not maintained anymore since it is only for Rails 3.2 so I'm closing this pull request.
Thank you for the contribution.
I've been working on reducing my app's boot time, and found that a lot of time was being spent in
Module#===
, which was primarily the fault ofJourney::GTG::Builder
's case statements.Module#===
has to walk the inheritance tree for a class when doing comparisons, so we can achieve better performance by avoiding it.I refactored
Builder
so that rather than usingnullable?
,firstpos
, andlastpos
methods, those methods are now implemented on the individual nodes. This has the added benefit of being far more Rubyish. :)Additionally, I implemented memoizations on the
Terminal
andCat
nodes, which improved the runtimes of their methods which return arrays by an order of magnitude according to ruby-prof.The overall effect is that
ActionDispatch::Routing::Mapper::Resources#resources
' runtime is reduced from 968ms to 888ms in my app - about a 9% performance gain. Not blowing any hair back, but every little bit helps, and IMO it improves the code quality, as well. The performance gain should be more notable as the Journey AST increases in size.I applied this against the 1-0-stable branch, but it also applies against and passes tests on master, as well