Skip to contentSkip to conversation

Performance drop on XDrawRectangles()

DISCUSSION Thomas Richter 3 participants 6 messages Jan 8, 2014

lore
Share & tools
lore
#0 lore raw

Hi folks,

during the changes from 3.12rc7 to 3.13rc4, the performance of XDrawRectangles() dropped considerably. Interestingly, it is not the raw rectangles drawing operations that are slow, but it seems that the "per-call" overhead has increased by one magnitude. In specific, if you use the unmodified "x11pref" program:

x11pref -rect10

no substiantial changes are visible. However, if the rectangles are drawn one by one by changing:

/* snip: old version, lines 86ff of do_rects.c of the x11perf program */

void
DoRectangles(XParms xp, Parms p, int reps)

{
    int i;

    for (i = 0; i != reps; i++) {
        XFillRectangles(xp->d, xp->w, pgc, rects, p->objects);
        if (pgc == xp->bggc)
            pgc = xp->fggc;
        else
            pgc = xp->bggc;
	CheckAbort ();
    }
}

/* to the following : */

void
DoRectangles(XParms xp, Parms p, int reps)

{
    int i;
    int j;

    for (i = 0; i != reps; i++) {
        for(j = 0;j < p->objects;j++) {
          XFillRectangles(xp->d, xp->w, pgc, rects+j, 1);
        }
        if (pgc == xp->bggc)
            pgc = xp->fggc;
        else
            pgc = xp->bggc;
	CheckAbort ();
    }
}

by instead drawing the rectangles one by one, the performance is decreased to one eigths of the original performance:

400000 trep @ 0.0687 msec ( 14600.0/sec): 10x10 rectangle (new)
2500000 trep @ 0.0107 msec ( 93900.0/sec): 10x10 rectangle (old)

Thus, apparently, not the actual hardware acceleration degraded, but there is something in the call path that slowed down the call considerably.

Any idea what changed?

Greetings,
Thomas

#1 lore raw
Quoted 53 lines · Thomas Richter

Hi folks,

during the changes from 3.12rc7 to 3.13rc4, the performance of XDrawRectangles() dropped considerably. Interestingly, it is not the raw rectangles drawing operations that are slow, but it seems that the "per-call" overhead has increased by one magnitude. In specific, if you use the unmodified "x11pref" program:

x11pref -rect10

no substiantial changes are visible. However, if the rectangles are drawn one by one by changing:

/* snip: old version, lines 86ff of do_rects.c of the x11perf program */

void
DoRectangles(XParms xp, Parms p, int reps)

{
    int i;

    for (i = 0; i != reps; i++) {
        XFillRectangles(xp->d, xp->w, pgc, rects, p->objects);
        if (pgc == xp->bggc)
            pgc = xp->fggc;
        else
            pgc = xp->bggc;
	CheckAbort ();
    }
}

/* to the following : */

void
DoRectangles(XParms xp, Parms p, int reps)

{
    int i;
    int j;

    for (i = 0; i != reps; i++) {
        for(j = 0;j < p->objects;j++) {
          XFillRectangles(xp->d, xp->w, pgc, rects+j, 1);
        }
        if (pgc == xp->bggc)
            pgc = xp->fggc;
        else
            pgc = xp->bggc;
	CheckAbort ();
    }
}

by instead drawing the rectangles one by one, the performance is decreased to one eigths of the original performance:

Quoted 8 lines

400000 trep @ 0.0687 msec ( 14600.0/sec): 10x10 rectangle (new)
2500000 trep @ 0.0107 msec ( 93900.0/sec): 10x10 rectangle (old)

Thus, apparently, not the actual hardware acceleration degraded, but there is something in the call path that slowed down the call considerably.

Any idea what changed?

If the ddx is indeed the same and Chris doesn't have any ideas I guess a full bisect of the kernel should help a lot. Could very well be that some seemingly unrelated change in e.g. the scheduler caused havoc ... -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#2 lore raw
In reply to Thomas Richter
Quoted 50 lines · Thomas Richter

Hi folks,

during the changes from 3.12rc7 to 3.13rc4, the performance of XDrawRectangles() dropped considerably. Interestingly, it is not the raw rectangles drawing operations that are slow, but it seems that the "per-call" overhead has increased by one magnitude. In specific, if you use the unmodified "x11pref" program:

x11pref -rect10

no substiantial changes are visible. However, if the rectangles are drawn one by one by changing:

/* snip: old version, lines 86ff of do_rects.c of the x11perf program */

void
DoRectangles(XParms xp, Parms p, int reps)

{
    int i;

    for (i = 0; i != reps; i++) {
        XFillRectangles(xp->d, xp->w, pgc, rects, p->objects);
        if (pgc == xp->bggc)
            pgc = xp->fggc;
        else
            pgc = xp->bggc;
	CheckAbort ();
    }
}

/* to the following : */

void
DoRectangles(XParms xp, Parms p, int reps)

{
    int i;
    int j;

    for (i = 0; i != reps; i++) {
        for(j = 0;j < p->objects;j++) {
          XFillRectangles(xp->d, xp->w, pgc, rects+j, 1);
        }
        if (pgc == xp->bggc)
            pgc = xp->fggc;
        else
            pgc = xp->bggc;
	CheckAbort ();
    }
}
Quoted 5 lines

by instead drawing the rectangles one by one, the performance is decreased to one eigths of the original performance:

400000 trep @ 0.0687 msec ( 14600.0/sec): 10x10 rectangle (new)
2500000 trep @ 0.0107 msec ( 93900.0/sec): 10x10 rectangle (old)

Just to be clear: new = 3.13-rc4, old = 3.12-rc7 ?

I've taken a quick look at this on an ivb i7-3270qm, and see a 296kops/s to 248kops/s decrease. Not massive, and considering the difference in our hardware probably a distinct issue.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw
Quoted 11 lines · Chris Wilson
Quoted 8 lines · Thomas Richter

Hi folks,

during the changes from 3.12rc7 to 3.13rc4, the performance of XDrawRectangles() dropped considerably. Interestingly, it is not the raw rectangles drawing operations that are slow, but it seems that the "per-call" overhead has increased by one magnitude. In specific, if you use the unmodified "x11pref" program:

Just to be clear: new = 3.13-rc4, old = 3.12-rc7 ?

Yes, exactly.

Quoted 3 lines

I've taken a quick look at this on an ivb i7-3270qm, and see a 296kops/s to 248kops/s decrease. Not massive, and considering the difference in our hardware probably a distinct issue.

Well, note that a 1Ghz P-III / i830M is not an i7-3270qm. (-;

Did you made the changes in x11perf as I did? The bottleneck is not in the actual rectangle rendering, it is somewhere in the call-path from the application down to the hardware, i.e. the per-call overhead increased by a factor of eight.

Kernel configuration is identical, as much as I could arrange it. X11 and higher level libraries are all identical, I only changed the kernel.

Greetings,
Thomas

#4 lore raw
Quoted 6 lines · Thomas Richter
Quoted 4 lines · Chris Wilson

On Wed, Jan 08, 2014 at 04:57:52PM +0100, Thomas Richter wrote:
I've taken a quick look at this on an ivb i7-3270qm, and see a 296kops/s to 248kops/s decrease. Not massive, and considering the difference in our hardware probably a distinct issue.

Quoted 6 lines

Well, note that a 1Ghz P-III / i830M is not an i7-3270qm. (-;

Did you made the changes in x11perf as I did? The bottleneck is not in the actual rectangle rendering, it is somewhere in the call-path from the application down to the hardware, i.e. the per-call overhead increased by a factor of eight.

Yes, I'm using the modified one rect per request test.

Quoted 3 lines

Kernel configuration is identical, as much as I could arrange it. X11 and higher level libraries are all identical, I only changed the kernel.

Same. But there are a lot of factors that changed for my two kernels (FBC, ppgtt) to name but two which should not apply to your machine. Anyway it looks like the bisect progressing smoothly here, so I'll find out if there is something outside of i915.ko that changed. Later, I'll poke around on i845g as well.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#5 lore raw
Quoted 5 lines · Chris Wilson

Same. But there are a lot of factors that changed for my two kernels (FBC, ppgtt) to name but two which should not apply to your machine. Anyway it looks like the bisect progressing smoothly here, so I'll find out if there is something outside of i915.ko that changed. Later, I'll poke around on i845g as well.

Well, I managed to bark up the wrong tree on ivb. Turns out I was just seeing RENDER vs BLT perf differences due to CONFIG_I915_FBDEV, so irrelevant for your issue.

Will try again on i845. Albeit slowly.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre