• Richard W.M. Jones's avatar
    sparse-random: Don't generate random content in blocks by default · 65d0d80d
    Richard W.M. Jones authored
    Testing nbdcopy with nbdkit-sparse-random-plugin as a test harness
    under perf showed that 34% of the total time was taken calling
    read_block() to generate random data within each block (about 18% when
    reading and another 16% when writing and verifying).  While we could
    probably optimize this a bit, it's all pointless make-work when
    testing.  As long as there is some non-zero data in each block it's
    still a valid test of nbdcopy.
    
    Therefore add a new flag (random-content=true|false) to enable random
    content inside each block.  The new default is random-content=false
    which means each block has the same random non-zero byte repeated
    across the whole block, which is fast.  To get the old behaviour use
    random-content=true.
    
    Total time spent running read_block() went from 34% down to 7%.
    Total time spent running nbdkit went from 58% down to 37%.
    65d0d80d