# Optimize two slow code paths \(\#2728\) · gitcafe/zed

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

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

Visibility: public

Requested revision: dcc2cd8dffeb9e12e4783c03af6350385e6ba59f

Requested commit: dcc2cd8dffeb9e12e4783c03af6350385e6ba59f

Commit: dcc2cd8dffeb9e12e4783c03af6350385e6ba59f

Tree: 078ac9bfe701718b354d9f4f8790b036614560e0

Author: Max Brunsfeld

Committer: GitHub

## Message

```
Optimize two slow code paths (#2728)

Linear:
https://linear.app/zed-industries/issue/Z-2578/zed-launches-very-slow-for-user

I was searching for the cause of a slow startup time reported in the
above issue, and I don't think I found it, but I did find two very
noticeable slow code paths while profiling, and fixed them.

###  Notes

1. When starting the JSON language server, we provide it with a JSON
schema for our settings. For the `theme` setting, the JSON schema needs
to read all of the themes in the registry, to generate a list of valid
theme names. Previously, as part of this, we were deserializing each
theme from JSON, which took a lot of CPU. Now, we don't do that.
2. When an FS event occurs within a git repository, we reload the git
status for all entries in that git repository. Previously, we did that
via a separate `libgit2` call per FS entry (including ignored entries,
so many thousands in the case of the `zed` repo). Now we do one
`libgit2` call, asking for all of the statuses. Git carries an index of
all of the files with statuses, so this is fast.

Release Notes:

- Improved the the performance of starting up a  JSON language server.
- Improved the performance of handling changes to git repositories, such
as changing branches or committing.
```

## Parents

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

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

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