tevador / RandomX

Proof of work algorithm based on random code execution
BSD 3-Clause "New" or "Revised" License
1.43k stars 307 forks source link

Possibility of increasing RAM requirement to 6 GB? #19

Closed JustFranz closed 5 years ago

JustFranz commented 5 years ago

Because of the 4 GB requirement both webmining and botnets are hindered. Botnets either don't have the necessary RAM or it will be too disruptive to the machine performance, thus harder to stay undetected.

How much do we know about the hardware capabilities of existing botnets? What systems tend to get infected? A lot of computers out there are 4 GB or less RAM, with no OS or apps of any kind, they will be hosed by the 4 GB. What kind of apps do 8 and 16 GB machines generally run and how disruptive is 4GB extra use, especially to 8 GB machines?

Will a purpose built CPU miner want dual channel RAM? With good timings? You'll go 2x4 GB. Windows 10 with with nothing else running should not use more than 1.5 GB (with free ram, win 10 will allocate it even when not necessarily needed), maybe you can even strip it down or go with some kind of a linux solution (not pirating windows is an unnecessary cost and you shouldn't pirate). Would 6GB + 1.5 GB + 500 MB free be cutting it too close?

Is the 4 GB also taking into consideration people mining with their PC? 4GB machines are screwed anyway and 6GB is pretty much nonexistent. Looking at steam HW survey https://store.steampowered.com/hwsurvey/Steam-Hardware-Software-Survey-Welcome-to-Steam

8GB 37.90% 16+GB ~35%

Is mining with an 8GB machine while it is not Idle even viable with 4GB miner RAM usage? If you have spare RAM, how many CPU cores can you reasonably spare? Pretty much all of the 4C processors have no HT. It used to be an i7 K exclusive feature (now only i9, with more cores).

The idea would be to not make it more expensive to build a bare-bones miner (8GB needed anyway, should we waste ram?) while possibly making it harder for infected machines to mine and stay undetected.

Do we know what kind of a performance impact dual vs single channel ram has and also different frequencies and timings? Can we make it favor faster ram?

JustFranz commented 5 years ago

Ok, I've been reading the Reddit thread. Some comments indicate that there is more ram overhead for the miner and It'll matter for performance how the 4GB is mapped in RAM.

I looked at ddr4 ram on newegg a little, gskill website, mobo compatibility lists. if this algo is memory frequency or latency sensitive (especially with ryzen) then the 4 gb thing should get more consideration.

3200 MHz 2x4GB cl16 kits are 70-120 USD where they start overlapping with 2x8gb cl16 3200 MHz at 120 ish USD.

3600 cl18 2x8 kits start at 120 usd. 3600 2x4 cl17 are 160

tevador commented 5 years ago

The size of the dataset needs to be a power of 2 for best performance, so 2, 4, 8 or 16 GB. I chose 4 GB because most computers are expected to have at least 8 GB nowadays.

How much do we know about the hardware capabilities of existing botnets? What systems tend to get infected?

AFAIK there are no statistics for this, but I'm assuming it's mostly lower-end machines that get infected.

how disruptive is 4GB extra use, especially to 8 GB machines?

On an 8 GB machine, it's very disruptive, especially on Windows. RandomX and an open web browser with a few tabs almost ensure swapping into the page file and noticeably slower response even with an SSD.

Will a purpose built CPU miner want dual channel RAM? With good timings? You'll go 2x4 GB. Windows 10 with with nothing else running should not use more than 1.5 GB (with free ram, win 10 will allocate it even when not necessarily needed), maybe you can even strip it down or go with some kind of a linux solution (not pirating windows is an unnecessary cost and you shouldn't pirate). Would 6GB + 1.5 GB + 500 MB free be cutting it too close?

You probably want dual channel, especially with a high-end CPU. 8 GB is probably better because the chances of being able to use large pages in Windows are smaller with 6 GB. Without large pages, RandomX runs ~25% slower.

A system with 16 GB of RAM has a small advantage because it can pregenerate the next dataset in RAM, so there is no interruption when dataset seed changes every 1024 blocks.

Is mining with an 8GB machine while it is not Idle even viable with 4GB miner RAM usage?

It depends on what the machine is being used for. Chrome is very hungry for RAM. As for the number of cores, RandomX is the same in this regard as Cryptonight - you should use 1 core per 2 MB of cache. Note that L3 cache is shared between cores, so using the PC while mining will increase L3 eviction rate and decrease performance.

Do we know what kind of a performance impact dual vs single channel ram has and also different frequencies and timings? Can we make it favor faster ram?

6 and 8 core CPUs will be bottlenecked by single channel DDR4. Memory latency is not very important, but I haven't done any benchmarks in this regard.

JustFranz commented 5 years ago

Thank you. Do you have an idea how performance might scale with memory frequency? Or how it might relate to the "Hash" rate of the CPU?

Gingeropolous commented 5 years ago

On an 8 GB machine, it's very disruptive, especially on Windows. RandomX and an open web browser with a few tabs almost ensure swapping into the page file and noticeably slower response even with an SSD.

This is not good. We want to encourage the average user to mine. I would propose reducing the 4 GB down to 2 GB, and somehow programming in an increase over time. e.g., 2 GB now, in 4 years 4 GB, in 16 years 16 GB, etc.

If this large memory dataset thing is just to hinder botnets, its a wasted effort. I remember pebblecoin had some variant of cryptonight called boulderhash that used 8 GB scratchpad instead of the 2 MB one. Botnets were still mining on it.

tevador commented 5 years ago

@Gingeropolous

Firstly, the primary goal of RandomX is ASIC resistance, not botnet resistance. I personally think that the botnet issue is blown out of proportion. The reasons why RandomX uses a lot of memory are partly explained here.

A 2 GB dataset would also satisfy the requirements, but most computers that can achieve any meaningful hashrate already have more than 4 GB of RAM, so the production costs of ASIC miners would be decreased with 2 GB without any real benefits. Increasing the dataset over time is a bit problematic because it would also increase verification cost.

Secondly, is there any evidence that "average user" mines while using the PC at the same time? Idle or overnight mining would always be a possibility even if the PC was unusable when mining.

Moreover, ~40% of gaming computers have more than 8 GB of RAM according to the Steam hardware survey.

RAM
<= 2 GB 1.77%
<= 4 GB 17,13%
8 GB 37.9%
> 8 GB 39,38%
Gingeropolous commented 5 years ago

Yeah, I don't know why gaming computers are a dataset we care about.

You wrote:

but most computers that can achieve any meaningful hashrate already have more than 4 GB of RAM,

Yet above you wrote:

On an 8 GB machine, it's very disruptive, especially on Windows.

So it seems the minimum would be something like 16 GB?

But yeah idle mining is an option. 4 GB seems fine. Thanks for the response.

tevador commented 5 years ago

So it seems the minimum would be something like 16 GB?

Minimum to run RandomX is 6 GB of RAM (2 GB for OS and 4 GB for the dataset). Most computers have this amount so there is no need to decrease the dataset size to 2 GB. That was my point.

JustFranz commented 5 years ago

Yeah, I don't know why gaming computers are a dataset we care about.

because you said "We want to encourage the average user to mine."

What do you actually mean by that then? Who is the average user and what does their mining look like?

On an 8 GB machine, it's very disruptive, especially on Windows.

That was in relation to botnet (or other) machines with 8 GB RAM and background mining. With windows and other applications running, an extra 4 GB RAM usage is going to noticeably slow down the machine.

Gingeropolous commented 5 years ago

I think our definitions of an average PC user are not the same.

I gauge this on what an entry level desktop at bestbuy would be

https://imgur.com/a/MjjSrZP

https://www.bestbuy.com/site/searchpage.jsp?browsedCategory=pcmcat212600050008&id=pcat17071&iht=n&ks=960&list=y&nrp=15&qp=condition_facet%3DCondition~New%5Ecurrentprice_facet%3DPrice~%24100%20-%20%24149.99%5Ecurrentprice_facet%3DPrice~%24150%20-%20%24199.99%5Ecurrentprice_facet%3DPrice~%24200%20-%20%24249.99%5Ecurrentprice_facet%3DPrice~%24250%20-%20%24499.99&sc=Global&st=categoryid%24pcmcat212600050008&type=page&usc=All%20Categories

I think half of those have 4 GB of RAM, half of them have 8 GB.

an average user should always be considered a general desktop user. Someone who would go to bestbuy to buy a PC to do online banking.

JustFranz commented 5 years ago

The PCs you linked to are what you'd buy for an office worker or for a POS machine.

Are people even going to bestbuy to buy e-mail and internet banking machines? I though that scenario was a myth. Stuff like that is probably done on laptops and going forward increasingly through banking apps on the phone.

Booting into windows 10 and opening the start menu is an absolute pain on a 4 GB RAM and HDD machine. These things are built to be barely usable and not mean for more than one hour of use a month, otherwise you'll lose your mind.

I wouldn't start catering to an imagined lowest common denominator.

Cryptos are an extreme niche, mining even more so. Mining needs to be valuable to the miner. Who is going to bother with their 20 H/s machine for a bi-annual 0.1 XMR payout?

tevador commented 5 years ago

@Gingeropolous

Looking at the first two computers with 4 GB of RAM that you linked:

First one has Intel Pentium J4205 , which is a low-power Intel Atom with a base frequency of 1500 MHz, 2 MB of cache and doesn't even support AES-NI.

Second one has AMD A9-9425, which has just 1 MB of cache.

Neither of these CPUs is suitable for mining regardless of the RAM amount. Even without considering the RAM requirement, they would not exceed 100 H/s in RandomX, while a laptop with an Intel i7-8550U can do 1650 H/s, or the equivalent of 16 such computers.

This only cements my opinion that the current RAM requirement is not excessive.

stoffu commented 5 years ago

IIUIC, every user running the full node will be required to allocate this large amount of RAM in order to verify blocks. While we don't expect a future where everyone (including those with low spec devices) participates in mining, we do aim for a future where (almost) everyone can run a full node.

Our current full node can run reasonably fine on those bestbuy desktops, but the new full node requiring 4GB of RAM may not be able to run on them.

This will also have a significant impact on exchanges and merchants accepting crypto payments. The bump of RAM requirement from tens of MBs to 4GB may surprise them and hinder adoption.

JustFranz commented 5 years ago

hile we don't expect a future where everyone (including those with low spec devices) participates in mining, we do aim for a future where (almost) everyone can run a full node.

Our current full node can run reasonably fine on those bestbuy desktops, but the new full node requiring 4GB of RAM may not be able to run on them.

This will also have a significant impact on exchanges and merchants accepting crypto payments. The bump of RAM requirement from tens of MBs to 4GB may surprise them and hinder adoption.

In the spec thread there is some mention of light clients that forgo the 4 GB requirement at the expense of CPU time. They verify the blockchain like a full node, but do it much slower. https://github.com/tevador/RandomX/issues/1#issuecomment-440806116

Its probably acceptable when you are keeping up with the blockchain or doing small catchups. Full verification would likely be way too slow.

stoffu commented 5 years ago

Good to know that there can be an option to trade speed for RAM requirement. How slow the sync speed can be needs to be thoroughly discussed, though.

Anyway, my point is that the hardware requirement should not be discussed solely based on typical computers owned by serious miners. It matters to every user in the ecosystem.

tevador commented 5 years ago

IIUIC, every user running the full node will be required to allocate this large amount of RAM in order to verify blocks.

This would obviously be a big issue, so RandomX was designed with a "light client" verification mode, which requires just 256 MB. Documentation.

The light-client verification is about 20 times slower.

Example with Intel i5-2500K: Mining mode (4 GB): ~2.2 ms per hash Verification mode (256 MB): ~50 ms per hash

Gingeropolous commented 5 years ago

agreed re: ram size. Thanks for the discussion.