Skip to content

Add CI workflow for Java projects using Maven#6

Merged
rag-nar1 merged 6 commits intomasterfrom
delete-btree
May 20, 2025
Merged

Add CI workflow for Java projects using Maven#6
rag-nar1 merged 6 commits intomasterfrom
delete-btree

Conversation

@rag-nar1
Copy link
Copy Markdown
Collaborator

@rag-nar1 rag-nar1 commented May 19, 2025

Summary by CodeRabbit

  • Chores
    • Introduced automated continuous integration for Java projects using Maven. Builds and tests are now triggered automatically on pushes and pull requests to the master branch.
    • Updated file tracking to allow more files in the storage directory while ignoring only specific file types.
    • Added a placeholder README file in the storage directory.
  • New Features
    • Added a new benchmark test measuring concurrent insert and search performance on the B-tree with detailed timing and throughput metrics.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented May 19, 2025

"""

Walkthrough

A new GitHub Actions workflow file named ci.yml has been added to automate continuous integration for a Java project using Maven. The workflow runs on pushes and pull requests to the master branch, performing code checkout, JDK setup, Maven dependency caching, and project build and verification. Additionally, the .gitignore file was modified to only ignore .btree files inside the storage directory instead of the entire directory, a placeholder README was added to the storage folder, and new benchmark test methods with detailed concurrent insert/search timing were introduced in BtreeBenchmark.java.

Changes

File(s) Change Summary
.github/workflows/ci.yml Added a CI workflow for Maven-based Java projects: triggers on master branch, sets up JDK 21, caches Maven dependencies, and runs mvn test -Dtest=BtreeBenchmark.
.gitignore Modified to ignore only *.btree files inside the storage directory instead of ignoring the entire directory.
storage/README.md Added a placeholder README file with the text "place holder".
src/test/btree/BtreeBenchmark.java Added setUp2() method initializing key/value types differently; added testBtreeBenchmark4() performing concurrent insert and search benchmarks with detailed timing and throughput metrics.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub
    participant Runner
    participant Maven

    GitHub->>Runner: Trigger workflow on push/PR to master
    Runner->>Runner: Checkout code
    Runner->>Runner: Set up JDK 21 (Temurin)
    Runner->>Runner: Cache Maven dependencies
    Runner->>Maven: Run mvn test -Dtest=BtreeBenchmark
    Maven-->>Runner: Build and test results
    Runner-->>GitHub: Report CI status
Loading
sequenceDiagram
    participant TestRunner
    participant WriterThreads
    participant ReaderThreads

    TestRunner->>WriterThreads: Create 200 writer threads for inserts
    TestRunner->>WriterThreads: Shuffle and start all writers
    WriterThreads-->>TestRunner: Report insert timings per operation
    TestRunner->>WriterThreads: Join all writer threads

    TestRunner->>ReaderThreads: Create 200 reader threads for searches
    TestRunner->>ReaderThreads: Shuffle and start all readers
    ReaderThreads-->>TestRunner: Report search timings per operation
    TestRunner->>ReaderThreads: Join all reader threads

    TestRunner->>TestRunner: Calculate and print average times and throughput
Loading

Poem

🐇
A workflow hops into the scene,
With Maven builds so crisp and clean.
On master’s push, it springs to life,
Testing code to banish strife.
Storage now holds just a note,
Ignoring btrees, we stay afloat.
Benchmarks race with threads galore,
Timing inserts, searches, and more!
🌱
"""

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
.github/workflows/ci.yml (4)

3-10: Remove trailing spaces & confirm default branch
Line 8 has trailing whitespace after branches:—please remove it. Also verify that master is indeed your repository’s default branch; many newer projects use main.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 8-8: trailing spaces

(trailing-spaces)


16-17: Pin to latest major or specific commit
Consider upgrading actions/checkout@v3 to the latest stable major (@v4) or pinning to a full SHA to avoid unexpected changes when a new minor version is released.

🧰 Tools
🪛 actionlint (1.7.7)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)

[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)


19-24: Java setup & optional matrix
Using actions/setup-java@v3 with Temurin and a fixed version (21) ensures reproducibility.
Optionally, if you need cross-JDK compatibility, you could convert this into a strategy.matrix to test against multiple versions (e.g., 8, 11, 17, 21).

🧰 Tools
🪛 actionlint (1.7.7)

20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


34-34: Add newline at end of file
Please add a trailing newline to satisfy POSIX conventions and resolve YAML lint errors.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 34-34: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 8cb49c5 and dfd9236.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 8-8: trailing spaces

(trailing-spaces)


[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)


[error] 34-34: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (3)
.github/workflows/ci.yml (3)

1-2: Workflow name clarity
The name: Java CI with Maven is clear and descriptive, making it easy to identify in the Actions UI.


25-32: Maven cache configuration looks good
Caching ~/.m2 keyed by your pom.xml hash will greatly speed up dependency resolution on subsequent runs.

🧰 Tools
🪛 actionlint (1.7.7)

26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


33-34: Build and test step is concise
Running mvn clean verify covers compilation, testing, and plugin checks in a single command—this is a solid approach.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 34-34: no new line character at the end of file

(new-line-at-end-of-file)

Comment on lines +15 to +17
steps:
- name: Checkout code
uses: actions/checkout@v3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix indentation for steps entries
The list under steps: should be indented by 6 spaces (not 4) to satisfy YAML syntax.
Apply this diff:

-    steps:
-    - name: Checkout code
+      steps:
+      - name: Checkout code

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 actionlint (1.7.7)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)

[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)

🤖 Prompt for AI Agents
In .github/workflows/ci.yml around lines 15 to 17, the entries under the steps
key are indented with 4 spaces instead of the required 6 spaces for proper YAML
syntax. Adjust the indentation of all lines under steps to be 6 spaces to ensure
correct parsing of the workflow file.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)

15-17: Fix indentation for steps entries.
A previous review called this out—each - name: item under steps: needs two more spaces (6 spaces total) to parse correctly.

Apply this diff for the first step (repeat for all steps):

-    - name: Checkout code
+      - name: Checkout code
🧰 Tools
🪛 actionlint (1.7.7)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)

[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)

🧹 Nitpick comments (4)
.github/workflows/ci.yml (4)

3-10: Review trigger configuration.
This workflow only runs on master for both push and pull_request events. If you maintain additional branches (e.g., develop, release/*) or want CI on forked PRs, consider expanding the branch list or trigger scope.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 8-8: trailing spaces

(trailing-spaces)


8-8: Remove trailing whitespace.
There’s an extra space after branches: which may trip stricter YAML parsers or linters.

-    branches: 
+    branches:
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 8-8: trailing spaces

(trailing-spaces)


33-35: Remove redundant storage management.
The workflow creates and then immediately deletes a storage directory, but none of the steps reference it. You can simplify maintenance by removing both the Ensure storage directory exists and Clean up storage directory steps.

Also applies to: 39-40


40-40: Add newline at end of file.
Ensure the file ends with a newline character to comply with POSIX standards and avoid linter warnings.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 40-40: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between dfd9236 and 662ad3a.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 8-8: trailing spaces

(trailing-spaces)


[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)


[error] 40-40: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (4)
.github/workflows/ci.yml (4)

1-2: Workflow name is clear.
The title Java CI with Maven accurately reflects the job’s purpose.


19-24: JDK setup is correct.
Using actions/setup-java@v3 to install Temurin JDK 21 meets the project’s requirements.

🧰 Tools
🪛 actionlint (1.7.7)

20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


25-32: Maven caching configuration is appropriate.
Caching the entire ~/.m2 directory keyed by the hash of all pom.xml files will speed up subsequent builds.

🧰 Tools
🪛 actionlint (1.7.7)

26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


36-38: Maven build and test step is correct.
Running mvn clean verify will compile, test, and verify the project as intended.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)

15-17: ⚠️ Potential issue

Fix indentation under steps: critical for workflow parsing.
Each step item (- name:) must be indented two levels (6 spaces) under steps:.

@@
-    - name: Checkout code
-      uses: actions/checkout@v3
+      - name: Checkout code
+        uses: actions/checkout@v3
🧰 Tools
🪛 actionlint (1.7.7)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)

[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)

🧹 Nitpick comments (2)
.github/workflows/ci.yml (2)

8-8: Remove trailing whitespace to avoid YAML parsing issues.
There’s a stray space after the branches: key on line 8, which can cause linting errors. Please remove the trailing space.

-    branches: 
+    branches:
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 8-8: trailing spaces

(trailing-spaces)


25-32: Use built-in Maven caching in setup-java (optional).
Since actions/setup-java@v3 supports a cache: 'maven' option, you can simplify by removing the separate actions/cache step:

-    - name: Cache Maven packages
-      uses: actions/cache@v3
-      with:
-        path: ~/.m2
-        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
-        restore-keys: |
-          ${{ runner.os }}-maven-
+    - name: Set up JDK and cache Maven
+      uses: actions/setup-java@v3
+      with:
+        java-version: '21'
+        distribution: 'temurin'
+        cache: 'maven'
🧰 Tools
🪛 actionlint (1.7.7)

26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 662ad3a and 9b2b3ca.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (1 hunks)
  • .gitignore (1 hunks)
  • storage/README.md (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • storage/README.md
  • .gitignore
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 8-8: trailing spaces

(trailing-spaces)


[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
.github/workflows/ci.yml (1)

5-9: Verify the default branch name in your repository.
This workflow only triggers on master. If your repo’s default branch is named main (or something else), you’ll need to update the branch filters.

Could you confirm your repository’s default branch name and adjust the push and pull_request triggers accordingly?

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 8-8: trailing spaces

(trailing-spaces)

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)

15-17: Fix indentation for steps entries.
This addresses the YAML lint warning—each entry under steps: must be indented by 6 spaces rather than 4.

🧰 Tools
🪛 actionlint (1.7.7)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)

[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)

🧹 Nitpick comments (3)
.github/workflows/ci.yml (3)

8-8: Remove trailing whitespace.
Line 8 has trailing spaces after branches: which may cause YAML linting errors. Please remove the extra spaces.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 8-8: trailing spaces

(trailing-spaces)


19-23: Consider testing against multiple JDK versions.
You can expand coverage by using a matrix strategy to run the build on multiple Java versions (e.g., 11, 17, 21).

    strategy:
      matrix:
        java-version: ['11', '17', '21']

Insert this under the build job before runs-on.

🧰 Tools
🪛 actionlint (1.7.7)

20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


34-35: Run full test suite or separate benchmark step.
Currently, only BtreeBenchmark tests are executed. If you intend to run the entire test suite, remove -Dtest=BtreeBenchmark. Alternatively, split benchmarks into a dedicated job for clearer reporting.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 9b2b3ca and 4be74dd.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 8-8: trailing spaces

(trailing-spaces)


[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
.github/workflows/ci.yml (1)

6-9: Verify default branch naming.
The workflow is configured to trigger on pushes and pull requests to the master branch. Please confirm that your repository’s default branch is indeed named master. If it uses main (or another name), update these triggers accordingly.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 8-8: trailing spaces

(trailing-spaces)

Comment on lines +15 to +35
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '21' # Or 11, 21, etc.
distribution: 'temurin' # Recommended distribution

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-


- name: Build and test with Maven
run: mvn test -Dtest=BtreeBenchmark
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Restructure steps for correct YAML and improved clarity.
Consolidate each step to group name, uses, and with under the same list item with proper 6-space indentation.

Apply this diff:

-    steps:
-    - name: Checkout code
-      uses: actions/checkout@v3
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v3

-    - name: Set up JDK
-      uses: actions/setup-java@v3
-      with:
-        java-version: '21'
-        distribution: 'temurin'
+      - name: Set up JDK
+        uses: actions/setup-java@v3
+        with:
+          java-version: '21'
+          distribution: 'temurin'

-    - name: Cache Maven packages
-      uses: actions/cache@v3
-      with:
-        path: ~/.m2
-        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
-        restore-keys: |
-          ${{ runner.os }}-maven-
+      - name: Cache Maven packages
+        uses: actions/cache@v3
+        with:
+          path: ~/.m2
+          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+          restore-keys: |
+            ${{ runner.os }}-maven-

-    - name: Build and test with Maven
-      run: mvn test -Dtest=BtreeBenchmark
+      - name: Build and test with Maven
+        run: mvn test -Dtest=BtreeBenchmark
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '21' # Or 11, 21, etc.
distribution: 'temurin' # Recommended distribution
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and test with Maven
run: mvn test -Dtest=BtreeBenchmark
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '21' # Or 11, 21, etc.
distribution: 'temurin' # Recommended distribution
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and test with Maven
run: mvn test -Dtest=BtreeBenchmark
🧰 Tools
🪛 actionlint (1.7.7)

17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


20-20: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


26-26: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)

[warning] 16-16: wrong indentation: expected 6 but found 4

(indentation)

🤖 Prompt for AI Agents
In .github/workflows/ci.yml between lines 15 and 35, the steps are not properly
indented and grouped, causing YAML structure issues. Fix this by ensuring each
step is a single list item with the keys 'name', 'uses', and 'with' properly
nested under it with consistent 6-space indentation. This will improve clarity
and ensure the workflow runs correctly.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/test/btree/BtreeBenchmark.java (2)

44-54: Avoid duplicating setUp logic – consolidate via a parameterised helper
setUp2() repeats ~90 % of the original setUp() with only the Template-shape differing. This duplication increases maintenance cost and the risk of the two initialisations drifting apart (e.g. buffer-pool sizing, file path, etc.).

Create a private helper that accepts the desired Template shape and invoke it from both @Before and custom setups, e.g.

-@Before
-public void setUp() {
-  CleanUp();
-  ...
-  keyType = new Template(Integer.class, Integer.class);
-  ...
-}
-
-public void setUp2() {
-  CleanUp();
-  ...
-  keyType = new Template(Integer.class);
-  ...
-}
+private void initBtree(Template keyT, Template valueT) {
+  CleanUp();
+  diskManager  = new BasicDiskManager();
+  bufferPool   = new BufferPool(MAX_PAGES, K, diskManager);
+  keyType      = keyT;
+  valueType    = valueT;
+  btree        = new Btree(keyType, valueType, btreeFilePath, Globals.INVALID_PAGE_ID, bufferPool);
+}
+
+@Before
+public void setUp()   { initBtree(new Template(Integer.class, Integer.class), new Template(Integer.class)); }
+
+public void setUp2()  { initBtree(new Template(Integer.class),               new Template(Integer.class)); }

This keeps behaviour identical while eliminating redundancy.


599-669: Consider an ExecutorService instead of manually managing 400 threads
Spawning 400 raw Thread objects per benchmark iteration incurs non-trivial scheduling overhead and obscures exception propagation. A fixed-size ExecutorService (e.g. Executors.newFixedThreadPool(writersCnt + readersCnt)) would:

  1. Re-use worker threads between tasks, reducing startup cost.
  2. Allow submission of callables/futures, making it easier to fail fast on exceptions.
  3. Support graceful shutdown.

While this is a performance benchmark, the thread-pool approach still yields comparable realism while simplifying the code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 4be74dd and 8a3e9b6.

📒 Files selected for processing (1)
  • src/test/btree/BtreeBenchmark.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

Comment on lines +592 to +634
double[] insertTimes = new double[2 * keysnumber];
double[] searchTimes = new double[keysnumber];

threads = new ArrayList<>();
double startTime = (double) System.currentTimeMillis();
double startTimeW = (double) System.currentTimeMillis();
// Insert operations
for (int i = 0; i < writersCnt; i++) {
final int end = op * (i + 1);
Thread writer =
new Thread(
() -> {
for (int key = end - op; key < end; key++) {
try {
long insertStartTime = System.currentTimeMillis();
btree.insert(
makeCompositekey(key, keyType),
makeCompositekey(key, valueType));
long insertEndTime = System.currentTimeMillis();
insertTimes[key] = (insertEndTime - insertStartTime);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
});
threads.add(writer);
}

Collections.shuffle(threads);
for (Thread thread : threads) {
thread.start();
}

for (Thread thread : threads) {
thread.join();
}

double insertTotalTime = System.currentTimeMillis() - startTimeW;
totalInsertTimes[iteration] = insertTotalTime;
avgInsertTimes[iteration] = Arrays.stream(insertTimes).average().getAsDouble();
insertThroughputs[iteration] = 2 * keysnumber / insertTotalTime * 1000;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect array sizing & throughput maths in testBtreeBenchmark4
testBtreeBenchmark4() performs insert-only work, yet:

  • insertTimes is sized to 2 * keysnumber (line 592) – half of this array remains zero-filled, biasing the average downward.
  • Throughput uses 2 * keysnumber (line 633) – overstating throughput by 100 %.

Fix both to reflect the real number of operations:

-      double[] insertTimes = new double[2 * keysnumber];
+      double[] insertTimes = new double[keysnumber];

-      insertThroughputs[iteration] = 2 * keysnumber / insertTotalTime * 1000;
+      insertThroughputs[iteration] = 1.0 * keysnumber / insertTotalTime * 1000;

Without this change, the reported benchmarks are misleading and could mask performance regressions.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
double[] insertTimes = new double[2 * keysnumber];
double[] searchTimes = new double[keysnumber];
threads = new ArrayList<>();
double startTime = (double) System.currentTimeMillis();
double startTimeW = (double) System.currentTimeMillis();
// Insert operations
for (int i = 0; i < writersCnt; i++) {
final int end = op * (i + 1);
Thread writer =
new Thread(
() -> {
for (int key = end - op; key < end; key++) {
try {
long insertStartTime = System.currentTimeMillis();
btree.insert(
makeCompositekey(key, keyType),
makeCompositekey(key, valueType));
long insertEndTime = System.currentTimeMillis();
insertTimes[key] = (insertEndTime - insertStartTime);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
});
threads.add(writer);
}
Collections.shuffle(threads);
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
double insertTotalTime = System.currentTimeMillis() - startTimeW;
totalInsertTimes[iteration] = insertTotalTime;
avgInsertTimes[iteration] = Arrays.stream(insertTimes).average().getAsDouble();
insertThroughputs[iteration] = 2 * keysnumber / insertTotalTime * 1000;
double[] insertTimes = new double[keysnumber];
double[] searchTimes = new double[keysnumber];
threads = new ArrayList<>();
double startTime = (double) System.currentTimeMillis();
double startTimeW = (double) System.currentTimeMillis();
// Insert operations
for (int i = 0; i < writersCnt; i++) {
final int end = op * (i + 1);
Thread writer =
new Thread(
() -> {
for (int key = end - op; key < end; key++) {
try {
long insertStartTime = System.currentTimeMillis();
btree.insert(
makeCompositekey(key, keyType),
makeCompositekey(key, valueType));
long insertEndTime = System.currentTimeMillis();
insertTimes[key] = (insertEndTime - insertStartTime);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
});
threads.add(writer);
}
Collections.shuffle(threads);
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
double insertTotalTime = System.currentTimeMillis() - startTimeW;
totalInsertTimes[iteration] = insertTotalTime;
avgInsertTimes[iteration] = Arrays.stream(insertTimes).average().getAsDouble();
insertThroughputs[iteration] = 1.0 * keysnumber / insertTotalTime * 1000;
🤖 Prompt for AI Agents
In src/test/btree/BtreeBenchmark.java around lines 592 to 634, the insertTimes
array is incorrectly sized to 2 * keysnumber, causing half the array to remain
zero and biasing the average insert time. Also, the throughput calculation
incorrectly multiplies keysnumber by 2, overstating throughput. Fix this by
resizing insertTimes to keysnumber and adjusting the throughput calculation to
use keysnumber instead of 2 * keysnumber to accurately reflect the number of
insert operations performed.

@rag-nar1 rag-nar1 merged commit 41ad246 into master May 20, 2025
2 checks passed
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