Skip to content
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

[ansible/tuning] Enable NUMA for Raspberry Pi 4 and 5 #219

Merged
merged 1 commit into from
Dec 2, 2024
Merged

Conversation

goldyfruit
Copy link
Member

@goldyfruit goldyfruit commented Dec 2, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new task for tuning configurations specifically for Raspberry Pi 4 and 5 devices.
    • Added support for enabling NUMA (Non-Uniform Memory Access) for improved performance on Raspberry Pi devices.

@goldyfruit goldyfruit added the enhancement New feature or request label Dec 2, 2024
@goldyfruit goldyfruit added this to the Wolfenstein milestone Dec 2, 2024
@goldyfruit goldyfruit self-assigned this Dec 2, 2024
Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

The changes introduce two new tasks in the Ansible playbook for tuning configurations specific to Raspberry Pi devices. The first task, added to main.yml, conditionally includes a new task file for NUMA tuning based on the detected Raspberry Pi model. The second task, defined in numa.yml, enables NUMA support for Raspberry Pi 4 and 5, modifying the cmdline.txt file with specific parameters. Both additions enhance the playbook's functionality without altering existing tasks.

Changes

File Path Change Summary
ansible/roles/ovos_installer/tasks/tuning/main.yml Added task to include tuning/numa.yml conditionally based on ovos_installer_raspberrypi.
ansible/roles/ovos_installer/tasks/tuning/numa.yml Introduced task to enable NUMA for Raspberry Pi 4 and 5, modifying cmdline.txt with specific parameters.

Poem

In the land of Raspberry Pi,
A tune-up task now flutters by.
With NUMA's grace, they dance and play,
Enhancing joy in every way!
So hop along, let's cheer and sing,
For tuning tasks that joy will bring! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@goldyfruit goldyfruit merged commit 2226881 into main Dec 2, 2024
8 checks passed
@goldyfruit goldyfruit deleted the feat/numa branch December 2, 2024 23:25
Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (2)
ansible/roles/ovos_installer/tasks/tuning/numa.yml (1)

3-4: Consider validating the Pi model more strictly

The current condition only checks for string presence. A more robust approach would be to use exact model matching to prevent false positives.

-    _fake_number: "{{ '4' if 'Raspberry Pi 5' in ovos_installer_raspberrypi else '2' }}"
+    _fake_number: >-
+      {{
+        '4' if ovos_installer_raspberrypi == 'Raspberry Pi 5' else
+        '2' if ovos_installer_raspberrypi == 'Raspberry Pi 4' else
+        ansible.builtin.fail('Unsupported Raspberry Pi model')
+      }}
ansible/roles/ovos_installer/tasks/tuning/main.yml (1)

32-34: Consider standardizing RPi model detection

The condition for including the NUMA task uses string matching similar to numa.yml. Consider extracting this logic into a variable or fact for consistency and reuse.

+- name: Set Raspberry Pi model facts
+  ansible.builtin.set_fact:
+    is_supported_pi: >-
+      {{ ovos_installer_raspberrypi in ['Raspberry Pi 4', 'Raspberry Pi 5'] }}
+
 - name: Include tuning/numa.yml
   ansible.builtin.import_tasks: tuning/numa.yml
-  when: "'Raspberry Pi 4' in ovos_installer_raspberrypi or 'Raspberry Pi 5' in ovos_installer_raspberrypi"
+  when: is_supported_pi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4c7cf45 and 472df5c.

📒 Files selected for processing (2)
  • ansible/roles/ovos_installer/tasks/tuning/main.yml (1 hunks)
  • ansible/roles/ovos_installer/tasks/tuning/numa.yml (1 hunks)
🔇 Additional comments (1)
ansible/roles/ovos_installer/tasks/tuning/numa.yml (1)

10-12: Verify NUMA parameters are appropriate for RPi hardware

The NUMA configuration looks correct:

  • numa=fake={{ _fake_number }}: Creates virtual NUMA nodes matching CPU cores
  • numa_policy=interleave: Ensures memory allocation across nodes
✅ Verification successful

NUMA configuration is correctly tailored for RPi hardware

The NUMA configuration is specifically designed for Raspberry Pi 4 & 5:

  • For RPi 5: numa=fake=4 (4 NUMA nodes)
  • For RPi 4: numa=fake=2 (2 NUMA nodes)
  • numa_policy=interleave is appropriately set for both
  • The configuration is only applied when the system is explicitly detected as RPi 4 or 5
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify if these NUMA parameters are commonly used with RPi
rg -A 2 'numa=fake|numa_policy' --type md  # Search docs/discussions

Length of output: 43


Script:

#!/bin/bash
# Search for NUMA configuration patterns in the codebase
rg -A 5 'numa=fake|numa_policy'

# Look for RPi or Raspberry Pi related configuration files
fd -e yml -e yaml | xargs rg -l 'raspberry|rpi' -i

# Check if there are any documentation files about system requirements or hardware
fd 'README|INSTALL|REQUIREMENTS|HARDWARE' -i

Length of output: 2149


Script:

#!/bin/bash
# Check the content of relevant README files and NUMA configuration context
cat ansible/roles/ovos_installer/README.md
cat ansible/roles/ovos_installer/tasks/tuning/numa.yml
cat ansible/roles/ovos_installer/tasks/tuning/main.yml

Length of output: 2120

Comment on lines +5 to +9
ansible.builtin.lineinfile:
path: "{{ _boot_directory }}/cmdline.txt"
regexp: "^((?!.*{{ item }}).*console.*)$"
line: '\1 {{ item }}'
backrefs: true
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add safety measures for cmdline.txt modification

Consider adding backup and validation steps before modifying this critical boot file.

+  ansible.builtin.copy:
+    src: "{{ _boot_directory }}/cmdline.txt"
+    dest: "{{ _boot_directory }}/cmdline.txt.backup"
+    remote_src: true
+    force: false  # Don't overwrite existing backup
+
+  ansible.builtin.stat:
+    path: "{{ _boot_directory }}/cmdline.txt"
+    register: cmdline_stat
+
+  ansible.builtin.fail:
+    msg: "Boot directory or cmdline.txt not found at {{ _boot_directory }}"
+  when: not cmdline_stat.stat.exists
+
   ansible.builtin.lineinfile:
     path: "{{ _boot_directory }}/cmdline.txt"
📝 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
ansible.builtin.lineinfile:
path: "{{ _boot_directory }}/cmdline.txt"
regexp: "^((?!.*{{ item }}).*console.*)$"
line: '\1 {{ item }}'
backrefs: true
ansible.builtin.copy:
src: "{{ _boot_directory }}/cmdline.txt"
dest: "{{ _boot_directory }}/cmdline.txt.backup"
remote_src: true
force: false # Don't overwrite existing backup
ansible.builtin.stat:
path: "{{ _boot_directory }}/cmdline.txt"
register: cmdline_stat
ansible.builtin.fail:
msg: "Boot directory or cmdline.txt not found at {{ _boot_directory }}"
when: not cmdline_stat.stat.exists
ansible.builtin.lineinfile:
path: "{{ _boot_directory }}/cmdline.txt"
regexp: "^((?!.*{{ item }}).*console.*)$"
line: '\1 {{ item }}'
backrefs: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant