Hashstore: move your hash tables off the HDD (memtbl or SSD). Numbers from my nodes

Short version: on hashstore, a large part of the random read IO on an HDD comes from the hash table, not from piece data. If you can move the table off the spinning disk, your HDD has a more headroom for real customer traffic. There are two ways to do that:

  1. memtbl: the table lives in RAM. Fastest, but it needs a lot of memory.
  2. hashtbl on an SSD: hashstore.table-path puts the tables on another disk. This needs very little RAM, and you probably already have an SSD for the OS.

I tested both on my own nodes (2 Raspberry Pis with 8 GB RAM, 16–18 TB HDDs, NVMe SSD for the OS).

Test setup

  • One HDD got the change. A second HDD on the same Pi with similar nodes stayed unchanged as the control.
  • Before the change, I measured the ratio between the two disks for a week, so the results below are compared against that baseline and not just raw numbers.

Result: hashtbl on SSD

Ratio of test disk to control disk (below 1.0 means the test disk does less):

metric before (7-day baseline) after moving tables to SSD change
disk utilization 1.13 ~0.60 about −45%
read ops/s 1.03 ~0.62 about −40%
read latency (r_await) 1.23 ~0.75 about −40%

In absolute numbers the test disk went from about the same load as the control (~55–65% busy) to 30–43% while the control stayed at 53–65%. Time to first byte for downloads was about the same on average and slightly better at p90. The bigger gain is the headroom the HDD gets back, which matters most during compaction, garbage collection and busy upload hours.

After that I moved the tables of all of my nodes to the SSDs.

Result: memtbl

memtbl removes the table IO just like the SSD does, and lookups are even faster. The problem is RAM:

  • I measured 21–34 bytes of RAM per piece, which works out to about 0.3–0.4 GB of RAM per TB stored.
  • A full 9 TB node needs about 3–3.5 GB of RAM just for the tables.
  • A Pi with four full 16 TB disks would need 20–25 GB of RAM.

On 8 GB Pis this ended in swapping after only about a third of the tables were converted, so I stopped the test. If you have the RAM (for example a small number of nodes on a machine with 32+ GB), memtbl is the best option. For everyone else, the SSD is the practical way.

How much SSD space you need

The tables are small compared to the data: about 0.7 GB per TB stored. A full 9 TB node has about 6 GB of tables. All of my nodes together use well under 100 GB on the SSDs.

How to move the tables to an SSD

Per node, with the node stopped:

  1. Copy every storage/hashstore/<satellite>/s0/meta and .../s1/meta folder to the new location, keeping the same structure: <table-path>/<satellite>/s0/meta, <table-path>/<satellite>/s1/meta.
  2. Add hashstore.table-path: /path/on/ssd/node1 to config.yaml. Use an absolute path, and a separate folder for each node.
  3. Start the node. Check the log and check that the node holds files open under the new path.

Notes:

  • The node-level storage/hashstore/meta folder (bloom filter, migration state) stays where it is. Only the per-satellite s0/meta and s1/meta folders move.
  • If the path is wrong, the node refuses to start with “missing hashtbl” instead of starting empty. That is a good safety net.
  • Downtime per node was 2 seconds to about 5 minutes, depending on table size and how busy the HDD was.
  • Keep the old folders (I renamed them to meta.pre-ssd) for a few days, then delete them. Once compaction has run, they are outdated and can’t be used to roll back.

Risks

  • If the SSD dies, the tables are gone. The data in the logs is still on the HDD, and the tables can be rebuilt from the logs (write-hashtbl), but that takes time and the node is offline meanwhile. Put the tables on an SSD you trust, not a cheap USB stick.
  • If the OS and the tables share the SSD, keep an eye on free space and wear. Compaction rewrites the table each time it runs.

If you run hashstore nodes on HDDs and have an SSD in the machine anyway, I think this is one of the cheapest performance improvements available right now. I’d be interested in numbers from other setups, especially from people who run memtbl on machines with enough RAM.

What filesystem?

I don’t expect this to make any difference on zfs: reads are cached, and writes are batched. But I’ll try as a matter of experiment – move them to a new dataset with small block size equal to record size.

This sounds like a way to run more nodes on the same-drive/same-pool. Normally you’d run into iops issues… but placing the hashtbl on flash would give the HDDs a bit more room to breath?

Cool setup!

I am using ext4.

In terms of upload success rate it makes no difference. At least not for my setup. But it does speed up my downloads. One less disk seek per download. That might not increase my payout at the end of the month but it might help to satisfy customers and that would have a positive impact long term. I have the SSD still installed from old piecestore times so I can as well make use of that.

Huh, interesting! I’ll give this a try later, and check if my beloved nodes will be a bit more quiet afterthefact

How to activate memtbl?

hashstore.table-default-kind: (hashtbl or memtbl)

I am a bit worried about the wear (just had to replace the SSDs in my server and want to make sure the new ones last longer :sweat_smile:).
Does it only write to the SSD while compaction? If not, can you estimate how much a day or month per TB stored gets written to it besides compaction?

Hard to say. I am increasing compact as well. About 1 TB per year per TB used space. So even with high compact load the SSD would still survive years.

Edit: If you have the memory memtable should be the better option.

Are you sure that works? My node complained that it didn’t know what “hashstore.table-path” was… but it accepted “hashstore.tablepath” (without the dash). But then that’s a path that’s outside the container by the time the node is running to even read config.yaml?

Do you maybe still need to use some bind mounts?

I’m doing something wrong… :winking_face_with_tongue:

I think I figured it out. I did need a mount in my docker-compose, like this:

volumes:
- /storjhashtbl/storjnode:/app/config/storage/hashtbls

(Where /storjhashtbl/storjnode is the path on the SSD that has the [SATELLITE]/[Sx]/meta directories copied under it.)

Then I added this to config.yaml

hashstore.table-path: “hashtbls”

The correct name is

But you are correct, you need to add a new binding mount.

What is the version of your storagenode? Also, please, provide a result of this command:

docker exec -it storagenode /app/bin/storagenode setup --help | grep hashstore.table

Yes, it is working with hashstore.table-path now in the config file. Thank you!

I think where littleskunk says " Add hashstore.table-path: /path/on/ssd/node1 to config.yaml" is confusing… because you definately don’t use the external SSD path. You just use a placeholder name (like I used ‘hashtbls’)… then you use that same name in the bind mount.

He doesn’t use docker, it’s a service-based setup.

If your server manages to wear out SSD – it’s either misconfigured, and you experience write amplification, or you have genuinely high load.

Im the latter case, additional load from storagenode will be negligible in comparison.

It could be a consumer grade SSD, they are prone to wearing.

@littleskunk Nice comparison.

Would be interesting to see results of mmap + hashstore.

We had the same fear, so we started monitoring internal metrics of nvme drives. Overall we didn’t see drastic wear rate, just very limited rate. But depends on your hardware.

Thank you, i will move it to the ssd then.
I think I just had bad luck with the old SSD, was waaaay off from the specified TBW before the available spare reached 0.

Does anything need to be rebuilt, if going from normal table to memtable?