Skip to content

Conversation

@watany-dev
Copy link
Owner

Implement custom UnmarshalYAML methods for WorkflowFile, Job, and Step
structs to avoid reflection overhead and eliminate redundant node traversal.

Key optimizations:

  • Single-pass extraction of struct fields and JobOrder in WorkflowFile
  • Direct field assignment instead of reflection-based Decode calls
  • Pre-allocated slices and maps with exact capacity
  • Simplified LoadWorkflowFile by removing parseWorkflowFromNode and
    extractJobOrderFromNode helper functions

Benchmark results (10 jobs × 5 steps each):

  • Speed: 774,299 ns/op → 693,108 ns/op (10.5% faster)
  • Memory: 206,857 B/op → 194,120 B/op (6.2% reduction)
  • Allocations: 3,837 → 3,109 (19.0% reduction)

Code simplification: load.go reduced from 84 to 28 lines.

Implement custom UnmarshalYAML methods for WorkflowFile, Job, and Step
structs to avoid reflection overhead and eliminate redundant node traversal.

Key optimizations:
- Single-pass extraction of struct fields and JobOrder in WorkflowFile
- Direct field assignment instead of reflection-based Decode calls
- Pre-allocated slices and maps with exact capacity
- Simplified LoadWorkflowFile by removing parseWorkflowFromNode and
  extractJobOrderFromNode helper functions

Benchmark results (10 jobs × 5 steps each):
- Speed: 774,299 ns/op → 693,108 ns/op (10.5% faster)
- Memory: 206,857 B/op → 194,120 B/op (6.2% reduction)
- Allocations: 3,837 → 3,109 (19.0% reduction)

Code simplification: load.go reduced from 84 to 28 lines.
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