DioxusLabs / DioxusLabs/dioxus

`dx fmt` is uncomfortably slow

Open
#4,628 0 comments 1 reaction 0 assignees View on GitHub
autoformatting cli performance
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Problem**

An invocation of `dx fmt` on a single, small source file takes, by my gut feel estimate, around 100-200ms. This is uncomfortably long for a formatter in my humble opinion.

**Steps To Reproduce**

Steps to reproduce the behavior:

I configured Neovim to use `dx fmt` in conform.nvim as follows:
```lua
formatters = {
dioxus = {
require_cwd = true,
cwd = function(self, ctx)
return require("conform.util").root_file({ "dx.toml" })(self, ctx)
end,
stdin = true,
command = "dx",
args = function(self, ctx)
return {
"fmt",
"-f",
"-",
}
end,
},
},
formatters_by_ft = {
rust = { "dioxus", lsp_format = "first" },
},
```
This uses the stdin behavior of `dx fmt`. However, the file variant is just as slow. Running `dx fmt -f ./src/main.rs` on the command line also takes a very noticable amount of time.

Disabling the `dioxus` formatter (and just using `rustfmt`) makes format-on-save virtually instant. Enabling it, either together with `rustfmt` or without it, means there is noticable jank after formatting, which is quite painful,

**Expected behavior**

Considering `dx fmt` is a Rust binary I expected it to be fast. Perhaps there is some unnecessary startup time hidden somewhere. I'd love for the execution time to be reduced to a point where it is no longer noticable.

**Environment:**

- Dioxus version: 0.6.3 and 0.7.0-rc.0
- Rust version: rustc 1.91.0-nightly
- OS info: NixOS 😎 (24.11)
- App platform: doesn't matter

**Questionnaire**

I'm interested in fixing this myself but don't know where to start.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.