charmbracelet / charmbracelet/bubbletea
Significant Performance Degradation in v2 (2x slower at-least)
- Dominant language
- Go
- Stars
- 44.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Was just updating to v2 to test it out (went pretty smooth) but found some really severe performance problems. The application I have is quite non-trivial and there is lots of rendering going on but it was running an extremely stable 110-120fps prior but now it very consistently is dropping to less than half of that.
I've got some profiling traces that I've attached (both were running for 10s doing the same operation).
The profiles are here (both old & new, with **no app changes in-between except required migrations such as the mouse msg changes**)
[cpu_and_mem_profiles.zip](https://github.com/user-attachments/files/22016866/cpu_and_mem_profiles.zip)
I see extremely heavy GC cycles in the new branch as you can see below
CellBuf + ansi parsing seems to be the fault, since it's making tons of copies every frame. Making up more than 50% of the allocations.
**Setup**
Please complete the following information along with version numbers, if applicable.
I don't feel this is applicable to terminal emulator.
**To Reproduce**
This should be visible on any document with lots of rendered items.
**Source Code**
Sadly, I can't provide source code here.
**Expected behavior**
For allocations and performance to be more inline with previous versions.
**Screenshots**
I don't feel the video / images would help much here I think the profiles show it pretty explicitly above.
**Additional context**
Happy to help :D
Contributor guide
Research direction
Start with the attached CPU and memory profiles, then inspect CellBuf and ANSI parsing, which the report identifies as major allocation sources during rendering. Reproduce with a document containing many rendered items and compare allocations, GC activity, and frame rate against the previous version; done means performance is closer to the prior baseline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100