Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Contribute to GitLab
  • Sign in
C
coderai
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • nexlab
  • coderai
  • Repository

Switch branch/tag
  • 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: 's avatarClaude Opus 4.8 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_011DDv7BchtZQWsnPG6Jm49m
    e2db1b5c
fastlog.py 1.52 KB
EditWeb IDE

Replace fastlog.py

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.