Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZFS.md #1694

Merged
merged 23 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions how-to-guides/bridge-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,8 @@ Follow the
[tutorial on setting up the bridge node as a background process with SystemD](./systemd.md).

You have successfully set up a bridge node that is syncing with the network.

### Optional: enable on-fly compression with ZFS

Follow the
[tutorial on how to set up your DA node to use on-fly compression with ZFS](/how-to-guides/zfs.md).
166 changes: 166 additions & 0 deletions how-to-guides/zfs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
description: Learn how to setup your DA node to use on-fly compression with ZFS.
---

# Optional: Setting up your DA node to use ZFS

:::warning
Using ZFS compression may impact node performance depending on your hardware configuration. Ensure your system meets the recommended requirements before proceeding. This is an optional optimization that may not be suitable for all deployments.
:::
kinrokinro marked this conversation as resolved.
Show resolved Hide resolved

Enabling ZFS compression on a DA Node server can significantly optimize storage efficiency by compressing data on the fly. Follow this step-by-step guide to implement ZFS compression without requiring any additional tuning on the DA node.

:::tip NOTE
ZFS, compression `zstd-3`:
```
$ zfs get compressratio celestia && du -h /celestia/bridge/.celestia-bridge
NAME PROPERTY VALUE SOURCE
celestia compressratio 1.22x -
1.3T /celestia/bridge/.celestia-bridge
```
EXT4, no compression:
```
$ du -h ~/.celestia-bridge/
1.8T /home/ubuntu/.celestia-bridge/
```
:::

## Requirements:
1. A bare metal server with:
- RAM: 64GB or more
- CPU: Latest generation EPYC or Xeon with:
- Clock speed: 2.1GHz or higher
- Threads: 32 or higher
- Note: Additional CPU overhead is required for ZFS compression
2. At least one empty disk (with no filesystem)

## Guide:

Get your disk name:
```sh
lsblk --nodeps -o name
```
kinrokinro marked this conversation as resolved.
Show resolved Hide resolved

Verify disk is empty (should show no partitions):
```sh
lsblk YOUR_DISK_NAME (/dev/nvme0n1 or /dev/sda i.e.)
```

Verify disk is not mounted:
```sh
mount | grep YOUR_DISK_NAME
```

Set variables:
```sh
ZFS_POOL_NAME="celestia" && ZFS_DATASET_NAME="bridge"
```
kinrokinro marked this conversation as resolved.
Show resolved Hide resolved

Validate variables are set:
```sh
if [ -z "$ZFS_POOL_NAME" ] || [ -z "$ZFS_DATASET_NAME" ]; then
echo "Error: Variables not set correctly"
exit 1
fi
```

Install ZFS utils:
```sh
sudo apt update && sudo apt install zfsutils-linux
```

Create ZFS pool:
```sh
zpool create -o ashift=12 $ZFS_POOL_NAME /dev/nvme0n1
```
kinrokinro marked this conversation as resolved.
Show resolved Hide resolved

:::tip NOTE
If you have more than one disk available - you can add them also:
```sh
zpool create -o ashift=12 $ZFS_POOL_NAME /dev/nvme0n1 /dev/nvme1n1
```
:::

Create dataset:
```sh
zfs create $ZFS_POOL_NAME/$ZFS_DATASET_NAME
```

Enable compression:
```sh
zfs set compression=zstd-3 $ZFS_POOL_NAME/$ZFS_DATASET_NAME
```

Set the custom path to the bridge data folder:

::: code-group

```sh [Mainnet Beta]
# Add flag --node.store /celestia/bridge/.celestia-bridge to your command, example:
celestia bridge start --metrics.tls=true --metrics --metrics.endpoint otel.celestia.observer --p2p.metrics --node.store /celestia/bridge/.celestia-bridge
```

```sh [Mocha]
# Add flag --node.store /celestia/bridge/.celestia-bridge-mocha-4 to your command, example:
celestia bridge start --metrics.tls=true --metrics --metrics.endpoint otel.mocha.celestia.observer --p2p.metrics --node.store /celestia/bridge/.celestia-bridge-mocha-4 --p2p.network mocha
```

```sh [Arabica]
# Add flag --node.store /celestia/bridge/.celestia-bridge-arabica-11 to your command, example:
celestia bridge start --node.store /celestia/bridge/.celestia-bridge-arabica-11 --p2p.network arabica
```

:::

:::tip NOTE
It is recommended to sync from scratch. In case of using a snapshot it is important to have your local route to `--data.store` identical to one in a snapshot.
:::

After completing the steps above, you can begin syncing your DA node.

You can check your compression rate with the following command:
```sh
zfs get compressratio $ZFS_POOL_NAME
```

## ZFS Fine-Tuning (Advanced)
:::danger
The following settings can significantly impact data integrity and system stability. Only proceed if you fully understand the implications of each setting. These optimizations should be carefully tested in a non-production environment first.
:::
If you want to increase your I/O performance and sync speed, you can try the following steps:
### Disable Auto-Trim
Auto-trim disabling can improve I/O performance, but may lead to increased SSD wear over time.
```sh
sudo zpool set autotrim=off $ZFS_POOL_NAME
```

:::tip NOTE
You always can trim maually: `sudo zpool trim $ZFS_POOL_NAME`
:::
kinrokinro marked this conversation as resolved.
Show resolved Hide resolved

### Disable sync
:::danger
Disabling sync provides faster write speeds but significantly increases the risk of data corruption in case of system crashes or power failures. Data in memory may be permanently lost before being written to disk.

This setting should:
1. Only be used during initial node sync
2. Never be used in production environments
3. Be re-enabled immediately after initial sync completes
:::


### Disable prefetch
Disabling reduces memory usage but can slow down performance for sequential read workloads.
```sh
echo 1 | sudo tee /sys/module/zfs/parameters/zfs_prefetch_disable
```
kinrokinro marked this conversation as resolved.
Show resolved Hide resolved

:::tip NOTE
You can always re-enable it: `echo 0 | sudo tee /sys/module/zfs/parameters/zfs_prefetch_disable`
:::

### Set record size
Setting `recordsize=256K` defines the maximum block size that ZFS will use when writing data to a dataset.
```sh
zfs set recordsize=256K $ZFS_POOL_NAME/$ZFS_DATASET_NAME
```
kinrokinro marked this conversation as resolved.
Show resolved Hide resolved
Loading