Skip to content

perf: remove transformer runner hot-path overhead - #427

Open
goldyfruit wants to merge 4 commits into
OpenVoiceOS:devfrom
goldyfruit:perf/transformer-hot-path
Open

perf: remove transformer runner hot-path overhead#427
goldyfruit wants to merge 4 commits into
OpenVoiceOS:devfrom
goldyfruit:perf/transformer-hot-path

Conversation

@goldyfruit

@goldyfruit goldyfruit commented Aug 8, 2026

Copy link
Copy Markdown

Summary

  • preserve caller context identity, including empty dictionaries
  • do not merge an in-place transformer context back into itself
  • retain merge_dict when a transformer returns a distinct context or delta
  • remove obsolete session redaction, per maintainer review
  • use lazy logger argument formatting across transformer services

Architecture and correctness

In-place transformers commonly return the exact context object they received. Merging that object into itself recursively walks identical nested mappings until RecursionError. The transformer service owns context composition, so identity and explicit-None checks belong here. No transformer is disabled, plugin order is unchanged, and distinct returned contexts still pass through merge_dict.

The session no longer carries the sensitive credentials that motivated redaction. Logging now passes the full context directly with deferred %s formatting, avoiding both the obsolete policy and an eager context copy. OpenVoiceOS/ovos-utils#415 supplies the shared disabled-level call-site gate.

Validation

  • focused transformer suite: 55 passed
  • Ruff clean on the touched files
  • git diff --check
  • prior full suite and exact 32-partition canary were green before the review-only redaction removal

No CI files were changed.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Transformer pipelines preserve explicitly supplied contexts, including empty mappings, during in-place mutations. Utterance and metadata transformations avoid self-merging. Transformer logging uses parameterized debug calls without filtering session metadata.

Changes

Transformer pipeline updates

Layer / File(s) Summary
Context identity preservation
ovos_plugin_manager/transformer_services.py, test/unittests/test_transformer_services.py
Utterance and metadata transformations preserve supplied context identity, skip self-merging, and retain nested and provenance updates. Tests cover empty contexts.
Parameterized transformer logging
ovos_plugin_manager/transformer_services.py
Utterance, metadata, intent, dialog, TTS, and audio transformers use parameterized debug logging. Existing transformation and cancellation behavior remains unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main performance optimization in the transformer runner hot path.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@goldyfruit
goldyfruit marked this pull request as ready for review August 8, 2026 01:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
ovos_plugin_manager/transformer_services.py (1)

258-260: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Move session filtering behind the debug-level check.

The safe comprehension copies every returned context, even when debug logging is disabled. This adds a top-level O(n) allocation to each transformer call. Create the filtered mapping only when the debug record will be emitted.

Based on the PR objective to remove transformer runner hot-path overhead.

Also applies to: 297-299

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ovos_plugin_manager/transformer_services.py` around lines 258 - 260, In the
transformer logging paths around LOG.debug, guard construction of the filtered
safe mapping with the debug-enabled check so the data comprehension runs only
when the record will be emitted. Apply the same change to both referenced
logging locations, while preserving removal of the session field and the
existing debug message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ovos_plugin_manager/transformer_services.py`:
- Around line 267-268: Replace the truthiness-based context normalization with
an explicit None check in both methods containing the merge guard around
data/context, so a caller-provided empty dictionary remains the same object
passed to the plugin. Add a regression test that passes an empty context,
exercises an in-place plugin, and verifies the original object identity is
preserved.

---

Nitpick comments:
In `@ovos_plugin_manager/transformer_services.py`:
- Around line 258-260: In the transformer logging paths around LOG.debug, guard
construction of the filtered safe mapping with the debug-enabled check so the
data comprehension runs only when the record will be emitted. Apply the same
change to both referenced logging locations, while preserving removal of the
session field and the existing debug message.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c8014134-d4e9-4f85-b7eb-c26e592fa3f2

📥 Commits

Reviewing files that changed from the base of the PR and between d0aeae5 and 46070aa.

📒 Files selected for processing (2)
  • ovos_plugin_manager/transformer_services.py
  • test/unittests/test_transformer_services.py

Comment thread ovos_plugin_manager/transformer_services.py
Comment thread ovos_plugin_manager/transformer_services.py Outdated
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.

2 participants