Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Anybody ever benchmarked lua string ops?

LEGEND ,
Jan 09, 2011 Jan 09, 2011

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

TOPICS
SDK
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 09, 2011 Jan 09, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 09, 2011 Jan 09, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 09, 2011 Jan 09, 2011

Thanks John,

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

Rob

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 10, 2011 Jan 10, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2011 Jan 10, 2011
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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2011 Jan 10, 2011
LATEST

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines