Skip to content

canvas: Adjust memory pressure heuristic - #46786

Merged
jschwe merged 2 commits into
servo:mainfrom
jschwe:canvas_memory_usage
Jul 26, 2026
Merged

canvas: Adjust memory pressure heuristic#46786
jschwe merged 2 commits into
servo:mainfrom
jschwe:canvas_memory_usage

Conversation

@jschwe

@jschwe jschwe commented Jul 26, 2026

Copy link
Copy Markdown
Member

With the testcase from #45199 memory usage grew to 1.7 GiB before stabilizing. With this patch it stopped at around 1GiB (due to more frequent GCs).
We probably should be able to remove at least one of the copies in memory, but thats a bit more effort than making the memory pressure more accurate.

Testing: We don't have any tests for GC behavior / memory usage.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
@jschwe
jschwe requested a review from gterzian as a code owner July 26, 2026 14:12
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 26, 2026
@jschwe
jschwe requested a review from yezhizhen July 26, 2026 14:12
Comment thread components/script/dom/canvas/2d/canvasrenderingcontext2d.rs Outdated
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jul 26, 2026
Co-authored-by: Sam <16504129+sagudev@users.noreply.github.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 26, 2026
@jschwe
jschwe added this pull request to the merge queue Jul 26, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 26, 2026
Merged via the queue into servo:main with commit 8fa3fd3 Jul 26, 2026
34 checks passed
@jschwe
jschwe deleted the canvas_memory_usage branch July 26, 2026 17:51
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 26, 2026
Comment on lines +62 to +63
/// On mobile devices this slightly undercounts (usually unified memory), on desktop this
/// slightly overcounts, since GPU memory is separate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand on Desktop this overcounts because VRAM is independent.

But why it undercounts on mobile tho?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I guess it's not totally accurate as written. In your test case for canvas 2d performance point 2 is more than 1 bitmap size, but it varies by scene so it can also be less. With vello GPU I think it would always be more than 1 bitmap size, but I didn't want to complicate things more, and leaving backend accuracy to the Todo tracked by the new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants