Skip to content

Clean up 32 vs 64-bit choice for random generators #2038

@vincentkfu

Description

@vincentkfu

The documentation for random_generator=tausworthe64 implies that it only applies to generating offsets, but this value actually determines whether several other random generators are 64 or 32 bits.

From init.c:td_fill_rand_seeds():

        if (td->o.random_generator == FIO_RAND_GEN_TAUSWORTHE64)
                use64 = true;
        else
                use64 = false;

...
        init_rand_seed(&td->bsrange_state[DDIR_READ], read_seed, use64);
        init_rand_seed(&td->bsrange_state[DDIR_WRITE], write_seed, use64);
        init_rand_seed(&td->bsrange_state[DDIR_TRIM], trim_seed, use64);

        init_rand_seed(&td->verify_state, td->rand_seeds[FIO_RAND_VER_OFF],
                use64);

...
        if (td->o.file_service_type == FIO_FSERVICE_RANDOM)
                init_rand_seed(&td->next_file_state, td->rand_seeds[FIO_RAND_FILE_OFF], use64);
        else if (td->o.file_service_type & __FIO_FSERVICE_NONUNIFORM)
                init_rand_file_service(td);

        init_rand_seed(&td->file_size_state, td->rand_seeds[FIO_RAND_FILE_SIZE_OFF], use64);
...
        init_rand_seed(&td->delay_state, td->rand_seeds[FIO_RAND_START_DELAY], use64);
...
        init_rand_seed(&td->dedupe_working_set_index_state, td->rand_seeds[FIO_RAND_DEDUPE_WORKING_SET_IX], use64);

...
        init_rand_seed(&td->buf_state, td->rand_seeds[FIO_RAND_BUF_OFF], use64);
        frand_copy(&td->buf_state_prev, &td->buf_state);

If the user selects random_generator=tausworthe64 this makes the random generators for choosing a random block size, file, start delay, etc use 64-bits.

On the other hand if the user selects rand_gen=lfsr, then these random generators will only be 32 bits.

We should fix up this code to divorce the 32- vs 64-bit decision for these other random generators from the random generator choice for offsets.

Fixing random generators used in the hot path that are unnecessarily 64 bits may produce some performance benefits.

This problem is of course not a show stopper but it would be nice to clean this up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions