Skip to content

graph/db: helper tests and some benchmarks for SQL #10109

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

Merged
merged 6 commits into from
Jul 30, 2025

Conversation

ellemouton
Copy link
Collaborator

@ellemouton ellemouton commented Jul 25, 2025

This PR adds:

  • some helper tests that can be used to populate a local graph (with any backend type) from a source graph (also from any backend type).
  • Another helper is added that does the same but via the Migrate SQL function.
  • Then, a few benchmark tests are added that can be used to test cache loading and describe graph calls against various graph db backend types.

These benchmarks will be useful for upcoming PRs which will start introducing some performance improvements. The benckmarks will let us ensure that we are in fact introducing valuable improvements

@ellemouton ellemouton self-assigned this Jul 25, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ellemouton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the testing and performance analysis capabilities within the graph/db package. It introduces robust helper tests for populating graph databases across various backend types, including a dedicated test for the KVDB to SQL migration process. Crucially, it adds a suite of benchmarks to measure key graph operations like cache loading and data iteration, providing valuable insights into performance characteristics. Additionally, the existing SQL migration logic has been improved with better progress reporting.

Highlights

  • New Testing Utilities: Introduced helper tests (TestPopulateDBs) to populate local graph databases from a source graph, supporting various backend types (bbolt, sqlite, postgres for both KVDB and native SQL). This includes a syncGraph utility for data replication.
  • SQL Migration Helper: Added TestPopulateViaMigration to specifically test and facilitate the migration of graph data from KVDB-backed databases to native SQL databases, leveraging the existing migration logic.
  • Performance Benchmarks: Implemented several benchmark tests (BenchmarkCacheLoading, BenchmarkForEachNode, BenchmarkForEachChannelAndPolicy) to measure the performance of graph cache loading and graph traversal operations across different database backends.
  • Migration Progress Logging: Enhanced the SQL migration functions (migrateNodes, migrateChannelsAndPolicies, migratePruneLog, migrateClosedSCIDIndex, migrateZombieIndex) by adding rate-limited progress logging, providing real-time feedback during large data migrations.
  • Logging Infrastructure Update: Updated the btclog import to btclog/v2 and adjusted the graphdb.Subsystem logger registration from AddV1SubLogger to AddSubLogger for consistency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces helper tests and benchmarks for SQL, including helper tests to populate a local graph from a source graph, another helper to do the same via the Migrate SQL function, and benchmark tests to test cache loading and describe graph calls against various graph DB backend types. Several comments were made to address line length issues.

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff 💯 Very nice helpers and benchmark tests, LGTM 🎉

Copy link
Collaborator Author

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, updated! Also just refactored the last commit to change the benchmarks to a single table driven one so that it is easy to expand it in future with more calls

@ellemouton ellemouton force-pushed the graphPerf1 branch 2 times, most recently from b841b78 to a8695e1 Compare July 29, 2025 09:57
Copy link
Collaborator

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I only have one comment that needs attention.

This is a prep commit that just adds all the boilerplate connection
logic for connecting to various graph DBs. These will be used in
upcoming commits which will add tests and benchmarks.
This commit adds a helper test that is similar to TestPopulateDBs except
for the fact that it uses the MigrateGraphToSQL function directly to
migrate a local kvdb-sql graph to a native SQL one.
Add a benchmark test to test graph cache loading against various local
graph DBs.
This commit adds benchmark tests for the ForEachNode and ForEachChannel
DB calls which are called by DescribeGraph.
Copy link
Collaborator

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@ellemouton
Copy link
Collaborator Author

cc @guggero for override merge 🙏 the test fail is invoice registry related

@guggero guggero merged commit 117035d into lightningnetwork:master Jul 30, 2025
33 of 39 checks passed
@ellemouton ellemouton deleted the graphPerf1 branch July 30, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants