0

I'm mining some Monero on my raspberry pi (Of course only for educational purposes). In order to increase my hashrate I'd like to increase my CPU cache. I already searched SE but haven't found a solution/tutorial so far...

The GPU performance is not important to me...

Do you know how to increase my CPU cache?

Any help would be very appreciated!! Thanks in advance!

6
  • Overclocking might be easier.
    – OyaMist
    Commented Jun 28, 2018 at 14:27
  • You might want to buy 4GB or more DDR4 RAM and install it as it would be faster than the on board memory. But be careful to buy the SODIMMs for laptops and not the full sized for desktop PCs as they are too large for the Raspberry Pi.
    – kwasmich
    Commented Jun 28, 2018 at 15:33
  • A CPU upgrade would also be a possibility. But haven't done that so far.
    – kwasmich
    Commented Jun 28, 2018 at 15:34
  • I'm not really interested in a PC... (As mentioned) It's only for educational purposes and meant to run on RPis... But of course buying ran would speed the process up..
    – Fipsi
    Commented Jun 28, 2018 at 15:35
  • Why do you think adjusting cache will help? Are you using htop to see your actual RAM layout? If so, a screenshot showing the cituation would help attract answers.
    – SDsolar
    Commented Jun 28, 2018 at 22:40

2 Answers 2

3

You cannot change the size of the cache; the CPU cache is built-in to the system on a chip (SoC) and replacing it manually is, for all intents and purposes, impossible.

It might be worth taking a look at this explanation of the CPU cache for some background context, but essentially the cache is a very small storage area near the CPU itself to store data as needed. The SoC is not designed to be modified by the user, and it will be inevitably be broken if you take it apart.

No modern computer really allows you to replace the CPU hardware cache, but the Pi is particularly difficult in this regard (you cannot even add/remove RAM).

If you need greater performance, you should probably invest in hardware designed for cryptocurrency mining (often these are high-end GPUs rather than inefficient Raspberry Pis).

8
  • Yeah I get your point but what about allocation disc space as a cache?
    – Fipsi
    Commented Jun 28, 2018 at 15:30
  • I read something on activating the level2 (L2) cache... But on the RPI 3 it should already been activated
    – Fipsi
    Commented Jun 28, 2018 at 15:32
  • The whole point of CPU cache is that it's really fast, @Fipsi. Your Pi can use the SD card as extra memory in the form of 'swap' space, but the CPU cache is by definition the hardware bit only. You can't configure more, or extend it; you only get what the processor was built with. I assume you were referring to this question too? As it says, the L2 cache is already active; you needn't do anything.
    – Aurora0001
    Commented Jun 28, 2018 at 15:34
  • I know how to change swap size but is the swap-size effect similar to a CPU cache 'upgrade'?
    – Fipsi
    Commented Jun 28, 2018 at 15:36
  • 2
    @Fipsi, not really. As I said, CPU cache is just the hardware cache, and it's not something that you can extend or customise. It is just a detail of how the processor works. You should probably look for a different way of optimising as the cache is essentially a fixed thing you can't adjust.
    – Aurora0001
    Commented Jun 28, 2018 at 15:53
2

CPU cache

The CPU caches are built into the CPU. You can not upgrade it.

  • Level 1: 16kB instruction, 16kB Data.
  • Level 2: 512kB shared.
  • Level 3: None (some architectures have this external)

Other caches

There are other caches

Disk/ssd cache.

  • The drive will have some sort of built in cache. You don't care about this, only what its spec is.
  • The OS will implement a disk cache using RAM. It usually knows what is best, so leave it alone. The only time I have had to mess with it. Is when copying large files, I tell it to not cache, as I am not going to read the files any time soon. You can do this by doing nocache command …. There are also kernel parameters that you can tune, but you better know how to measure your changes, or you will probably make it worse.

Network cache.

  • The OS will use disk/ssd to cache web access.
  • You can cache dns lookup, but not installed by default.

What is cpu cache

A program will run from RAM, however RAM is slower than the CPU. Therefore a cache is added. It is the same speed as the CPU. It remembers recent RAM accesses and will give the CPU the data quicker that the RAM can. Because the cache is expensive, it is small. Therefore the cache will forget stuff, when it does, the CPU has to get the data from the RAM (this is slower). Everything in cache is a copy of what is in RAM. The caches job is to make RAM seem faster. It succeeds most of the time (≈80%), because in most programs the same data is access more than once, and usually clustered in time and space.

A note on swap

Cache is NOT swap. It is very different. (Modern OSs use paging, not swap. However the differences are inconsequential for the purpose of this discussion.)

While RAM is slower than cache and the CPU. It is faster than SSD and Disk. And while RAM is much bigger than cache, it is much smaller than SSD and Disk.

It get around the smallness of RAM, the OS will swap/page the content of parts of the RAM into the swap area of disk. Now that the disk knows the content, it can be erased from RAM, and this bit of RAM used for something else.

Key differences between cache and swap/paging

  • Cache is smaller that the thing it is caching, a cache is used to allow faster running. A CPU cache makes RAM appear faster (It does not make the RAM appear smaller).
  • Swap/paging is slow, it is used to make RAM appear bigger (but slower, but not by much, if the data is not being swapped in and out, and in and out and …).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.