-
Notifications
You must be signed in to change notification settings - Fork 8.4k
scripts: dts: optimize gen_driver_kconfig_dts.py execution time
#101383
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
base: main
Are you sure you want to change the base?
scripts: dts: optimize gen_driver_kconfig_dts.py execution time
#101383
Conversation
Replace yaml.compose() with a faster event-stream parser that extracts the first top-level "compatible" scalar without constructing the full YAML node tree. This reduces per-file parsing overhead when iterating over thousands of binding files. Binding files are now opened in binary mode and passed directly to SafeLoader/CSafeLoader. Benchmark (Windows, Python 3.12, 2913 bindings): - before: 874ms, 641862 function calls - after: 603ms, 188557 function calls Half of the time is spent opening and closing files, which is quite a bit faster on Linux. Signed-off-by: Guðni Már Gilbert <[email protected]>
98d562d to
a65323e
Compare
|
JarmouniA
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it work with child-bindings?
ex.
zephyr/dts/bindings/i2c/ti,tca9544a.yaml
Line 10 in 5a58989
| compatible: "ti,tca9544a-channel" |
@JarmouniA My initial thought is no, its just ignored as the value is not at root-level. The contents of the output file Unrelated, I just discovered why Windows is so slow on my end. Turns out one of my disk drives has a lot more file filters: C: drive: While on my D drive: I see almost 2x better performance in opening/closing files! 300ms reduced to 138ms. Very interesting... will look into this further :) |
Huh, so we were ignoring child-bindings all this time, interesting! I hope there is no usage of a |



Replace
yaml.compose()with a faster event-stream parser that extracts the first top-levelcompatiblescalar without constructing the full YAML node tree.This reduces per-file parsing overhead when iterating over thousands of binding files. Binding files are now opened in binary mode and passed directly to
SafeLoader/CSafeLoader.Benchmark (Windows, Python 3.12.3, 2913 bindings):
Benchmark (Ubuntu 24.04, Python 3.12, 3388 bindings).
mainas of writing which is 5a58989:So on my end I'm seeing the following improvements:
On Windows half the time, 300ms, is spent on opening 2913 binding files. While on Ubuntu it is only 32ms for 3388 files. Which explains a larger difference between the OS performance.
Testing Method