Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

talmy

macrumors 601
Original poster
Oct 26, 2009
4,726
332
Oregon
This has me baffled. I've got a program that is basically CPU bound with only system calls I know of are mainly to malloc and free. But even those should be limited. When I run under Linux (in a virtual machine) I get 1.8 seconds CPU time (as measured by times() adding system and user) and 2.0 seconds real time. When run under OS X it takes 12 seconds of real time and the CPU time is 5.98 seconds system and 13.20 seconds user.

Keep in mind that the program is a single task/thread so I am baffled why my user CPU time is greater than the real time. I'm also baffled why it takes 5x as long to run. I've tried both gcc and clang and 32-bit as well as 64-bit (64 is faster and are the times quoted, but the Linux is 32 bit.).

One other baffling item is while the program appears to use 2MB of RAM (believable) but shows as 20MB virtual memory. This is in Activity Monitor.

I don't know how to use the analysis tools, especially with a command-line application.

Any thoughts or answers?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I think you should be looking at the Private Memory, that should be closer to what you expect.
 

talmy

macrumors 601
Original poster
Oct 26, 2009
4,726
332
Oregon
Well, yes, but what I'm really after are hints to tracking down the performance problem. I tried running one of the performance monitoring tools ("Time Profiler" seemed like a likely choice) but I don't see a command console to run my program. I guess it only works for GUI applications. I'm at a loss to figure out what is consuming the time and then to fix it. As it is, the program runs faster on a 5 year old Linux PC with a Pentium 4 processor than on my i7 iMac!
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Once you choose Time Profiler in Instruments, in the toolbar select Choose Target > Choose Target > Choose Target... (a bit redundant :p). Then you can select the binary using their weird custom open dialog. There you can specify arguments if you need to.
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
...but I don't see a command console to run my program. I guess it only works for GUI applications.

We can see you're upset but you're question is so lacking in information with which to answer it you might as well not even posted it in the first place.

Just in case you're saying you couldn't find it a CLI can be had by launching the Terminal.app at /Applications/Utilities/Terminal.app.
 

talmy

macrumors 601
Original poster
Oct 26, 2009
4,726
332
Oregon
Thank you kainjow!

Being able to set command options let me have the program run a command script (so I didn't need the terminal window that the tool apparently can't provide). Having done so, I found that it is spending its time doing setjmp's, which do some internal routine __sigaltstack.

This tells me that setjmp is expensive in OS X. It seems to be virtually free in Linux (and MSDOS/Windows for that matter). Unfortunately the program requires setjmp/longjmp for error recovery. I guess it just isn't ideal for the Mac. :(
 

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
That's from 2002, and is primarily referring to PowerPC setjmp, with some commentary about i386 setjmp on Linux.


Make sure the actual code that's running is Intel code, not PowerPC code. The 5x or more slowdowns and the larger memory consumption are symptoms I would expect when running PowerPC code under the Rosetta emulator.

Activity Monitor will show what's running, in the left-most column.

One can also identify the kind of executable using the 'file' command like so in Terminal:
Code:
file /path/to/executable

It might be worthwhile to post exactly how this program is being built (Xcode? makefile?), and what architectures are being called for. Heck, it might even be worthwhile to identify what the program is, and where someone else can download it. Because then someone else could look at it and maybe measure it or debug it. All we have now are descriptions, and we can't debug descriptions.
 

talmy

macrumors 601
Original poster
Oct 26, 2009
4,726
332
Oregon
Aha! I switched to _setjmp and _longjmp and performance is NOW the same as Linux. Problem solved!

The program is XLISP, something I was working on in the 1980's and 90's, but put away 12 years ago. I just wanted to get it running again, and on my Mac.

It's here.

What I've posted there for Mac OS X does have a few bugs I've tracked down, but now I can put a full working copy up! :)
 
Last edited:

engram

macrumors newbie
Nov 17, 2010
7
24
Aha! I switched to _setjmp and _longjmp and performance is NOW the same as Linux. Problem solved!

The program is XLISP, something I was working on in the 1980's and 90's, but put away 12 years ago. I just wanted to get it running again, and on my Mac.

It's here.

What I've posted there for Mac OS X does have a few bugs I've tracked down, but now I can put a full working copy up! :)

Looks interesting. Thanks for reviving your project and posting this.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.