The synch-parallel test was writing the thread buffer to the nbd server, and then copying data from the ramdisk to the thread buffer. This looks wrong for two reasons:
- The thread buffer is initialized to zeroes, and after every write, to the contents of the ramdisk, so we always write data which does not match the contents of the ramdisk. I guess this works since the patten filter drops the written data. - For every write, we pay for unneeded memcpy() adding unwanted noise to the results. Simplify the code to either copy a block from the ramdisk to the nbd server or copy a block from nbd server to the thread buffer. Testing show no significant difference with or without the unneeded memcpy(). Signed-off-by: Nir Soffer <[email protected]> --- tests/synch-parallel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/synch-parallel.c b/tests/synch-parallel.c index 72402d7..cecfeae 100644 --- a/tests/synch-parallel.c +++ b/tests/synch-parallel.c @@ -218,48 +218,49 @@ start_thread (void *arg) } assert (nbd_get_size (nbd) == EXPORTSIZE); assert (nbd_can_multi_conn (nbd) > 0); assert (nbd_is_read_only (nbd) == 0); start_usec = microtime (); stop_usec = start_usec + RUN_TIME * MICROSECONDS; /* Issue commands. */ while (1) { /* Run until the timer expires. */ now_usec = microtime (); if (now_usec >= stop_usec) break; /* Issue a synchronous read or write command. */ offset = status->offset + (rand () % (status->length - BUFFER_SIZE)); cmd = rand () & 1; if (cmd == 0) { - if (nbd_pwrite (nbd, buf, BUFFER_SIZE, offset, 0) == -1) { + /* Write block from ramdisk to nbd server. */ + if (nbd_pwrite (nbd, &ramdisk[offset], BUFFER_SIZE, offset, 0) == -1) { fprintf (stderr, "%s\n", nbd_get_error ()); goto error; } status->bytes_sent += BUFFER_SIZE; - memcpy (&ramdisk[offset], buf, BUFFER_SIZE); } else { + /* Read block from nbd server to buf. */ if (nbd_pread (nbd, buf, BUFFER_SIZE, offset, 0) == -1) { fprintf (stderr, "%s\n", nbd_get_error ()); goto error; } status->bytes_received += BUFFER_SIZE; if (memcmp (&ramdisk[offset], buf, BUFFER_SIZE) != 0) { fprintf (stderr, "thread %zu: DATA INTEGRITY ERROR!\n", status->i); goto error; } } status->requests++; } printf ("thread %zu: finished OK in %.6f seconds\n", status->i, (double) (now_usec - start_usec) / MICROSECONDS); if (nbd_shutdown (nbd, 0) == -1) { fprintf (stderr, "%s\n", nbd_get_error ()); goto error; } -- 2.31.1 _______________________________________________ Libguestfs mailing list [email protected] https://listman.redhat.com/mailman/listinfo/libguestfs
