# gpui: Take advantage of unified memory on Apple silicon \(\#44273\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 2441dc3f6637431a781ae10b2e1aa8c4704b9502

Requested commit: 2441dc3f6637431a781ae10b2e1aa8c4704b9502

Commit: 2441dc3f6637431a781ae10b2e1aa8c4704b9502

Tree: e004a08a6a6c555df9b5779133ab02d420a522d3

Author: Marco Mihai Condrache

Committer: GitHub

## Message

```
gpui: Take advantage of unified memory on Apple silicon (#44273)

Metal chooses a buffer’s default storage mode based on the type of GPU
in use.
On Apple GPUs, the default mode is shared, which allows the CPU and GPU
to access the same memory without requiring explicit synchronization.
On discrete or external GPUs, Metal instead defaults to managed storage,
which does require explicit CPU–GPU memory synchronization.

This change aligns our buffer usage with Metal’s default behavior and
avoids unnecessary synchronization on Apple-silicon Macs. As a result,
memory usage on Apple hardware is reduced and performance improves due
to fewer sync operations.

Ref:
https://developer.apple.com/documentation/metal/setting-resource-storage-modes
Ref:
https://developer.apple.com/documentation/metal/synchronizing-a-managed-resource-in-macos

With the storage mode:

<img width="356" height="74" alt="image"
src="https://github.com/user-attachments/assets/e5a5bf9a-f339-417b-b5ab-818d8f692bd1"
/>

On main branch:

<img width="356" height="74" alt="image"
src="https://github.com/user-attachments/assets/6ccd77fe-7929-4423-9696-671d185ceffb"
/>

That's a 44% reduction of memory usage.

Release Notes:

- Reduced memory usage on Apple-silicon Macs by using shared memory
where appropriate

---------

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
```

## Parents

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

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