Skip to content

Conversation

MiniMe453
Copy link

@MiniMe453 MiniMe453 commented Sep 13, 2025

The goal is to reduce the number of allocations in Scribe to increase the performance. I am creating this pull request so others can look at the code and help with the optimization. Outcome is a 99% reduction in the allocation rate and 99% decrease in the number of GC events

Using Markdown layout system

Before

Allocation Rate: 864 MiB
GC Count: ~71/frame
image
image

After

Allocation Rate: 6.53 MiB
Allocations/Frame: ~38/frame
GC Count: <1/second
image
image

The markdown demo is by far the most demanding on the system. For the other demos, just rendering text is now extremely fast

Before

image

After

image

@MiniMe453 MiniMe453 marked this pull request as draft September 13, 2025 22:22
@MiniMe453
Copy link
Author

MiniMe453 commented Sep 14, 2025

did some more work and now the library is extremely performant.

Final results

Allocation Rate: 6.53 MiB
Allocations/Frame: ~38/frame
GC Count: <1/second

:D

I just need to fix a memory leak related to the TextLayoutSettings then do some cleanup of the code.

@michaelsakharov
Copy link
Contributor

Is this ready or still a draft?

@MiniMe453 MiniMe453 marked this pull request as ready for review September 26, 2025 20:57
@MiniMe453
Copy link
Author

@michaelsakharov I fixed the memory leak issue with TextLayoutSettings :) it seems it was an issue with using stack to pool the objects, so i changed it to a list and explicit index. seems to work very well now and the GC pressure is even lower in markdown mode.

this PR is ready for review!

}

}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a mismatched bracket here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants