]> git.cworth.org Git - cworth.org/blob - src/exa/mystery_solved.mdwn
Convert prefix directives to new syntax.
[cworth.org] / src / exa / mystery_solved.mdwn
1 [[!meta title="Rectangles mystery solved"]]
2
3 [[!tag exa performance xorg]]
4
5 So I found the answer to my [[!fill rate
6 confusion|corrected_rectangles]] and it turned out to not be all that
7 interesting in the end---no pretty graphs this time. And it should
8 have been obvious to me---though admittedly the EXA run time was too
9 fast for me to _see_ what was happening.
10
11 What I did was eliminate all the variables of the cairo-perf test
12 suite by writing a tiny [[!standalone test case|rectangles.c]].  I
13 happened to be running an XAA server at the time, and when I ran the
14 test it gave exactly the same results as `x11perf -rect500`. They both
15 rendered 501 500x500 rectangles per second. But there was an obvious
16 difference, x11perf flashed wildly while my test stayed a constant
17 black.
18
19 So a quick glance with xtrace---by the way this is the long [[!sought
20 after|understanding_rectangles]] X protocol tracer that actually
21 decodes Render requests, and it's much easier to use than any of xmon,
22 xscope, or wireshark. Hurrah! (And many thanks to Behdad for pointing
23 it out to me). Anyway, xtrace showed immediately that my test was
24 sending rectangles in batches of 256 per request while x11perf was
25 sending only 1 per request.
26
27 And how could I have missed the obvious fact that x11perf is
28 alternating black and white colors when drawing rectangles while my
29 program was sending only white? (Cue forehead smacking sounds.) I
30 changed my program to do the same, (the file linked to above contains
31 this change), and it now behaves exactly like x11perf.
32
33 At least I was correct that the speedup I saw is due to the
34 optimization in EXA to avoid doing any redundant filling of rectangles
35 that overlap. So with that optimization guess what happens when you
36 send 256 rectangles that overlap almost entirely? Wow, it goes about
37 200 times faster.
38
39 OK, so that's actually a pretty boring result. I can't see that it's
40 all that useful to send lots of overlapping rectangles to the X
41 server, (but if your application is doing this for any reason, use EXA
42 and it will go faster).
43
44 Oh, and just to leave on another note of mystery. After I saw many
45 runs of both x11perf and my test agreeing on 501 rectangles/sec., after
46 a server restart I started getting 772 rectangles/sec. At first I
47 thought this was due to a different X server build and configuration
48 file that I had switched to, but when I switched back, the original
49 one also gave me 772 rectangles/sec.
50
51 Incidentally, the 501 rectangles/sec. rate corresponds to the 125M
52 pixels/sec. fill rate I reported in my previous post. So now I'm
53 getting a 193M pixels/sec. fill rate and I have no idea what
54 changed. (And I'm also wondering what the expected maximum fill rate
55 is for an r100. Anyone know? I guess it depends on how fast the memory
56 is on my card, and I'm not exactly sure how fast it might be.)
57
58
59