Virtual helm merge: use yaml.CSafeLoader/CDumper for 10-50x YAML parse/dump speedup #34
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Performance Issue
The
_merge_helm_indexesfunction inartifact/virtual.pyusesyaml.safe_load(pure-Python loader) andyaml.dump(pure-Python dumper). For a 19-member virtual repo merging ~14MB of index data, the merge step took 38.5 seconds in testing.PyYAML ships C extensions (
yaml.CSafeLoader,yaml.CDumper/yaml.CSafeDumper) that are 10–50x faster than their pure-Python equivalents.Fix
Replace in
_merge_helm_indexes:yaml.safe_load(raw_data)→yaml.load(raw_data, Loader=yaml.CSafeLoader)yaml.dump(merged, Dumper=_HelmDumper, ...)— extend_HelmDumperfromyaml.CDumperinstead ofyaml.Dumperand useyaml.dump(merged, Dumper=_CHelmDumper, ...)Add a graceful fallback to pure-Python loaders if the C extension is not available (importable as
yaml.CSafeLoader).Expected Impact
The 38.5s merge step should drop to under 5s for 19 members. The cache-miss latency for large virtual repos becomes acceptable for the first request.