savonrb / wasabi

A simple WSDL parser
MIT License
90 stars 84 forks source link

Performance regression #7

Closed jacobat closed 4 years ago

jacobat commented 12 years ago

Parsing https://www.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL with Wasabi 1.0 takes ~0.3 sec:

require 'rubygems'
gem 'wasabi', '1.0.0'
require 'wasabi'
require 'benchmark'

wsdl = Wasabi.document File.read('economic.wsdl'); nil
Benchmark.measure do wsdl.endpoint end
 => #<Benchmark::Tms:0x10123ef90 @total=0.33, @cutime=0.0, @label="", @stime=0.01, @real=0.327524900436401, @utime=0.32, @cstime=0.0>

The same with 2.1.0 takes ~7sec:

require 'rubygems'
gem 'wasabi', '2.1.0'
require 'wasabi'
require 'benchmark'

wsdl = Wasabi.document File.read('economic.wsdl'); nil
Benchmark.measure do wsdl.endpoint end
 => #<Benchmark::Tms:0x1046a2a98 @label="", @stime=0.03, @real=6.99103879928589, @utime=6.97, @cstime=0.0, @total=7.0, @cutime=0.0>
henrik commented 11 years ago

With a local WSDL, the best times I get now are around 3–3.5 seconds. Just a few runs, no proper benchmark.

With the marshalling instead, it's just under 2.5 seconds. So the difference is a lot smaller. And considering that the marshalling probably has a ton of issues, that's very promising.

rubiii commented 11 years ago

@henrik i'm working on cleaning up the type parsing right now, so that may or may not bring some performance improvements as well. there's a lots of code to improve :wink: not against caching, but it comes with a few new problems and i think we can actually get this thing even faster.

henrik commented 11 years ago

What you have is plenty fast enough for me not to bother with the fragile marshalling stuff (and good riddance).

Shaving off even more time would of course be great, but I'm very happy with what you have now :)

On 30 apr 2013, at 14:05, Daniel Harrington notifications@github.com wrote:

@henrik i'm working on cleaning up the type parsing right now, so that may or may not bring some performance improvements as well. there's a lots of code to improve not against caching, but it comes with a few new problems and i think we can actually get this thing even faster.

— Reply to this email directly or view it on GitHub.

rubiii commented 11 years ago

@henrik cool :smile:

koppen commented 11 years ago

This is looking really good, thanks so much @rubiii . A preliminary test with Savon 2.2 and running a spec from R-conomic:

This brings us into usable territory, let the upgrading commence.

rubiii commented 11 years ago

started to clean up schema type parsing and pushed the first step to master. the accidental benefit of this is that now every single schema element is parsed lazily. if you're going to test this, please let me know how this affects your test scenarios!

the code still merges elements and complex types, ignores simple types and various other element types like group and choice, etc. which needs to be fixed, but it should be no different than before. and it exposes the same interface through the document class, so that it still works with savon.

next step: improve the interface (document class), because it's hard to consume and the code that uses it is the worst code inside savon right now. it's also pretty slow for documents with many elements, because we're iterating over all the types at least 4 times until we have the final xml. i think i can cut that down to one iteration total.

rubiii commented 11 years ago

just noticed, that the "lazy parsing" probably doesn't speed up the overall time to request just yet, because the code around it doesn't take advantage of this. it could even slow down your tests a bit.

rubiii commented 11 years ago

summed up everything i learned about this and pushed a lot of new code to master. it's basically a complete rewrite, but i finally managed to do it incrementally.

i updated the changelog and the readme to reflect the changes. i had to change the public interface, because it did not match the real world, so i need to adjust savon and throw out a lot of bad code.

not done here, but the new code already supports wsdl imports and xml schema imports are next on my todo list. i would like see as many people as possible try this with their wsdl documents, so that i can fix any major problems as early as possible.

this needs a lot more documentation and proper specs, but i'm very happy about it!

ps. codeclimate is awesome :)