paul@cacilj.UUCP (Paul Close) (02/02/90)
I have a graphics library which uses Xlib calls to do its work. The programs linked with this library run slower than the equivalent program run on SunView. I would expect some overhead due to communication between server and client, but I would like to examine the issue of performance/efficiency. I started by building a profiled version of Xlib. Unfortunately, most of the real work is being done by the server, as evidenced by the cpu time (around 5% utilized!). My profiled output at least tells me how many calls I am making. Is there some way to figure out how much time each Xlib call is really taking? My application involves animation, so there is a lot of polling, a lot of clipping, and a lot of drawing. Using the profiler, I found that some of the following calls are called the most (roughly in order): XPending (I have to poll for events) _XGenerateGCList _XFlushGCCache XDrawLines XSetForeground XSetClipRectangles XCopyArea XFillRectangle XFillPolygon XSetLineAttributes XSetFillStyle XSetDashes XAllocColor Is the high activity in _XGenerateGCList and _XFlushGCCache indicate that I am not using GCs effectively? I only have two GCs per window, and generally use calls like XSetForeground to set the drawing color before drawing part of an object. In fact, the three routines _XGenerateGCList, _XFlushGCCache, and XSetForeground all have roughly the same number of calls and are near or at the top of the list. Anyone care to comment? -- Paul Close paul@cacilj.CTS.COM ...!{uunet, ucsd, crash}!cacilj!paul The Obi-wan Kenobi method: "Use the Source, Luke" -Jim Fulton
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (02/02/90)
The programs linked with this library run slower than the equivalent program run on SunView. You haven't said anything about the server you're using, so it's rather difficult to guess at where performance problems might be. My profiled output at least tells me how many calls I am making. Is there some way to figure out how much time each Xlib call is really taking? Assuming your system supports it, compile and link everything -pg, and use gprof. Unfortunately, most of the real work is being done by the server, as evidenced by the cpu time (around 5% utilized!). (5% is large?) If you really want to understand performance, it will pay to build a profiled version of the server as well. Is the high activity in _XGenerateGCList and _XFlushGCCache indicate that I am not using GCs effectively? Not necessarily, but it depends in part on the server implementation. On some servers, switching among a few GCs, changing one or two attributes at each switch, will be more effective than using a large number of GCs with static contents. For most servers in the MIT distribution, however, using GCs with static contents will probably tend to be faster. But, it will be hard to determine real costs without profiling both the client and the server.