#815 ✓resolved
Jonathan Beckman

[PATCH]dm-types/flag.rb, speed improvement and cleanup

Reported by Jonathan Beckman | March 14th, 2009 @ 01:39 AM | in 0.10.0

I did some cleanup of dm-types so it doesn't use Math(which is really not needed) and use normal Integer[n] access for bit values in the fields. Apparently this did some speedups I think you could get more performance on the -dump thingy if you think about it.

% ruby test.rb Rehearsal ------------------------------------------------- Bitshift-load 2.420000 0.270000 2.690000 ( 2.780449) Pow-load 3.330000 0.380000 3.710000 ( 3.708585) Bitshift-dump 3.690000 0.390000 4.080000 ( 4.087149) Pow-dump 3.720000 0.340000 4.060000 ( 4.065642) --------------------------------------- total: 14.540000sec

                user     system      total        real

Bitshift-load 2.410000 0.300000 2.710000 ( 2.702938) Pow-load 3.370000 0.360000 3.730000 ( 3.754667) Bitshift-dump 3.650000 0.440000 4.090000 ( 4.091334) Pow-dump 3.630000 0.370000 4.000000 ( 3.999450)

Comments and changes to this ticket

  • Jonathan Beckman

    Jonathan Beckman March 14th, 2009 @ 01:41 AM

    Ouch, lighthouse rather destroyed my formating there. Does it accept pre tags? Also attached program I used to test the different implementations(rather ugly though).

    Rehearsal -------------------------------------------------
    Bitshift-load   2.420000   0.270000   2.690000 (  2.780449)
    Pow-load        3.330000   0.380000   3.710000 (  3.708585)
    Bitshift-dump   3.690000   0.390000   4.080000 (  4.087149)
    Pow-dump        3.720000   0.340000   4.060000 (  4.065642)
    --------------------------------------- total: 14.540000sec
    
                        user     system      total        real
    Bitshift-load   2.410000   0.300000   2.710000 (  2.702938)
    Pow-load        3.370000   0.360000   3.730000 (  3.754667)
    Bitshift-dump   3.650000   0.440000   4.090000 (  4.091334)
    Pow-dump        3.630000   0.370000   4.000000 (  3.999450)
    
  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) July 12th, 2009 @ 02:49 PM

    • Assigned user set to “Martin Gamsjaeger (snusnu)”
    • State changed from “unconfirmed” to “accepted”
    • Milestone set to 0.10.0

    I adapted your patch to work with latest next branch. It can be found at

    http://github.com/snusnu/dm-more/commits/815

    I think it's up to Dan to decide wether it gets merged or not.

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) July 14th, 2009 @ 03:11 PM

    Jonathan,

    I have to admit that I'm not very fluent with bitshifting stuff. Would your patch raise any issues regarding backwards compatibility? I mean, would there be any problems when users were storing their stuff with the old flag type and then upgrade to the flag type with your patch? This of course would be undesired! If you can confirm that everything will work like before for end users (apart from getting faster reads :) I could pull your patch in.

    Thanks for taking the time!

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) August 15th, 2009 @ 12:13 PM

    @Johanthan: My only concern with this patch is that it will break existing specs since it works differently from the old Flag type. It will probably also break any systems that were built with the old Flag type. Am I correct in that?

  • Jonathan Beckman

    Jonathan Beckman August 15th, 2009 @ 01:13 PM

    Shouldn't break anything, it just breaks how it works not how the interface works.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) August 15th, 2009 @ 07:22 PM

    @Johnathan: Doesn't it changed the actual stored values? So if there's a deployed site with records created using the old approach, it won't work with the new one? I guess my point is it appears to change the actual algorithm used for calculating the values, or am I wrong?

  • Jonathan Beckman

    Jonathan Beckman August 17th, 2009 @ 01:13 AM

    @dkubb: It doesn't change the actual value stored, it only changes how it checks if a bit is set or not using Integer [] access.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) August 18th, 2009 @ 12:54 AM

    @Jonathan: Ah, right you are. I had to write a test program to see because I couldn't visualize it, but I see now you were correct. I am going to apply this patch with a couple of other small cleanups and push it to the repo.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) August 18th, 2009 @ 12:55 AM

    • State changed from “accepted” to “resolved”

    (from [41b45659f3b0133075e4a10e87d2f19cca587103]) [dm-types] Speed improvement and cleanup for Flag type

    • Remove unecessary usage of Math

    [#815 state:resolved] http://github.com/datamapper/dm-more/commit/41b45659f3b0133075e4a10...

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Attachments

Referenced by

Pages