refactor: update load test implementation to use DatabaseWrapper and enhance parameters#2329
refactor: update load test implementation to use DatabaseWrapper and enhance parameters#2329
Conversation
…enhance parameters wip
There was a problem hiding this comment.
Summary of Changes
Hello @robfrank, 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 refactors and expands the existing performance test suite for ArcadeDB. It generalizes the database interaction layer, introduces new test scenarios for 'likes' relationships, and enhances the robustness of data insertion and transaction management. The changes aim to provide more flexible, comprehensive, and insightful performance measurements for the ArcadeDB system.
Highlights
- Refactored Database Interaction: The
DatabaseWrapperhas been refactored to accepthostandportdirectly instead of aGenericContainer, making it more flexible for connecting to various database instances (local or containerized). TheLocalhostDatabaseWrapperhas been updated to use this new genericDatabaseWrapper. - Enhanced Load Test Scenarios: The
SingleLocalhostServerSimpleLoadTestITandSingleServerLoadTestITnow include new parameters (numOfFriendship,numOfLike) and logic to create 'Likes' relationships, expanding the scope of performance testing beyond just users and photos. TheSingleServerSimpleLoadTestIThas been simplified to focus solely on users and photos. - Improved Transaction Handling in
DatabaseWrapper: Database operations for adding users, photos, and friendships withinDatabaseWrappernow utilizesqlscriptwith explicitBEGIN; LOCK TYPE; COMMIT RETRY;commands. This provides more robust and atomic transaction management, replacing the previousdb.transactionanddb.acquireLockapproach. - Comprehensive Bucket Locking: The
LocalTransactionExplicitLockin the core engine has been enhanced to include all polymorphic buckets when locking by type. This ensures more thorough pessimistic locking, especially in scenarios involving inheritance or complex schema structures, improving transaction reliability. - New Generic ID Supplier: A new
TypeIdSupplierclass has been introduced to generalize the process of fetching IDs for any given type (e.g., 'User', 'Photo') in batches. This replaces the previousUserIdSupplier, promoting code reusability and maintainability. - Enhanced Performance Test Metrics and Logging: Load tests now include detailed logging for test start/finish times, total duration, and expose Micrometer metrics. This provides better observability and insights into the performance characteristics of the database operations during testing.
- Adjusted Container Memory Allocation: The default memory allocation for ArcadeDB containers in performance tests has been reduced from 16GB to 8GB (
-Xms8G -Xmx8G), potentially optimizing resource consumption during test execution.
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 is currently in preview and 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 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
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request refactors the performance tests by introducing a more generic DatabaseWrapper, enhancing test parameters, and adding new entities like 'likes' to the load tests. The changes improve the flexibility and realism of the performance testing suite. My review has identified a bug that could cause a division-by-zero error, as well as issues related to code clarity. Addressing these points will further improve the quality of the code.
| } | ||
| addFriendship(userId1, userId2); | ||
| count++; | ||
| if (count % pauseEvery == 0) { |
There was a problem hiding this comment.
There is a potential for a division-by-zero error here. pauseEvery is calculated as numOfFriendships / 10. If numOfFriendships is greater than 0 but less than 10, pauseEvery will be 0. The modulo operation count % pauseEvery will then throw an ArithmeticException. You should add a check to ensure pauseEvery is greater than zero before the modulo operation.
| if (count % pauseEvery == 0) { | |
| if (pauseEvery > 0 && count % pauseEvery == 0) { |
| } | ||
| addLike(userId, photoId); | ||
| count++; | ||
| if (count % pauseEvery == 0) { |
There was a problem hiding this comment.
Similar to the createFriendships method, there is a potential for a division-by-zero error here. pauseEvery is calculated as numOfLikes / 10. If numOfLikes is between 1 and 9, pauseEvery will be 0, causing an ArithmeticException from the modulo operator. Please add a guard to prevent this.
| if (count % pauseEvery == 0) { | |
| if (pauseEvery > 0 && count % pauseEvery == 0) { |
| // Each thread will create friendships | ||
| executor.submit(() -> { | ||
| DatabaseWrapper db1 = new DatabaseWrapper(host, port, idSupplier); | ||
| ; |
| // Each thread will create friendships | ||
| executor.submit(() -> { | ||
| DatabaseWrapper db1 = new DatabaseWrapper(host, port, idSupplier); | ||
| ; |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
What does this PR do?
Enanche Perfs tests
Checklist
mvn clean packagecommand