Skip to content

Comments

Reduce LogStep formatting allocations#165

Open
AhmedSalih3d wants to merge 2 commits intocodex/refactor-to-avoid-if-statementfrom
codex/analyze-code-for-performance-improvements
Open

Reduce LogStep formatting allocations#165
AhmedSalih3d wants to merge 2 commits intocodex/refactor-to-avoid-if-statementfrom
codex/analyze-code-for-performance-improvements

Conversation

@AhmedSalih3d
Copy link
Owner

Motivation

  • The per-iteration LogStep path incurred repeated string formatting allocations which are hot in the time-stepping loop and can impact performance.

Description

  • Added a pre-parsed Printf.Format field (FormatSpec) and a reusable IOBuffer (StepBuffer) to SimulationLogger to avoid reallocating format state and temporary strings on every LogStep call.
  • Pre-parse the progress format in the constructor with Printf.Format(format_string) and allocate a single IOBuffer() for reuse.
  • Replaced the previous cfmt join-based line construction in LogStep with Printf.format writing into the reusable buffer and then logging String(take!(buffer)), while leaving the header formatting intact.
  • Change applied to src/SimulationLoggerConfiguration.jl and preserves existing log output semantics.

Testing

  • No automated tests were run against this change.
  • Commands executed while preparing the patch include ls, cat AGENTS.md, rg to locate call sites, multiple sed/nl inspections of files, apply_patch to apply changes, git status, git add, and git commit, and the commit completed successfully.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant