[sql-64] firewalldb: add database benchmarking for firewalldb package#1232
Conversation
Summary of ChangesHello @ViktorT-11, 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 enhances the project's database infrastructure by introducing robust benchmarking capabilities for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request adds a comprehensive benchmarking suite for the accounts, session, and firewalldb packages, comparing kvdb-bbolt, sqlite, and postgres backends. The changes include new unit-bench Makefile targets, benchmark test files for each package, and documentation on how to run them. The benchmark implementations are well-structured and correctly isolate the code under test. I have a couple of suggestions to improve the clarity of resource cleanup in the firewalldb benchmarks and to make the documentation more generic and easier to use.
| grep '^BenchmarkAccountStore/kvdb-bbolt/' /tmp/run.txt | \ | ||
| sed 's#BenchmarkAccountStore/kvdb-bbolt/#BenchmarkAccountStore/#' \ | ||
| > /tmp/kvdb.norm.txt | ||
| grep '^BenchmarkAccountStore/native-sqlite/' /tmp/run.txt | \ | ||
| sed 's#BenchmarkAccountStore/native-sqlite/#BenchmarkAccountStore/#' \ | ||
| > /tmp/sqlite.norm.txt |
There was a problem hiding this comment.
The example commands for benchstat are specific to the accounts package (BenchmarkAccountStore). To make this documentation more reusable for other packages like session and firewalldb, consider using a variable for the benchmark name prefix.
For example:
# Set BENCH_PREFIX based on the package being benchmarked.
# For pkg=accounts: BENCH_PREFIX='BenchmarkAccountStore'
# For pkg=session: BENCH_PREFIX='BenchmarkSessionStore'
# For pkg=firewalldb: BENCH_PREFIX='BenchmarkFirewallDB'
grep "^${BENCH_PREFIX}/kvdb-bbolt/" /tmp/run.txt | \
sed "s#^${BENCH_PREFIX}/kvdb-bbolt/#${BENCH_PREFIX}/#" \
> /tmp/kvdb.norm.txt
grep "^${BENCH_PREFIX}/native-sqlite/" /tmp/run.txt | \
sed "s#^${BENCH_PREFIX}/native-sqlite/#${BENCH_PREFIX}/#" \
> /tmp/sqlite.norm.txtThis would make it clearer how to adapt the commands for different benchmark suites.
| require.NoError( | ||
| b, firewallStore.Close(), | ||
| ) |
There was a problem hiding this comment.
For clarity and robustness, it's better to close the sqlStore that owns the database connection, rather than one of the stores that uses it (firewallStore). This makes it explicit that the shared resource used by both firewallStore and sessStore is being cleaned up.
| require.NoError( | |
| b, firewallStore.Close(), | |
| ) | |
| require.NoError( | |
| b, sqlStore.Close(), | |
| ) |
| require.NoError( | ||
| b, firewallStore.Close(), | ||
| ) |
There was a problem hiding this comment.
Similar to the sqlite backend, it's clearer to close the sqlStore that owns the database connection, rather than one of the stores that uses it (firewallStore). This makes it explicit that the shared resource is being cleaned up.
| require.NoError( | |
| b, firewallStore.Close(), | |
| ) | |
| require.NoError( | |
| b, sqlStore.Close(), | |
| ) |
Based on #1231
Implements the last part of step 7. of "Phase 3" in #917.
This PR implements benchmarking tests for different database backends in the firewalldb package.