Skip to content

Rendering large sessions is extremely slow (>30s for ~2800 messages) #392

@jensenojs

Description

@jensenojs

Switching to a session with ~2800 messages (~9300 parts, ~87000 rendered lines) freezes the UI for 30+ seconds.

Profiled on a session with 2786 messages, 9312 parts, 86946 rendered lines:

Phase Time %
API fetch ~1900ms 5%
Format (Lua) 437ms 1.2%
nvim_buf_set_lines 788ms 2.2%
Extmarks 69ms 0.2%
Fold creation (cursor + normal! zc/zo) 35,266ms 96.5%

The bottleneck is output_window.set_folds() — it iterates through fold ranges calling vim.fn.cursor() + vim.cmd('silent! normal! zc') for each one. With 392 folds in an 87K-line buffer, each cursor + zc triggers a screen redraw (~90ms per fold). A second pass restoring previously-open folds (zo) doubles the cost.

for _, range in ipairs(folds.ranges) do
  vim.fn.cursor(range.from, 1)
  vim.cmd('silent! normal! zc')
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions