6 Replies Latest reply on Jan 10, 2011 1:59 PM by areohbee

    Anybody ever benchmarked lua string ops?

    areohbee Level 5

      Or have reference to benchmarks?

       

      Some of my plugins are unbearably slow. One of the things that concerns me is the speed of string operations.

       

      I'd also be interested in performance of non-string ops, so I can write more efficient plugins.

       

      R

        • 1. Re: Anybody ever benchmarked lua string ops?
          johnrellis Most Valuable Participant

          Based on my (very) light reading about the Lua implementation, I'd guess that Lua string operations are roughly the same cost as Java string operations. There are two components to the cost: doing the byte manipulations, and the amortized cost of garbage-collecting the strings later.  Unlike Java, Lua needs to hash each string into a global string table, but the incremental cost of that is likely smaller than you think for many apps, since tests for equality take a single instruction, and the hashing can reduce additional storage allocations.   Also, I'd guess that the Lua garbage collector is not as efficient as a modern Java GC, but that's just an educated guess.

          • 2. Re: Anybody ever benchmarked lua string ops?
            johnrellis Most Valuable Participant

            You might consider profiling your plugins using the function Debug.profileFunc() from my debugging toolkit (free, of course):

             

            http://www.johnrellis.com/lightroom/debugging-toolkit.htm

             

            This is an elapsed-time profiler, which is generally more useful than a CPU-time profiler.   Because it imposes a non-trivial overhead on each profiled function, start profiling higher-level functions and then drill down into the bigger hogs.

             

            One thing I've found is that a number of the SDK API functions appear to call LrTasks.yield() (or equivalent), and this seems to impose a minimum overhead of at least 10 - 20 ms.   Doesn't seem like much until you discover you're calling it hundreds or thousands of times.

            • 3. Re: Anybody ever benchmarked lua string ops?
              areohbee Level 5

              Thanks John,

               

              I will give the debugging toolkit a closer look - theres a lot there :-)

               

              Rob

              • 4. Re: Anybody ever benchmarked lua string ops?
                jarnoh Level 1

                I noticed the yield issue as well.  But it's only problematic on Windows  

                 

                I'm creating a dialog with 128 pulldown menus, on Mac it takes less than one second to appear.  On Windows, it takes 10+ seconds. Almost worth putting separate progress dialog for configuration dialog...

                 

                Jarno

                • 5. Re: Anybody ever benchmarked lua string ops?
                  johnrellis Most Valuable Participant
                  I noticed the yield issue as well.  But it's only problematic on Windows

                  Yeah, I measured the cost of LrTasks.yield() on Mac to be about 1/100 to 1/1000 of that on Windows.   And I noticed that a number of API functions, e.g. the keyword-accessing functions, went proportionally faster on Mac as well.

                  • 6. Re: Anybody ever benchmarked lua string ops?
                    areohbee Level 5

                    I think Lightroom was initially developed on Macs, for Macs, by Mac developers..., then "ported" to Windows. I mean they probably had Windows in mind from the start, and I dont know the mechanisms whereby they accomplish a dual-platform product, but there is clearly a Mac bias in the programming, so no surprise if there are some things better optimized for a Mac...