On 2012-12-21 22:28, Sam Bradshaw (sbradshaw) wrote: > >> -----Original Message----- >> From: Jens Axboe [mailto:axboe@xxxxxxxxx] >> Sent: Friday, December 21, 2012 7:33 AM >> To: Sam Bradshaw (sbradshaw) >> Cc: fio@xxxxxxxxxxxxxxx >> Subject: Re: [PATCH] gettime: minimize integer division >> >> On 2012-12-20 20:23, Sam Bradshaw wrote: >>> >>> >>> Something like this might work, though that amount of logic may >>> be equivalent in terms of cycles to the divide. >> >> So I took a look at it. The costly bit is the division by >> cycles_per_usec, which the compiler has no other option than turn into a >> divq. The modulo and divide by 1M can be turned into something more >> clever, basically shifts and imull. >> >> So how about the below? It turns the divq into multiplication and >> division by 10M, which should be considerably less expensive. Can you >> test and see how that works for you? > > That works much better. Several % lower execution time in fio_gettime(). Goodie > IOPs look the same in my synthetic test but I'm not sure that's relevant; > (it probably just needs some more tweaking). It'd probably need 3-4M IOPS from a single thread to have a big impact. But reduced CPU is leftover CPU for doing actual IO, so always a good thing. And just as important, did the timing look correct? > I'll keep hunting for other hot spots. Thanks! -- Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html