# Improve rendering performance in \`gpui2\` \(\#3605\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/97eae4b08178ef54ab2384416abae1c5e9ec6669)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 97eae4b08178ef54ab2384416abae1c5e9ec6669

Requested commit: 97eae4b08178ef54ab2384416abae1c5e9ec6669

Commit: 97eae4b08178ef54ab2384416abae1c5e9ec6669

Tree: 6d09933f5a4c724bae89b1ec394e291df5189701

Author: Antonio Scandurra

Committer: GitHub

## Message

```
Improve rendering performance in `gpui2` (#3605)

The biggest improvements come from preventing element moves where
unnecessary, and when they are absolutely needed, try to make the struct
we're moving as small as possible. Having big structs on the stack (such
as `Interactivity`) increases the cost of moving but also reduces
opportunities for other compiler optimizations (e.g., inlining).

One more notable change was using `FxHashMap` and `FxHashSet` in hot
code paths where we don't need those collections to be resistant to DoS.

Another thing I am seeing a lot in the profiler is interacting with
`StackingOrder` (cloning it, searching for it, inserting into the
`Scene`). I have some thoughts on how to optimize that but I punted on
it because performance seems to be pretty good now.

Release Notes:

- N/A
```

## Parents

- [706dd8246ed0340a5e1e7d693313013339c56085](https://git.cafe/gitcafe/zed/commit/706dd8246ed0340a5e1e7d693313013339c56085?format=markdown)

- [6159a595347123a5d529c6955cbdb1194bff40d3](https://git.cafe/gitcafe/zed/commit/6159a595347123a5d529c6955cbdb1194bff40d3?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/97eae4b08178ef54ab2384416abae1c5e9ec6669?format=markdown)
