Skip to content

Conversation

@baxeaz
Copy link
Contributor

@baxeaz baxeaz commented Jul 31, 2025

What was the problem/requirement? (What/Why)

Our yaml parser was far slower than our JSON parser which prevented certain checks we'd like to do at job creation time in some cases and generally caused our create job API to run slower than we'd like.

What was the solution? (How)

Try to use the yaml CSafeLoader where available. Create benchmarking tests to note the difference.

What is the impact of this change?

### 1. Small Template (987 characters):
• **SafeLoader**: 2.91ms
• **CSafeLoader**: 0.27ms
• **Performance improvement**: 11.0x faster
• **Time saved**: 2.64ms per parse

### 2. Large Template (44,187 characters):
• **SafeLoader**: 125.74ms
• **CSafeLoader**: 13.44ms
• **Performance improvement**: 9.4x faster
• **Time saved**: 112.30ms per parse

### 3. Extra Large Template (192,387 characters):
• **SafeLoader**: 590.07ms
• **CSafeLoader**: 65.48ms
• **Performance improvement**: 9.0x faster
• **Time saved**: 524.59ms per parse

### 4. File-based Template (27,347 characters):
• **SafeLoader**: 77.26ms
• **CSafeLoader**: 8.08ms
• **Performance improvement**: 9.6x faster
• **Time saved**: 69.18ms per parse

How was this change tested?

All unit tests pass
Benchmarking test created which passes and shows above performance improvements

Was this change documented?

Yes

Is this a breaking change?

No

Does this change impact security?

No - the CSafeLoader is a C implementation of the safe loader we were using previously - https://pyyaml.org/wiki/PyYAMLDocumentation


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@baxeaz baxeaz requested a review from a team as a code owner July 31, 2025 15:52
…e available. CSafeLoader can offer 9->11x performance improvements in some cases while still performing the safe loading methods of safe_load (No code execution)

Signed-off-by: Brian Axelson <86568017+baxeaz@users.noreply.github.com>
@sonarqubecloud
Copy link

@epmog epmog merged commit 37d3a65 into OpenJobDescription:mainline Jul 31, 2025
19 checks passed
miabatta pushed a commit to miabatta/openjd-model-for-python that referenced this pull request Sep 9, 2025
…nJobDescription#219)

feat: Attempting to load use CSafeLoader for faster YAML parsing where available.  CSafeLoader can offer 9->11x performance improvements in some cases while still performing the safe loading methods of safe_load (No code execution)

Signed-off-by: Brian Axelson <86568017+baxeaz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants