I’ve got 64 GB of RAM and would like to force cargo to dump build artifacts into it. So basically the target/ directory should end up there.

Unless I’m mistaken RAM is much faster than SSDs and since I do rebuild quite often, it would save some R/W cycles on my SSD and allow faster file access.

I do jot mind doing a full rebuild every morning

Solution:

These 2 comments gave me the best indication how to do it: cargo ramdisk and build.target-dir config options.

Would be great if cargo had a build.target-dir-prefix though. One could set and env var CARGO_TARGET_DIR_PREFIX and point it at /dev/shm or /tmp if it’s a tmpfs and every rust project would have its artefacts end up in RAM.

  • Alex@lemmy.ml
    link
    fedilink
    arrow-up
    8
    ·
    5 days ago

    Your build artefacts will already be in RAM as the kernel will utilise any spare for the block cache. The block cache is evicted using a least recently used (LRU) basis when the system is under memory pressure. Using ram based filesystems is basically bypassing the kernel and reducing it’s flexibility to make the best use of spare RAM in the system.