From: thepipeline_xyz
Optimizing blockchain performance is crucial, and a significant portion of the cost lies in cryptography functions and state access [00:00:22]. While smart contract business logic is relatively inexpensive to execute compared to typical desktop or phone applications, and optimizing computation alone doesn’t yield substantial gains [00:00:41], the true bottlenecks emerge elsewhere.
Cryptography Overheads
Cryptographic operations, such as elliptical curve cryptography and hashing functions, are inherently costly [00:00:27]. Transaction execution, particularly signature recovery, is one of the most expensive components [00:01:09]. Although some blockchain clients have begun to parallelize signature recovery to mitigate this, there’s a limit to how much performance can be gained solely through computation optimization [00:01:09].
State Access and Database Latency
The most significant performance challenge, however, stems from state access and interactions with the underlying database [00:00:35].
SSD Latency
A single read from an SSD can introduce a latency of 80 to 100 microseconds, or even more, depending on the SSD model and generation [00:01:38]. This duration is “orders of magnitude longer” than the time it takes to execute a simple smart contract [00:01:56].
Sequential Reads in Transactions
Executing a single transaction often necessitates multiple sequential reads from the database. For instance, a transaction requires reading the sender’s account to check their balance, the destination account, and potentially proxy accounts if involved [00:02:07]. Furthermore, data like ERC20 balances or Uniswap data are stored in specific storage slots, requiring additional reads [00:02:18].
If these reads are not cached in main memory, the cumulative latency from these sequential disk accesses results in a “long time” for a single transaction to execute [00:02:30].
Hardware-Software Mismatch
One approach to mitigate this is to equip blockchain nodes with massive amounts of RAM, effectively avoiding disk reads and their associated latencies [00:02:53]. However, this demands very large and expensive hardware, which can restrict decentralization [00:02:56].
Modern SSDs are highly capable, with some offering up to 500,000 I/O operations per second [00:06:53]. The fundamental challenge is that standard databases commonly used in blockchain clients (like Pebble DB, RocksDB, LMDB, LevelDB, and MDBX) fail to fully leverage this raw performance [00:03:48].
The Inefficiency of General-Purpose Databases
The core issue with these widely adopted databases is their general-purpose nature [00:04:49]. They are designed for average performance across a wide range of applications, not for highly specialized use cases like blockchain [00:05:05].
Common problems include:
- Nested Data Structures: Embedding one data structure inside another on disk can lead to very expensive traversal operations for every request [00:04:06].
- Excessive Requests: These general-purpose databases often make numerous requests to the hardware for basic lookups. For example, some standard implementations might require 20 disk requests to look up a single account, whereas an optimized custom database like Bana could do the same in one or two requests [00:07:39]. This “wastes” the underlying hardware’s capability [00:07:33].
The Solution: Custom State Databases
To overcome these technical challenges and solutions in blockchain performance, the importance of custom state databases in blockchain becomes evident. By applying techniques from high-frequency trading (HFT), where standard libraries are bypassed in favor of custom, highly optimized data structures, developers can extract significantly better performance from existing hardware [00:05:10].
A custom database, like Bana Database, is designed with a precise understanding of how blockchain data needs to be stored and accessed [00:05:32]. This tailored approach allows for a reduction in the number of disk requests per operation, maximizing the throughput from high-performance SSDs and addressing the challenges and opportunities in blockchain scalability [00:07:50]. This enables the development of a truly performant blockchain [00:00:15].