docs: add ramdisk guide for running tests on OSX #27124

pull pinheadmz wants to merge 1 commits into bitcoin:master from pinheadmz:ramdisk-osx changing 1 files +32 −9
  1. pinheadmz commented at 4:25 PM on February 18, 2023: member

    Using a ramdisk on OSX sped up the test suite by about 5x (using default jobs=4) on my M1 macbook pro running macOS Monterey 12.3.1. This PR adds the relevant OSX commands following the Linux directions.

    Default:

    8204 s (accumulated) 
    Runtime: 2104 s
    

    following commands from the PR:

    1606 s (accumulated) 
    Runtime: 421 s
    

    ramdisk + jobs=32:

    2090 s (accumulated) 
    Runtime: 85 s
    
  2. DrahtBot commented at 4:25 PM on February 18, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK brunoerg, jonatack, willcl-ark
    Concept ACK RandyMcMillan, kristapsk
    Stale ACK Sjors, stickies-v

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Docs on Feb 18, 2023
  4. in test/README.md:142 in 62ac3b4dce outdated
     138 | @@ -137,6 +139,27 @@ Once finished with the tests and the disk, and to free the ram, simply unmount t
     139 |  sudo umount /mnt/tmp
     140 |  ```
     141 |  
     142 | +**OSX**
    


    jonatack commented at 10:25 PM on February 18, 2023:

    Unsure, but I thought "macOS" was the naming nowadays.

    **macOS**
    
  5. in test/README.md:144 in 62ac3b4dce outdated
     138 | @@ -137,6 +139,27 @@ Once finished with the tests and the disk, and to free the ram, simply unmount t
     139 |  sudo umount /mnt/tmp
     140 |  ```
     141 |  
     142 | +**OSX**
     143 | +
     144 | +To create a 4GB ramdisk named "ramdisk" on OSX at `/Volumes/ramdisk/`:
    


    jonatack commented at 10:25 PM on February 18, 2023:
    • not sure if it's needed to restate the OS here and line 119 above
    • 4GB -> 4 GiB if I'm not confused (correct units and consistent spacing)
    • no strong opinion about "ramdisk" but it looks like the most common spelling may be "RAM disk" (https://en.wikipedia.org/wiki/RAM_disk etc.)
    To create a 4 GiB RAM disk named "ramdisk" at `/Volumes/ramdisk/`:
    
  6. in test/README.md:151 in 62ac3b4dce outdated
     146 | +```bash
     147 | +diskutil erasevolume HFS+ ramdisk $(hdiutil attach -nomount ram://8388608)
     148 | +```
     149 | +
     150 | +Configure the size at the end of the command, in terms of block size
     151 | +(`8388608 / 2048 = 4096` or 4 GB). To run the tests using the ramdisk:
    


    jonatack commented at 10:27 PM on February 18, 2023:
    (`8388608 / 2048 = 4096` or 4 GiB). To run the tests using the RAM disk:
    
  7. in test/README.md:119 in 62ac3b4dce outdated
     113 | @@ -114,6 +114,8 @@ options. Run `test/functional/test_runner.py -h` to see them all.
     114 |  If you have available RAM on your system you can create a ramdisk to use as the `cache` and `tmp` directories for the functional tests in order to speed them up.
     115 |  Speed-up amount varies on each system (and according to your ram speed and other variables), but a 2-3x speed-up is not uncommon.
     116 |  
     117 | +**Linux**
     118 | +
     119 |  To create a 4GB ramdisk on Linux at `/mnt/tmp/`:
    


    jonatack commented at 10:28 PM on February 18, 2023:
    To create a 4 GiB RAM disk at `/mnt/tmp/`:
    

    pinheadmz commented at 3:23 PM on February 21, 2023:

    Thanks for the review! All nits addressed throughout the entire section at ab6f73a1f65bcfd59fea07f3067312a757dba2f8

  8. Sjors commented at 2:29 PM on February 20, 2023: member

    utACK 62ac3b4

    That looks pretty much like what I use on macOS.

  9. in test/README.md:147 in 62ac3b4dce outdated
     138 | @@ -137,6 +139,27 @@ Once finished with the tests and the disk, and to free the ram, simply unmount t
     139 |  sudo umount /mnt/tmp
     140 |  ```
     141 |  
     142 | +**OSX**
     143 | +
     144 | +To create a 4GB ramdisk named "ramdisk" on OSX at `/Volumes/ramdisk/`:
     145 | +
     146 | +```bash
     147 | +diskutil erasevolume HFS+ ramdisk $(hdiutil attach -nomount ram://8388608)
    


    willcl-ark commented at 2:31 PM on February 20, 2023:

    I think this could "feel safer" for people to run if it were split into two commands (even though it's using a subshell)?


    Sjors commented at 2:36 PM on February 20, 2023:

    You need to do this again at every reboot, so it's nice to have a single incantation in your bash history.


    willcl-ark commented at 2:37 PM on February 20, 2023:

    OK, that makes sense too :)


    RandyMcMillan commented at 4:31 PM on February 20, 2023:

    agree with Sjors


    pinheadmz commented at 3:22 PM on February 21, 2023:

    OK, leaving this as one-liner for now


    brunoerg commented at 5:22 PM on February 21, 2023:

    doubt:

    To create a 4 GiB RAM disk named "ramdisk" at `/Volumes/ramdisk/`:
    

    Does it create a RAM disk named "ramdisk" at /Volumes/, resulting in /Volumes/ramdisk/ or it creates a RAM disk named "ramdisk" into /Volumes/ramdisk/?


    pinheadmz commented at 6:05 PM on February 21, 2023:

    @brunoerg

    Not sure I understand. The volume is named "ramdisk" and is mounted at /Volumes/ramdisk. The path /Volumes/ramdisk does not exist before the command is executed.

  10. willcl-ark commented at 2:32 PM on February 20, 2023: contributor
  11. RandyMcMillan commented at 3:46 PM on February 20, 2023: contributor

    Concept ACK

  12. jonatack commented at 6:01 PM on February 20, 2023: contributor

    Concept ACK

  13. pinheadmz force-pushed on Feb 21, 2023
  14. brunoerg commented at 5:20 PM on February 21, 2023: contributor

    Tested these steps on my macOS machine and it worked as expected:

    ➜  bitcoin-core-dev git:(master) ✗ diskutil erasevolume HFS+ ramdisk $(hdiutil attach -nomount ram://8388608)
    Started erase on disk5
    Unmounting disk
    Erasing
    Initialized /dev/rdisk5 as a 4 GB case-insensitive HFS Plus volume
    Mounting disk
    Finished erase on disk5 (ramdisk)
    
    ➜  bitcoin-core-dev git:(master) ✗ ./test/functional/test_runner.py --cachedir=/Volumes/ramdisk/cache --tmpdir=/Volumes/ramdisk/tmp
    Temporary test directory at /Volumes/ramdisk/tmp/test_runner_₿_🏃_20230221_120656
    Running Unit Tests for Test Framework Modules
    ..........
    ----------------------------------------------------------------------
    Ran 10 tests in 0.595s
    
    OK
    1/260 - feature_taproot.py passed, Duration: 31 s
    ...
    
    ➜  bitcoin-core-dev git:(master) ✗ umount /Volumes/ramdisk
    
  15. kristapsk commented at 5:28 PM on February 21, 2023: contributor

    Concept ACK

  16. in test/README.md:151 in ab6f73a1f6 outdated
     146 | +```bash
     147 | +diskutil erasevolume HFS+ ramdisk $(hdiutil attach -nomount ram://8388608)
     148 | +```
     149 | +
     150 | +Configure the size at the end of the command, in terms of block size
     151 | +(`8388608 / 2048 = 4096` or 4 GiB). To run the tests using the RAM disk:
    


    stickies-v commented at 12:28 PM on February 22, 2023:

    nit: I think the formula can be expressed a bit more useable like this:

    (`4096 MiB * 2048 blocks/MiB = 8388608 blocks` for 4GiB). To run the tests using the RAM disk:
    

    pinheadmz commented at 3:10 PM on February 22, 2023:

    sure, updated

  17. stickies-v approved
  18. stickies-v commented at 12:29 PM on February 22, 2023: contributor

    ACK ab6f73a1f65bcfd59fea07f3067312a757dba2f8

    I use this command on my M1 too.

  19. DrahtBot requested review from Sjors on Feb 22, 2023
  20. pinheadmz force-pushed on Feb 22, 2023
  21. stickies-v approved
  22. stickies-v commented at 3:19 PM on February 22, 2023: contributor

    re-ACK cb7be3a

  23. willcl-ark approved
  24. willcl-ark commented at 5:00 PM on February 22, 2023: contributor

    ACK cb7be3a237c7e5a3d09f24259be015557dc72bca

    Tested on my Macbook, worked as expected and speeded up the test suite noticeably.

  25. in test/README.md:150 in cb7be3a237 outdated
     145 | +
     146 | +```bash
     147 | +diskutil erasevolume HFS+ ramdisk $(hdiutil attach -nomount ram://8388608)
     148 | +```
     149 | +
     150 | +Configure the size at the end of the command, in terms of block size
    


    jonatack commented at 6:00 PM on February 22, 2023:

    Am I understanding this correctly?

    Configure the size, expressed as the number of blocks, at the end of the command
    

    Also, if you retouch, s/ram/RAM/ in this line:

    Once finished with the tests and the disk, and to free the ram, simply unmount the disk:
    

    pinheadmz commented at 6:04 PM on February 22, 2023:

    great, both updated

  26. jonatack commented at 6:01 PM on February 22, 2023: contributor

    utACK cb7be3a237c7e5a3d09f24259be015557dc72bca

  27. docs: add ramdisk guide for running tests on OSX 2f84ad7b9e
  28. pinheadmz force-pushed on Feb 22, 2023
  29. brunoerg approved
  30. brunoerg commented at 6:53 PM on February 22, 2023: contributor

    utACK 2f84ad7b9e62dd710940c2f265b65973b94864d7

  31. DrahtBot requested review from jonatack on Feb 22, 2023
  32. DrahtBot requested review from stickies-v on Feb 22, 2023
  33. DrahtBot requested review from willcl-ark on Feb 22, 2023
  34. jonatack commented at 6:59 PM on February 22, 2023: contributor

    ACK 2f84ad7b9e62dd710940c2f265b65973b94864d7

    M1 Max, macOS 13.2

    $ diskutil erasevolume HFS+ ramdisk $(hdiutil attach -nomount ram://8388608)
    Started erase on disk6
    Unmounting disk
    Erasing
    Initialized /dev/rdisk6 as a 4 GB case-insensitive HFS Plus volume
    Mounting disk
    Finished erase on disk6 (ramdisk)
    
    $ diskutil info disk6 | grep -e Size
       Disk Size:                 4.3 GB (4294967296 Bytes) (exactly 8388608 512-Byte-Units)
       Device Block Size:         512 Bytes
       Allocation Block Size:     4096 Bytes
    
    $ test/functional/test_runner.py --cachedir=/Volumes/ramdisk/cache --tmpdir=/Volumes/ramdisk/tmp
    Temporary test directory at /Volumes/ramdisk/tmp/test_runner_₿_🏃_20230222_105652
    ..........
    
    ALL                                                    | ✓ Passed  | 2702 s (accumulated) 
    Runtime: 292 s
    
    $ umount /Volumes/ramdisk
    
  35. willcl-ark commented at 9:10 AM on February 23, 2023: contributor

    ACK 2f84ad7b9e62dd710940c2f265b65973b94864d7

  36. fanquake merged this on Feb 23, 2023
  37. fanquake closed this on Feb 23, 2023

  38. sidhujag referenced this in commit 3f3e901817 on Feb 25, 2023
  39. bitcoin locked this on Feb 23, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me