Skip to content

Conversation

@roma-jam
Copy link
Contributor

@roma-jam roma-jam commented Nov 17, 2025

Description

This is the second part of the plan: Add a test application for CPU load

The test case has been added to the runtime_config, which is the future will be used as a general esp_tinyusb device test.

Measuring values:

  • Run Time (Amount of ticks, that works the TinyUSB task during enumeration): < 1800
  • CPU load (Percentage of the CPU time): == 0 (as most of the time CPU spend in IDLE0 and IDLE1 tasks)
Name                   Run time CPU load
TinyUSB                    1741       0%
main                       8340       0%
IDLE1                    826544      50%
IDLE0                    824993      49%
ipc1                          0       0%
ipc0                          0       0%

Limitations

CPU Load is calculated based on the Run time value for the task. Precision of the current calculation is not enough to show the real CPU Load in percentage in our case (as it is less than 1%).

In the current PR we measure the Run Time value and expect it to be in the interval:

  • ESP32-S2: 0 < Run Time < 5000
  • ESP32-S3: 0 < Run Time < 3000
  • ESP32-P4: 0 < Run Time < 1800
  • assert if the target is not in the table

Related

Testing

  • Added test case: [CPU load] Install & Uninstall, default configuration", "[cpu_load] with pytest scenario

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@roma-jam roma-jam added this to the esp_tinyusb v2.0.2 milestone Nov 17, 2025
@roma-jam roma-jam self-assigned this Nov 17, 2025
@roma-jam roma-jam added the Component: usb_device Issue affects usb_device component label Nov 17, 2025
@roma-jam roma-jam force-pushed the feature/tinyusb_task_deletion_part2 branch 2 times, most recently from 31fd0b0 to d14fb88 Compare November 18, 2025 13:14
@roma-jam roma-jam requested a review from Copilot November 18, 2025 13:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds CPU load measurement capabilities to the TinyUSB test suite to ensure the task deletion notification-driven implementation doesn't introduce performance regressions. The test measures both runtime ticks and CPU load percentage during USB device enumeration.

Key Changes:

  • Adds CPU load and runtime statistics measurement test for TinyUSB task
  • Validates that TinyUSB task CPU load remains at 0% after enumeration
  • Validates that TinyUSB runtime stays below 1800 ticks during enumeration

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
sdkconfig.defaults Enables FreeRTOS trace facility and runtime stats for CPU load measurement
pytest_runtime_config.py Adds pytest test case to verify CPU load metrics are within expected thresholds
test_cpu_load.c Implements CPU load measurement logic using FreeRTOS runtime statistics

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@roma-jam roma-jam force-pushed the feature/tinyusb_task_deletion_part2 branch from d14fb88 to 1619f26 Compare November 18, 2025 13:55
@roma-jam roma-jam changed the title feature(esp_tinyusb): TinyUSB task deletion notification driven (part 2/3) [WIP] feature(esp_tinyusb): TinyUSB task deletion notification driven (part 2/3) Nov 18, 2025
@roma-jam roma-jam marked this pull request as ready for review November 18, 2025 13:57
@roma-jam
Copy link
Contributor Author

Hi

@tore-espressif
@peter-marcisovsky
@igi540

This one is also ready, PTAL after the part 1.

@roma-jam roma-jam force-pushed the refactor/tinyusb_task_deletion_part1 branch from aed6a02 to 6ec9db1 Compare November 18, 2025 15:29
@roma-jam roma-jam force-pushed the feature/tinyusb_task_deletion_part2 branch from 1619f26 to 019c18f Compare November 18, 2025 15:31
Copy link
Collaborator

@peter-marcisovsky peter-marcisovsky left a comment

Choose a reason for hiding this comment

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

LGTM, no other comments.

@roma-jam roma-jam force-pushed the refactor/tinyusb_task_deletion_part1 branch from 6ec9db1 to 0c6cf9e Compare November 20, 2025 12:26
@roma-jam roma-jam changed the title feature(esp_tinyusb): TinyUSB task deletion notification driven (part 2/3) feature(esp_tinyusb): TinyUSB task deletion notification driven (part 2/3) [WIP] Nov 20, 2025
@roma-jam roma-jam marked this pull request as draft November 20, 2025 12:32
@roma-jam
Copy link
Contributor Author

Converted to draft to apply Peter's notes and resolve conflicts.

@roma-jam roma-jam force-pushed the feature/tinyusb_task_deletion_part2 branch from 019c18f to fd54244 Compare November 20, 2025 12:51
@roma-jam roma-jam changed the title feature(esp_tinyusb): TinyUSB task deletion notification driven (part 2/3) [WIP] feature(esp_tinyusb): TinyUSB task deletion notification driven (part 2/3) Nov 20, 2025
@roma-jam roma-jam marked this pull request as ready for review November 20, 2025 12:54
@cursor
Copy link

cursor bot commented Nov 20, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on December 20.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@roma-jam roma-jam force-pushed the refactor/tinyusb_task_deletion_part1 branch from 0c6cf9e to 5ac149b Compare November 20, 2025 13:32
@roma-jam roma-jam force-pushed the feature/tinyusb_task_deletion_part2 branch from fd54244 to adc2129 Compare November 20, 2025 13:33
Base automatically changed from refactor/tinyusb_task_deletion_part1 to master November 20, 2025 16:27
@roma-jam roma-jam force-pushed the feature/tinyusb_task_deletion_part2 branch 6 times, most recently from 6dca07a to eae16ec Compare November 24, 2025 18:53
@roma-jam roma-jam force-pushed the feature/tinyusb_task_deletion_part2 branch from eae16ec to e3b601d Compare November 24, 2025 20:25
@roma-jam
Copy link
Contributor Author

Hi
@tore-espressif,
@igi540,

This one is ready again, PTAL.

@roma-jam roma-jam merged commit 0ea7e08 into master Nov 27, 2025
207 of 220 checks passed
@roma-jam roma-jam deleted the feature/tinyusb_task_deletion_part2 branch November 27, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: usb_device Issue affects usb_device component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants