Skip to content

Cache config reads on streaming and rendering hot paths - #786

Open
kvandre12-commits wants to merge 3 commits into
mpfaffenberger:mainfrom
kvandre12-commits:fix/config-hot-path-cache
Open

Cache config reads on streaming and rendering hot paths#786
kvandre12-commits wants to merge 3 commits into
mpfaffenberger:mainfrom
kvandre12-commits:fix/config-hot-path-cache

Conversation

@kvandre12-commits

Copy link
Copy Markdown

Summary

Fixes #784.

code_puppy/config.py was re-reading and INI-parsing puppy.cfg on repeated
configuration lookups. Those getters are used from streaming and rendering
hot paths, turning ordinary display decisions into repeated filesystem I/O
and config parsing.

This PR addresses the issue at the three affected boundaries:

  • config.py — caches the parsed ConfigParser using the config file's
    (st_mtime_ns, st_size) signature. In-process mutations explicitly
    invalidate the cache, while external file changes are still detected.

  • agents/event_stream_handler.py — snapshots the output level and
    suppression decisions once when handling a stream instead of resolving
    them repeatedly as streamed deltas arrive.

  • messaging/rich_renderer.py — resolves output_level once for a
    message dispatch and reuses that value through collapse, suppression,
    and subagent rendering decisions.

The result keeps the existing configuration semantics while removing repeated
disk reads and INI parsing from high-frequency streaming and rendering paths.

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.

Config is read + INI-parsed uncached on hot paths (per streamed delta and per output line)

1 participant