[Dbix-class] [ANNOUNCE] A much faster DBIx::Class 0.08250 is now on
CPAN
Peter Rabbitson
rabbit+dbic at rabbit.us
Tue Apr 30 10:00:00 GMT 2013
After a long and fascinating journey DBIx::Class version 0.08250 [1] is
finally here. Not much has entered the changelog [2] since the first
trial announcement [3], but a great deal of oversights have been fixed
and extra optimizations have taken place. To recap: if you upgrade from
an older version of DBIC to the current 0.08250 you will:
- Not need to change any of your existing code. The undertaking to clean
up and streamline the internals was always centered around the premise
that the spice must flow. If something seems to be working differently –
please do file a bugreport.
- Observe a massive speed-up of iterating codepaths - places where you do
while (my $r = $rs->next) { ... }
- Finally be able to truly reap the benefits of prefetching [4]. Up
until now a combination of several factors could turn this feature from
an optimization to a massive time-waster, especially on large
resultsets. No more – the current codepath performs equally well on
resultsets containing either 5 or 500,000 individual results.
- Notice that DBIx::Class::ResultClass::HashRefInflator [5] is now twice
as fast. The new internals allow for intelligent bypassing of much of
the result construction machinery when all you need is a hash.
- Be able to specify exactly which columns you wish to prefetch, instead
of the old "all or nothing" approach. Future blogposts will likely
explore this improvement in detail, but this test case should be a
decent primer for what is currently possible: observe what is returned
[6] given this fixture [7] and these search criteria [8]. The only thing
that is new API is the collapse() attribute [9], everything else behaves
exactly as you expect.
- And as shown in the above examples you will finaly be able to perform
any combination of same level has_many prefetches, and perform
prefetches fom resultsets with any arbitrary order_by (including
RANDOM() ).
As customary – here are some numbers from 3rd party benchmark suites
comparing the current 0.08250 (right) with the previous stable 0.08210
(left).
- Laurent Dami's benchmark taken from https://github.com/damil/compare-ORM
(git 5782179afd): http://www.diffchecker.com/v89swf0a
- John Siracusa's benchmark taken from
http://rose.googlecode.com/svn/trunk/modules/Rose-DB-Object/t/benchmarks
(svn rev 2274): http://www.diffchecker.com/6uzm88b5
I also would like to thank folks who helped along the way with code,
documentation, ideas, and plain old prodding. In particular:
abraxxa - Alexander Hartmaier
Caelum - Rafael Kitover
castaway - Jess Robinson
frew - Arthur Schmidt
ldami - Laurent Dami
mattp - Matt Phillips
mna
mo - Moritz Onken
mst - Matt Trout
rkinyon - Rob Kinyon
SineSwiper - Brendan Byrd
And likely others I can not currently remember. Thank you all! This code
would not have materialized without your help.
So this is it. Take it for a spin and let us know what we missed. In the
meantime the next yak awaits ;)
Cheers and happy search()ing \o/
[1] https://metacpan.org/release/RIBASUSHI/DBIx-Class-0.08250/
[2] https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.08250/Changes#L4
[3] http://lists.scsys.co.uk/pipermail/dbix-class/2013-February/011109.html
[4] https://metacpan.org/module/DBIx::Class::ResultSet#PREFETCHING
[5] https://metacpan.org/module/RIBASUSHI/DBIx-Class-0.08250/lib/DBIx/Class/Manual/Cookbook.pod#Skip-result-object-creation-for-faster-results
[6] https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.08250/t/prefetch/manual.t#L338
[7] https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.08250/t/prefetch/manual.t#L15
[8] https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.08250/t/prefetch/manual.t#L223
[9] https://metacpan.org/module/DBIx::Class::ResultSet#collapse
More information about the DBIx-Class
mailing list