Optimize pattern filling by limiting small calls to memcpy
authorSteven Lang <tirea@google.com>
Thu, 2 Feb 2012 19:22:04 +0000 (20:22 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 2 Feb 2012 19:22:04 +0000 (20:22 +0100)
commitefcd9dcc5e93fc313b0cd37e267bbf141675826c
treea1ae155d456170e35de43213a37faa8a1b5c6cf0
parent07d91f3b8c746d2d7f303c0b3130a8a3d8516541
Optimize pattern filling by limiting small calls to memcpy

In looking at profiling the speed of fill_pattern(), it calls memcpy()
for the fill pattern repeatedly for multibyte patterns.  So for a 4
byte pattern with 8k IO, it calls memcpy() 2048 times.

Since there is already 512 bytes reserved for the pattern, I figured a
simple solution was to use it.  This patch replicates short patterns
so they can be more efficiently copied.  (Single byte patterns are
left alone since they can make use of the much more efficient memset()
call.)

The result is a 10x performance improvement on pattern filling. (With
this patch, it's still 3x slower than when it re-uses the already
filled pattern.)

Signed-off-by: Jens Axboe <axboe@kernel.dk>
options.c