Forum: Ruby wow, YAML / Psych in 1.9.3 is *slow*!

Fbb4d027695dfdf76bf448b15d7e306a?d=identicon&s=25 Matt Neuburg (Guest)
on 2012-09-14 16:07
(Received via mailing list)
I just started trying Ruby 1.9.3, coming from Ruby 1.8.7, and was
surprised to discover YAML's sluggishness. The chief problem seems to be
the Psych library.

In my main use case, a certain routine takes about 14 seconds.

Fortunately, I can switch to the "syck" library:

begin
  YAML::ENGINE.yamler = 'syck'
rescue

Using syck, the same routine takes about 7 seconds.

That's actually a bit faster than the same routine under Ruby 1.8.7 with
the old YAML, where the time for the same routine is 8 or 9 seconds. So
to get the juicy goodness of improved speed in Ruby 1.9.3, I definitely
need to use "syck".

A little googling suggests I'm not the only person to make this sort of
observation.

m.
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2012-09-14 20:13
(Received via mailing list)
File. A. Bug.
Fbb4d027695dfdf76bf448b15d7e306a?d=identicon&s=25 Matt Neuburg (Guest)
on 2012-09-15 01:21
(Received via mailing list)
Ryan Davis <ryand-ruby@zenspider.com> wrote:

> File. A. Bug.

With? Whom?

m.
Abbe9f1ceb1ebc50d1a5ac80a8d416e6?d=identicon&s=25 Jam Bees (Guest)
on 2012-09-15 02:11
(Received via mailing list)
The psych devs.

Are you asking for someone to look up their email address for you?
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2012-09-15 02:43
(Received via mailing list)
On Sep 14, 2012, at 16:20 , Matt Neuburg <matt@tidbits.com> wrote:

> Ryan Davis <ryand-ruby@zenspider.com> wrote:
>
>> File. A. Bug.
>
> With? Whom?

Given that you've now blogged about psych and cited its source... I'm
guessing you know.
Fbb4d027695dfdf76bf448b15d7e306a?d=identicon&s=25 Matt Neuburg (Guest)
on 2012-09-15 17:30
(Received via mailing list)
I think the question is a reasonable one. Who is to "blame" in a case
like this? The psych people? The YAML people, who have so forcibly
replaced syck with psych and made this horrible warning notice appear in
1.9.3 if you didn't build psych into Ruby? The Ruby people, who have
accepted that situation and allowed it to be built into the core? I
don't think the answer is obvious. m.

PS Don't be a ninny. Assume that your interlocutor has a brain. Give me
the same benefit of the doubt that I give you.
Abbe9f1ceb1ebc50d1a5ac80a8d416e6?d=identicon&s=25 James Harrison (Guest)
on 2012-09-15 18:26
(Received via mailing list)
Where is the performance problem? File the issue there.
Fbb4d027695dfdf76bf448b15d7e306a?d=identicon&s=25 Matt Neuburg (Guest)
on 2012-09-16 01:51
(Received via mailing list)
James Harrison <jam@jamandbees.net> wrote:

> Where is the performance problem? File the issue there.

In the end I filed in two places: Psych on github, and Ruby itself.
Here's why. There are really two problems. First, Psych is demonstrably
slow. I was able to write a simple real-world case showing that it takes
Pysch more then 3 times as long as Syck to do a load_file:

https://github.com/tenderlove/psych/issues/84

However, there's also a deeply disturbing philosophical problem. Psych
has been crammed down the throats of users before it's ready for prime
time. If you build Ruby 1.9.3 without libyaml being present, Psych won't
be installed and every time yaml is used, including every time you touch
"gem" in any way, you get a nasty warning. So I also filed at rubybugs
asking that this force-feeding of Psych be backed out. It won't be, of
course, but the point is made. m.
Ee276f5ceaf888446e989b04f30be3c9?d=identicon&s=25 Patrick B. (patrick_b)
on 2012-09-19 17:14
Matt Neuburg wrote in post #1076014:
> I just started trying Ruby 1.9.3, coming from Ruby 1.8.7, and was
> surprised to discover YAML's sluggishness. The chief problem seems to be
> the Psych library.
>
[...]
> Fortunately, I can switch to the "syck" library:
>
> begin
>   YAML::ENGINE.yamler = 'syck'
> rescue
>
> Using syck, the same routine takes about 7 seconds.

Wow indeed! With a test app with some of my data (having to load 820
yaml documents) switching to syck took execution from 16.7 to 1.3
seconds!
Are there any known side-effects with doing this?

Patrick
A74a68807619459925cc1d8e1045c7bd?d=identicon&s=25 Tony Arcieri (Guest)
on 2012-09-19 17:35
(Received via mailing list)
On Sat, Sep 15, 2012 at 4:50 PM, Matt Neuburg <matt@tidbits.com> wrote:

> However, there's also a deeply disturbing philosophical problem. Psych
> has been crammed down the throats of users before it's ready for prime
> time.


You do realize Syck is completely broken and unmaintained, right?
89d887b50262bbe10225d36d974fdb0c?d=identicon&s=25 Peter Zotov (Guest)
on 2012-09-20 06:12
(Received via mailing list)
Patrick B. писал 19.09.2012 19:14:
>>   YAML::ENGINE.yamler = 'syck'
>> rescue
>>
>> Using syck, the same routine takes about 7 seconds.
>
> Wow indeed! With a test app with some of my data (having to load 820
> yaml documents) switching to syck took execution from 16.7 to 1.3
> seconds!
> Are there any known side-effects with doing this?

Yes; namely, not being compatible with YAML specification.
Psych was written for a reason, and that reason was Syck's brokenness.
For years it has generated invalid YAML (or was refusing to consume
valid YAML; I have seen different opinions on this) in common cases.
For
example, this:
http://blog.rubygems.org/2011/08/31/shaving-the-ya...
Ee276f5ceaf888446e989b04f30be3c9?d=identicon&s=25 Patrick B. (patrick_b)
on 2012-09-20 06:31
Peter Zotov wrote in post #1076749:
> Patrick B. писал 19.09.2012 19:14:
>>>   YAML::ENGINE.yamler = 'syck'
>>> rescue
>>>
>>> Using syck, the same routine takes about 7 seconds.
>>
>> Wow indeed! With a test app with some of my data (having to load 820
>> yaml documents) switching to syck took execution from 16.7 to 1.3
>> seconds!
>> Are there any known side-effects with doing this?
>
> Yes; namely, not being compatible with YAML specification.
> Psych was written for a reason, and that reason was Syck's brokenness.
> For years it has generated invalid YAML (or was refusing to consume
> valid YAML; I have seen different opinions on this) in common cases.
> For
> example, this:
> http://blog.rubygems.org/2011/08/31/shaving-the-ya...

So then what can be done to improve the speed of the 'correct' YAML
library?  The difference is to put it mildly, significant.  :(
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.