http://qs1969.pair.com?node_id=11138670


in reply to Re: Anyone with XS experience willing to create a high performance data type for Perl?
in thread Anyone with XS experience willing to create a high performance data type for Perl?

> then it's an exaggeration to say it's 'several orders of magnitude faster'; based on those numbers, it's one order of magnitude faster.

I used to confuse orders of magnitude with times for a long time, until I realized the latter former referred to the exponent (usually applied to 10). Nonetheless, the type of hubris in this post begs for master of these kinds of topics. Perhaps OP is willing to contract someone to do this, which I think would be the appropriate tact. That said, the initial step of using Inline::C you suggested I think is the right one. For additional speed up, if the algorithm is parallelizable, is to introduce OpenMP, which is a lot more straightforward with Alien::OpenMP (and OpenMP::Environment for good measure).

Updated thanks to note by jdporter.

  • Comment on Re^2: Anyone with XS experience willing to create a high performance data type for Perl?

Replies are listed 'Best First'.
Re^3: Anyone with XS experience willing to create a high performance data type for Perl?
by talexb (Chancellor) on Nov 10, 2021 at 17:10 UTC

    An order of magnitude refers to the difference in exponent (or that's what I learned). To take an extreme case, 10 and 99 (1E1 and 9.9E1) are the same order of magnitude, but 99 and 100 (9.9E1 and 1E2) are different orders of magnitude.

    And sure, a 10x difference is big, but all of these things are relative. Unless you're working at FAANG scale, this may not add up to much. So your job runs for 10 seconds instead of a second? Meh. OK. Ten minutes instead of a minute? OK. Ten hours instead of one hour? Hmm .. that does take a while. Maybe don't run it every hour.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

      10 and 99 (1E1 and 9.9E1) are the same order of magnitude, but 99 and 100 (9.9E1 and 1E2) are different orders of magnitude

      No. That's the problem with taking such a definition literally. The "order of magnitude" of a number is its base-10 logarithm, usually rounded to the nearest whole number.

      Try this: round( log10(X) - log10(Y) )

      In terms of "order of magnitude", 99 and 100 are the same number.

      I reckon we are the only monastery ever to have a dungeon staffed with 16,000 zombies.

        :) OK, then, I guess I need to move my scale around. I could have said that 31 and 32 are different orders of magnitude (log of 31 is 1.49, log of 32 is 1.51).

        Using this (corrected) scale, 33 and 2 are actually two orders of magnitude apart (log of 33 is 1.51, log of 2 is of course .30). Two orders does count as 'several' orders, but a 16x difference, while large, is not gigantic. A recent improvement at work sped a database operation up from 5-6 minutes to about 15-20 seconds -- about a 20x improvement. I was happy with that.

        Alex / talexb / Toronto

        Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.