Skip to content

perf(dotfiles): cache aliases and read straight from file#1918

Merged
ellie merged 6 commits intomainfrom
ellie/faster-dotfiles
Apr 3, 2024
Merged

perf(dotfiles): cache aliases and read straight from file#1918
ellie merged 6 commits intomainfrom
ellie/faster-dotfiles

Conversation

@ellie
Copy link
Member

@ellie ellie commented Apr 3, 2024

Previously, we'd rebuild all aliases from sqlite every single time the shell started. This is... ok?

But not great.

With more aliases, we get slower shell starts. On a new-ish macbook pro this isn't too bad, but I imagine it gets worse with older hardware, and especially spinning rust.

This PR builds aliases into cached files every time they are mutated - either locally, or from sync. From there, starting a new shell is pretty much just reading and printing a file.

I've also neatened up the store "building" code a bit

I'd like to follow up with removing the async runtime from the init path if possible, as that is adding overhead and isn't needed to read the cached file. If the cache doesn't exist, we can start tokio and build it.

There's some obvious duplication here that could be cleaned up. I decided that I'd rather leave it as-is, so that future dotfiles have a nice path to follow. While aliases are the same for posix shells, not everything will be

Checks

  • I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

@ellie ellie merged commit 894eaa6 into main Apr 3, 2024
@ellie ellie deleted the ellie/faster-dotfiles branch April 3, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant