# gpui: Reduce \`window.refresh\` to improve cache hit of the cached views \(\#25009\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 985ac4e5f2483598087fd1315cbf1f7307ef88e0

Requested commit: 985ac4e5f2483598087fd1315cbf1f7307ef88e0

Commit: 985ac4e5f2483598087fd1315cbf1f7307ef88e0

Tree: 0d915d41d46a0606dedc437ce4dacbc42f762cd6

Author: Jason Lee

Committer: GitHub

## Message

```
gpui: Reduce `window.refresh` to improve cache hit of the cached views (#25009)

Release Notes:

- Improved performance when using the scroll wheel and some other mouse
interactions.

Based on some cache details about GPUI `AnyView::cached` that I found in
the discussion of
https://github.com/zed-industries/zed/discussions/24260#discussioncomment-12135749,
and combined with the optimization points found in actual applications.

This change may have some scenarios that I have not considered, so I
just make a draft to put forward my ideas first for discussion.

From my analysis, `AnyView::cached` will always invalid by Div's mouse
events, because of it called `window.refresh`. I understand that (mouse
move event) this is because the interface changes related to hover and
mouse_move will be affected style, so `window.refresh` is required.
Since Div does not have the `entity_id` of View, it is impossible to
know which View should be refreshed, so the entire window can only be
refreshed.

With this change, we can reduce a lot of `render` method calls on
ScrollWheel or Mouse Event.
```

## Parents

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

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