Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full memory mode support #2

Open
duggavo opened this issue Sep 30, 2024 · 2 comments
Open

full memory mode support #2

duggavo opened this issue Sep 30, 2024 · 2 comments

Comments

@duggavo
Copy link

duggavo commented Sep 30, 2024

it would be nice to support RandomX full mode, mainly for testing, but it can be useful for faster hashing in Node.JS when a lot of memory is available.

@l1mey112
Copy link
Owner

This is currently not planned, because I am designing the library to be the most performant given the restrictions of the average browser.

Eventually yes, this could become a possibility. If enough people get behind a full speed RandomX implementation, completely implemented using web standards only (no FFI) I will budge.

@vExcess
Copy link

vExcess commented Oct 21, 2024

It is true that browsers won't let you allocate a 2 GB buffer, however you can allocate two 1GB buffers.
Running the following program in latest Chromium raised my RAM usage from 3.3GB to 5.5GB and in latest Firefox raises RAM usage from 2.9GB to 4.9GB. Both browsers run the program without erroring. This isn't even on a high end system. This was just run on my laptop with 6 GB of usable RAM (which is not a lot these days) running Linux Mint.

const GB = 1024 * 1024 * 1024;

class Buff2GB {
    arr1;
    arr2;
    
    constructor() {
        this.arr1 = new Uint8Array(GB);
        this.arr2 = new Uint8Array(GB);
    }
    
    read(idx) {
        return idx < GB ? this.arr1[idx] : this.arr2[idx - GB];
    }

    set(idx, val) {
        if (idx < GB) {
            this.arr1[idx] = val;
        } else {
            this.arr2[idx - GB] = val;
        }
    }
}

var mem = new Buff2GB();
for (let i = 0; i < 100000000; i++) {
    const idx = (Math.random() * GB * 2) | 0;
    const val = (Math.random() * 255) | 0;
    mem.set(idx, val);
}

console.log("DONE");

Also I should note thate Node JS does allow you to allocate a 2 GB buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants