
libxml support for dm-serializer
Reported by Adam greene | August 24th, 2008 @ 06:20 PM
hey guys, any interest in allowing the use of libxml for dm-serializer .to_xml methods? I've attached a working version (not a full patch, but more just a drop-in replacement so you can see how it works). The performance, for my limited testing, is 2.5x to 4x faster than REXML.
If you would like additional work on this, let me know.
thanks! Adam
Comments and changes to this ticket
-
Dan Kubb (dkubb) August 25th, 2008 @ 02:01 PM
This is something I'd definately like to see added to dm-serializer. If you've got the time to develop a patch, I'd definately encourage it. One of DataMapper's primary missions is to be as high performance as possible, so this is very much encouraged.
-
Sam Smoot August 25th, 2008 @ 02:09 PM
What Dan said.
Also though, I'd like to see something like this implemented as modules that can be included based on defined constants.
So basically, you implement:
module DM::Serializers module Xml module REXML ...original implementation... end module LibXml ...new fast implementation... end module ERubis ...fastest implementation perhaps?, output is just banging strings together after all... end end if defined?(LibXml) include XML::LibXml elsif defined?(ERubis) include XML::ERubis else require 'rexml' include XML::REXML end end
Could be prettier, but you get the idea I'm sure. The idea is just that it'll use the fastest available for whatever's loaded without having to configure anything specifically.
-
Adam greene August 25th, 2008 @ 04:04 PM
sounds good guys (and sam, nice layout...I'll use that general structure)
I won't be able to get a patch in right away, but I'll put one together. ping me if you want it done sooner ;)
-
Dan Kubb (dkubb) November 30th, 2008 @ 06:47 PM
- State changed from new to hold
- Assigned user changed from Sam Smoot to Dan Kubb (dkubb)
Adam, I was wondering how this patch was coming? I know the last comment was done in August, but if you've finished this please let me know. I would still love to see a sped-up to_xml method make it's way into dm-serializer.
-
Dan Kubb (dkubb) December 4th, 2008 @ 01:42 AM
- State changed from hold to confirmed
- Assigned user changed from Dan Kubb (dkubb) to Xavier Shay
Xavier, would you mind looking into this? Either using the last patch as a base, or altering the code in dm-serializer to use libxslt. It should certainly be faster than what we're doing now with REXML. The idea that Sam is outlining is that it should use the fastest available method, falling back to the next fastest and finally settling on using REXML, which should always be available.
You may also want to look into Sam's comment about using Erubis. I don't precisely know what he was thinking, but I assumed his suggestion was that the library could concat the strings together directly rather than using an XML builder. It could be faster I guess, but I don't really know.
Also, I would encourage a shared spec for the XML generators to ensure they all output the same XML structures.
-
Xavier Shay December 4th, 2008 @ 01:51 AM
No worries - Adam drop me a line if you've done anything further.
-
Xavier Shay December 4th, 2008 @ 04:22 PM
- State changed from confirmed to accepted
-
Dirkjan Bussink December 5th, 2008 @ 03:09 AM
I think we should also take a look at nokogiri, it's built on top of libxml / libxslt and its pretty fast. Merb already uses it too, so adding it as a dependency is not very strange and wouldn't cause too much problems i guess.
-
Xavier Shay December 9th, 2008 @ 10:38 AM
AFAIK nokogiri is a parsing lib - we want generation.
I didn't get a chance to start on this yet - I forgot to install libxml before I lost internets.
-
Greg Campbell December 12th, 2008 @ 02:51 PM
Nokogiri definitely supports generation as well - you can construct Documents, Nodes, etc. It also includes a Builder-style interface, but that uses method_missing, so probably not great for speed.
-
Xavier Shay January 1st, 2009 @ 12:16 PM
- State changed from accepted to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »