7730b6993f
- Create assembly/vm.ts with full RandomX VM implementation
- 256 instructions, 2048 iterations per hash
- Native u64/f64 operations in WebAssembly
- Full mode dataset lookups (2GB pre-computed)
- Update miner to use WASM VM for full mode
- mining-worker-asm.js uses pre-compiled WASM
- ~32 H/s per thread (4x faster than light mode)
- 8 threads achieves ~260 H/s
- Clean up redundant code
- Remove mining-worker-full.js (old JIT approach)
- Consolidate 'asm' mode into 'full' mode
29 lines
943 B
JavaScript
29 lines
943 B
JavaScript
import { randomx_init_cache, randomx_superscalarhash } from '../src/randomx/vendor/index.js';
|
|
|
|
const cache = randomx_init_cache('test');
|
|
|
|
// Try to find the correct VM memory size by trial and error
|
|
// Start with a reasonable minimum and increase until it works
|
|
|
|
const testPages = [33, 34, 35, 36, 50, 64, 100, 128];
|
|
|
|
for (const pages of testPages) {
|
|
try {
|
|
const memory = new WebAssembly.Memory({ initial: pages, maximum: pages });
|
|
const vmImports = { env: { memory } };
|
|
const vmInstance = new WebAssembly.Instance(cache.vm, vmImports);
|
|
console.log('SUCCESS: VM instantiated with', pages, 'pages');
|
|
|
|
// Check exports
|
|
const exports = vmInstance.exports;
|
|
console.log(' Exports:', Object.keys(exports));
|
|
|
|
// Try to initialize
|
|
const scratchPtr = exports.i(3);
|
|
console.log(' Scratch ptr:', scratchPtr);
|
|
break;
|
|
} catch (e) {
|
|
console.log('FAILED with', pages, 'pages:', e.message);
|
|
}
|
|
}
|