prettier-plugin-tailwind icon indicating copy to clipboard operation
prettier-plugin-tailwind copied to clipboard

Performance improvements

Open jaronheard opened this issue 5 years ago • 5 comments

I'm wondering if there's some low-hanging fruit for performance improvements. I'm seeing a big performance slowdown after adding this extension on a real world project. Running prettier check takes 6.5x as long with this extension added on my Intel Macbook Pro. I tested using Node 12.16.1 and Node 14.6.0 with similar results.

I could dig around, but curious if others are seeing similar slowdowns. It seems like this plugin shouldn't be quite that computationally expensive.

Without extension

image

With extension

image

jaronheard avatar Jan 25 '21 20:01 jaronheard

That is very slow I agree. I don't know of a good way to solve this.

For now I'm kind of waiting for https://github.com/prettier/prettier/issues/4424 to be solved - when this happens I'll probably rewrite this plugin (might be silly, but would be fun to tackle the rewrite in Rust if possible).

tqwewe avatar Feb 24 '21 09:02 tqwewe

There is a sorter write by rust: https://github.com/avencera/rustywind, but it can't read the configuration file.

https://github.com/PutziSan/prettier-plugin-sort-class-names is faster but can't format vue files

Airkro avatar Feb 25 '21 01:02 Airkro

@Acidic9 I would start by looking here. The algorithmic complexity of that underlying class name sort function is off the charts—so many trivial optimizations possible that would dramatically improve performance.

kainosnoema avatar Nov 06 '21 02:11 kainosnoema

I've got a 8.84s check time without this plugin, which inflated to 168.10s once I installed it, little bit more than 19x slower. It's not like my machine is slow, Ryzen 5600x, 64GB of RAM @ 3200 MT/s, 512 GB Gen 3 NVMe SSD, and it's not like it's under a high load at the moment. At close to 3 minutes, this is kinda unusable, as it would make my git hooks and CI runs that much slower.

That said, give me a poke if you have a test version and want to see how much that puts a dent in it. Can't share the project as it's my work stuff, but I can give you the metrics for improving the speed of it. I'd like to see it be much faster so I could actually include it in our config.

Spice-King avatar Nov 26 '21 15:11 Spice-King

@Spice-King I did some messing around a couple of days ago and tried using WASM to make it faster.. but after some tests it turned out that JavaScript was way faster. But the code I was testing was completely rewritten and different to this projects code. I'll make a Github repo with some instructions for testing.. it might be quite useful getting some statistics from you

tqwewe avatar Nov 28 '21 06:11 tqwewe