Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C coderai
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • nexlab
  • coderai
  • Repository
  • coderai
  • codai
  • api
  • fastlog.py
Find file BlameHistoryPermalink
  • Stefy Lanza (nextime / spora )'s avatar
    engine: route hot-path logs through os.write (fast_print) instead of print() · e2db1b5c
    Stefy Lanza (nextime / spora ) authored Jun 22, 2026
    
    
    The engine emits a lot of debug output during generation. Builtin print() goes
    through a buffered, lock-guarded text stream — per-call overhead plus a lock that
    can serialize against other threads on the hot path. New codai/api/fastlog.py
    fast_print writes each line with a single os.write(1) syscall: unbuffered, no
    Python-level lock, atomic for pipe writes up to PIPE_BUF (log lines don't
    interleave), with a fallback to real print() for stderr/failures. Imported as
    print() in the generation hot path: api/text.py, backends/vulkan.py, backends/
    cuda.py.
    
    Verified: fast_print mirrors print's signature (sep/end/file/flush), writes to
    fd 1, falls back for stderr; all three modules compile.
    
    Co-Authored-By: default avatarClaude Opus 4.8 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_011DDv7BchtZQWsnPG6Jm49m
    e2db1b5c