mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 08:17:37 +00:00
Update to RandomX v1.1.3, simplify
We don't need to detect if the cache has changed, just always call to set it on the VM. The call will be a no-op if the cache hasn't changed.
This commit is contained in:
parent
1c600a492f
commit
2675cf4483
2 changed files with 3 additions and 20 deletions
2
external/randomx
vendored
2
external/randomx
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 519b9cf70540bdd996e806251cde335c8eef8aca
|
Subproject commit 298cc77095c8992e30ecdd4ca0aa09a969a62bc1
|
|
@ -63,8 +63,6 @@ static rx_state rx_s[2] = {{CTHR_MUTEX_INIT,{0},0,0},{CTHR_MUTEX_INIT,{0},0,0}};
|
||||||
static randomx_dataset *rx_dataset;
|
static randomx_dataset *rx_dataset;
|
||||||
static uint64_t rx_dataset_height;
|
static uint64_t rx_dataset_height;
|
||||||
static THREADV randomx_vm *rx_vm = NULL;
|
static THREADV randomx_vm *rx_vm = NULL;
|
||||||
static THREADV int rx_toggle = -1;
|
|
||||||
static THREADV char rx_seedhash[HASH_SIZE];
|
|
||||||
|
|
||||||
static void local_abort(const char *msg)
|
static void local_abort(const char *msg)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +232,6 @@ static void rx_initdata(randomx_cache *rs_cache, const int miners, const uint64_
|
||||||
void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const char *seedhash, const void *data, size_t length,
|
void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const char *seedhash, const void *data, size_t length,
|
||||||
char *hash, int miners, int is_alt) {
|
char *hash, int miners, int is_alt) {
|
||||||
uint64_t s_height = rx_seedheight(mainheight);
|
uint64_t s_height = rx_seedheight(mainheight);
|
||||||
int changed = 0;
|
|
||||||
int toggle = (s_height & SEEDHASH_EPOCH_BLOCKS) != 0;
|
int toggle = (s_height & SEEDHASH_EPOCH_BLOCKS) != 0;
|
||||||
randomx_flags flags = RANDOMX_FLAG_DEFAULT;
|
randomx_flags flags = RANDOMX_FLAG_DEFAULT;
|
||||||
rx_state *rx_sp;
|
rx_state *rx_sp;
|
||||||
|
@ -256,9 +253,6 @@ void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle ^= (is_alt != 0);
|
toggle ^= (is_alt != 0);
|
||||||
if (toggle != rx_toggle)
|
|
||||||
changed = 1;
|
|
||||||
rx_toggle = toggle;
|
|
||||||
|
|
||||||
rx_sp = &rx_s[toggle];
|
rx_sp = &rx_s[toggle];
|
||||||
CTHR_MUTEX_LOCK(rx_sp->rs_mutex);
|
CTHR_MUTEX_LOCK(rx_sp->rs_mutex);
|
||||||
|
@ -283,11 +277,7 @@ void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const ch
|
||||||
rx_sp->rs_cache = cache;
|
rx_sp->rs_cache = cache;
|
||||||
rx_sp->rs_height = seedheight;
|
rx_sp->rs_height = seedheight;
|
||||||
memcpy(rx_sp->rs_hash, seedhash, HASH_SIZE);
|
memcpy(rx_sp->rs_hash, seedhash, HASH_SIZE);
|
||||||
changed = 1;
|
|
||||||
}
|
}
|
||||||
/* only non-miners use rx_seedhash */
|
|
||||||
if (!miners && !changed && memcmp(seedhash, rx_seedhash, HASH_SIZE))
|
|
||||||
changed = 1;
|
|
||||||
if (rx_vm == NULL) {
|
if (rx_vm == NULL) {
|
||||||
randomx_flags flags = RANDOMX_FLAG_DEFAULT;
|
randomx_flags flags = RANDOMX_FLAG_DEFAULT;
|
||||||
if (use_rx_jit()) {
|
if (use_rx_jit()) {
|
||||||
|
@ -315,9 +305,6 @@ void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const ch
|
||||||
mwarning(RX_LOGCAT, "Couldn't allocate RandomX dataset for miner");
|
mwarning(RX_LOGCAT, "Couldn't allocate RandomX dataset for miner");
|
||||||
}
|
}
|
||||||
CTHR_MUTEX_UNLOCK(rx_dataset_mutex);
|
CTHR_MUTEX_UNLOCK(rx_dataset_mutex);
|
||||||
} else {
|
|
||||||
/* only non-miners use rx_seedhash */
|
|
||||||
memcpy(rx_seedhash, seedhash, HASH_SIZE);
|
|
||||||
}
|
}
|
||||||
rx_vm = randomx_create_vm(flags | RANDOMX_FLAG_LARGE_PAGES, rx_sp->rs_cache, rx_dataset);
|
rx_vm = randomx_create_vm(flags | RANDOMX_FLAG_LARGE_PAGES, rx_sp->rs_cache, rx_dataset);
|
||||||
if(rx_vm == NULL) { //large pages failed
|
if(rx_vm == NULL) { //large pages failed
|
||||||
|
@ -335,13 +322,9 @@ void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const ch
|
||||||
if (rx_dataset != NULL && rx_dataset_height != seedheight)
|
if (rx_dataset != NULL && rx_dataset_height != seedheight)
|
||||||
rx_initdata(cache, miners, seedheight);
|
rx_initdata(cache, miners, seedheight);
|
||||||
CTHR_MUTEX_UNLOCK(rx_dataset_mutex);
|
CTHR_MUTEX_UNLOCK(rx_dataset_mutex);
|
||||||
} else if (changed) {
|
} else {
|
||||||
|
/* this is a no-op if the cache hasn't changed */
|
||||||
randomx_vm_set_cache(rx_vm, rx_sp->rs_cache);
|
randomx_vm_set_cache(rx_vm, rx_sp->rs_cache);
|
||||||
/* remember the seedhash being used by the current VM. Other threads may set
|
|
||||||
* rx_sp->rs_cache to the correct value, but we still have to know if the
|
|
||||||
* current rx_vm has been set to use it or not.
|
|
||||||
*/
|
|
||||||
memcpy(rx_seedhash, seedhash, HASH_SIZE);
|
|
||||||
}
|
}
|
||||||
/* mainchain users can run in parallel */
|
/* mainchain users can run in parallel */
|
||||||
if (!is_alt)
|
if (!is_alt)
|
||||||
|
|
Loading…
Reference in a new issue