change '%' to condition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I think you should revert the patch 
4c0ca26bd260dddf3b9781758cb5e2df3f74d4a3 that did this change:

                for (f = 1; f < geo->far_copies; f++) {
                        d += geo->near_copies;
-                       if (d >= geo->raid_disks)
-                               d -= geo->raid_disks;
+                       d %= geo->raid_disks;
                        s += geo->stride;
                        r10bio->devs[slot].devnum = d;
                        r10bio->devs[slot].addr = s;


On most processors, the divide and modulo operations are slower than a 
possibly misprediteced branch or conditional move instruction.

So, replacing a condition with modulo doesn't make sense.

A benchmark on AMD K10 shows that mispredicted branch is 8.7 times faster 
than a divide operation:

        for (i = 0; i < 10000000; i++) {
                q++;
                if (q >= 8)
                        q -= 8;
        }
- 11607us (it compiles to cmov and runs at a rate of 3 ticks per 
iteration)

        for (i = 0; i < 10000000; i++) {
                q++;
                q %= max;
        }
- 101241us (26 ticks per iteration)


Mikulas
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux