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

scripts: dts: Refactor gen_driver_kconfig_dts #83878

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

57300
Copy link
Contributor

@57300 57300 commented Jan 13, 2025

The motivation for this patch was to improve the script's performance, but some stylistic changes and cleanups are included as well.

The main optimization concerns the use of PyYAML, as it offers multiple functions for interpreting YAML. The commonly used load/safe_load converts a YAML stream to a dictionary. There are also scan, parse, and compose, which return intermediate representations, the last one being a graph. [1]

Since gen_driver_kconfig_dts scans DT bindings for compatible strings, it only needs to look through top level keys in YAML. The intermediate PyYAML graph is sufficient for this, and using it reduces the script's execution time by about 30%, without making the code too complicated.

[1] - https://pyyaml.org/wiki/PyYAMLDocumentation

The motivation for this patch was to improve the script's performance,
but some stylistic changes and cleanups are included as well.

The main optimization concerns the use of PyYAML, as it offers multiple
functions for interpreting YAML. The commonly used `load`/`safe_load`
converts a YAML stream to a dictionary. There are also `scan`, `parse`,
and `compose`, which return intermediate representations, the last one
being a graph. [1]

Since `gen_driver_kconfig_dts` scans DT bindings for compatible strings,
it only needs to look through top level keys in YAML. The intermediate
PyYAML graph is sufficient for this, and using it reduces the script's
execution time by about 30%, without making the code too complicated.

[1] - https://pyyaml.org/wiki/PyYAMLDocumentation

Signed-off-by: Grzegorz Swiderski <[email protected]>
Copy link
Member

@decsny decsny left a comment

Choose a reason for hiding this comment

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

lgtm

@kartben kartben requested a review from pdgendt January 18, 2025 10:19
@kartben kartben merged commit 15488be into zephyrproject-rtos:main Jan 19, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants