Skip to content

Conversation

@adolago
Copy link
Owner

@adolago adolago commented Feb 7, 2026

πŸ’‘ What: Optimized TaskStatus::colored_string to return cached &'static str using once_cell::sync::Lazy and refactored format_duration to avoid intermediate String allocations.

🎯 Why:

  1. TaskStatus::colored_string was allocating a new String (with ANSI codes) for every single task execution. In a playbook with many tasks/hosts, this adds up.
  2. format_duration was using multiple format! calls and slice manipulations that allocated temporary strings.

πŸ“Š Impact:

  • Reduces heap allocations by 1 per task for status string.
  • Reduces heap allocations by 1 per task for duration formatting.
  • TaskStatus::colored_string is now zero-allocation after first use.

πŸ”¬ Measurement:

  • Verified via cargo test --bin rustible output::tests.
  • Code review note: once_cell is an existing dependency. TaskStatus signature change is safe as it is internal to the binary crate's CLI module.

PR created automatically by Jules for task 3146391609273665638 started by @dolagoartur

- Cache colored TaskStatus strings using `once_cell::Lazy` to return `&'static str` instead of allocating `String` on every task.
- Optimize `format_duration` to use `String::with_capacity` and `std::fmt::Write` to avoid intermediate string allocations in the hot path.
- Avoid unnecessary string conversions in `task_result`.

This reduces memory allocations for every task execution, improving performance for large playbooks.

Co-authored-by: dolagoartur <146357947+dolagoartur@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@adolago adolago merged commit 22b94a3 into main Feb 11, 2026
20 of 23 checks passed
@adolago adolago deleted the bolt/output-optimization-3146391609273665638 branch February 11, 2026 09:14
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.

1 participant