Benchmarking c-lightning

grubles
Blockstream Engineering Blog
4 min readFeb 24, 2021

Stay humble. Stack stats.

Unlike Bitcoin nodes, which must process all payments on the network, Lightning nodes only process the payments routed through them. Therefore the bottleneck to payment throughput becomes a matter of connection latency, hardware performance, and channel liquidity (depending on the payment size).

Blockstream’s c-lightning implementation is suitable for running on a wide range of hardware. Designed to be lightweight and performant, c-lightning is also extendable with plugins. Plugins allow you to customize your c-lightning node with additional features to fit your needs. This means you can run a lightweight bare bones c-lightning instance on the lowest of the low-end hardware for day to day purchases (such as swag from the Blockstream Store!), or run an instance on beefier server-grade hardware with many plugins to provide payment routing.

In this article, we’re going to look at the results of some c-lightning benchmarking tests I completed on my own hardware, then go through a guide on how you can perform the benchmark on your own.

Hardware testing

There is a simple benchmark script you can run to see how well c-lightning will perform in an optimized environment. The benchmark creates two regtest c-lightning nodes running in memory, tells one node to pre-generate 10,000 invoices, then the second node pays the invoices. The benchmark measures how quickly the 10,000 invoices are paid.

I went ahead and ran the benchmark on a handful of different devices already. The range of devices I ran the benchmark on started at the ~$45 Rock64 ARM-based SoC (which is similar to a Raspberry Pi 4), to a modern laptop Intel i7–8665U, to a modern, third-generation AMD Ryzen 3600X, and finally to a beefy IBM POWER9. Of the devices I benchmarked, the i7 and Ryzen processors were the fastest, with the POWER9 in 3rd place and the Rock64 unsurprisingly in last place.

The (admittedly small) set of data suggests that since the benchmark is only utilizing the CPU for a short amount of time, it seems to benefit from better single-core performance and possibly from a higher temporary “boost” clock. I suspect this because one would assume the POWER9, with 8 cores, 32 threads, and 80 MB of L3 cache, would do much better than the Intel and AMD processors. However, it has slower single-core performance compared to the Intel and AMD processors. A workstation or server CPU will likely be better suited for sustained payments processing, rather than the short burst of payments that the benchmark simulates.

The Intel and AMD performance is nearly the same. I’m assuming this is because they both have fewer cores but better single-core performance than the POWER9.

Since the data set is pretty small (only the devices I have lying around in my office), I invite you to run the benchmark on your own devices. I’ve put together a small guide (with Christian Decker’s help) for building an optimized c-lightning and running the benchmark.

Benchmark Tutorial

Download and install Bitcoin Core:

wget https://bitcoincore.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
tar zxvf bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
cp bitcoin-0.21.0/bin/bitcoind /usr/local/bin
cp bitcoin-0.21.0/bin/bitcoin-cli /usr/local/bin

Install the c-lightning build dependencies:

Follow the document here based on the OS you are using. https://github.com/ElementsProject/lightning/blob/master/doc/INSTALL.md

Clone cdecker’s c-lightning fork:

git clone https://github.com/cdecker/lightning
git checkout benchmark
cd lightning

Install the python dependencies:

pip3 install — user \-r requirements.txt \
-r contrib/pyln-client/requirements.txt \
-r contrib/pyln-proto/requirements.txt \
-r contrib/pyln-testing/requirements.txt

Add the custom environment variables when configuring:

DEVELOPER=0 COMPAT=0 EXPERIMENTAL_FEATURES=0 ./configure COPTFLAGS=-O3

Build c-lightning:

make && make install

To run the benchmark:

While in the lightningd/ directory (it’s all one line):

PYTHONPATH=contrib/pylightning:contrib/pyln-client:contrib/pyln-testing:contrib/pyln-proto DEVELOPER=0 VALGRIND=0 TEST_DIR=/dev/shm pytest tests/benchmark.py —-benchmark-autosave —-benchmark-compare

Post your results

The benchmark will take around 10 minutes to complete. At the end, the benchmark script will output how well your computer performed in terms of operations per second (OPS). We specifically want the “test_throughput_single_hop” results. Once you’ve run the benchmark, feel free to submit the benchmark results and then post your results on Twitter with the #clightning hashtag!

The submitted results will be added to this public Google Spreadsheet.

P.S. To check the speed of your RAM, run the following command on Linux:

sudo dmidecode --type 17

The Configured Memory Speed will be your RAM speed.

--

--