Skip to content

Persistent to Hasql #1938

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Persistent to Hasql #1938

wants to merge 20 commits into from

Conversation

Cmdv
Copy link
Contributor

@Cmdv Cmdv commented Jan 30, 2025

Hasql Migration

Summary

The migration from Persistent to Hasql delivered a 3-4x performance improvement in epoch processing time, with some gains in cache efficiency.

Processing Time Comparison

Before (Persistent)

  • Epoch 432: 29 minutes
  • Epoch 433: 32 minutes
  • Average: ~30.5 minutes per epoch

After (Hasql)

  • Epoch 441: 8m 14s
  • Epoch 442: 9m 19s
  • Average: ~8.7 minutes per epoch

Improvement: 73% reduction in processing time (3.5x faster)

Resource Utilisation

Database Connections

  • Before: ORM connection pooling with abstraction overhead
  • After: Direct PostgreSQL connection management
  • Benefit: Reduced connection overhead and more efficient resource usage

Technical Factors Contributing to Performance

1. Eliminated ORM Overhead

  • No runtime type reflection
  • No query generation overhead
  • Direct SQL statement preparation

2. Optimised SQL Generation

  • Hand-crafted SQL statements
  • Better query plans
  • Reduced parsing overhead

3. Type-Safe Operations

  • Compile-time validation reduces runtime checks
  • Efficient encoder/decoder patterns
  • Zero-copy data transformations where possible

4. Connection Management

  • Direct PostgreSQL protocol usage
  • Reduced middleware layers
  • Better connection reuse

Epoch Context

Based on Cardano network data, each epoch processes approximately 21,600 blocks over a 5-day period. The performance improvement scales linearly with blockchain growth, making this migration critical for long-term sustainability.

Conclusion

The Hasql migration represents a significant infrastructure improvement, providing both immediate performance gains and better long-term scalability. The 73% reduction in processing time, positions the system for handling increased blockchain throughput.

@Cmdv Cmdv self-assigned this Jan 30, 2025
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch from f80c67b to 96182d8 Compare March 14, 2025 09:16
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch 2 times, most recently from 89285ee to 2db7312 Compare April 3, 2025 12:16
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch from 7c34694 to f434016 Compare May 8, 2025 15:09
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch 5 times, most recently from a67562c to 94f48af Compare June 30, 2025 22:20
@Cmdv Cmdv marked this pull request as ready for review June 30, 2025 22:21
@Cmdv Cmdv requested a review from a team as a code owner June 30, 2025 22:21
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch 4 times, most recently from 107fc47 to cdab159 Compare July 11, 2025 12:19
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch from cdab159 to 8ce46c6 Compare July 11, 2025 12:41
@Cmdv Cmdv requested a review from a team as a code owner July 11, 2025 12:41
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch 4 times, most recently from c621226 to 08d56ec Compare July 11, 2025 16:07
@Cmdv Cmdv force-pushed the Persistent-to-Hasql branch from 08d56ec to f237b25 Compare July 11, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant