Skip to content

Send and Sync for the core structures #58

@poszu

Description

@poszu

Currently, neither RandomXCache, RandomXDataset nor RandomXVM implement Send and Sync.

I think cache and dataset could implement both Send and Sync. For example, these structures are shared by VMs working in different threads in RandomX benchmarks: https://github.com/tevador/RandomX/blob/040f4500a6e79d54d84a668013a94507045e786f/src/tests/benchmark.cpp#L340-L365. It is essential to reuse cache and dataset to achieve high hashing rate using multiple threads.

I'm not 100% sure, but I think RandomXVM could also implement the Send trait. There doesn't seem anything that would make dropping a VM in a different thread unsound. It would allow putting it in a ThreadLocal to avoid recreating VMs every time a proof of work needs to be calculated. It would be useful for scenarios where many pows need to be verified in a short time.

Note: these traits are implemented by the archived moneromint/randomx4r:

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions