zanaptak / TypedCssClasses

A CSS class type provider for F# web development. Bring external stylesheet classes into your F# code as design-time discoverable compiler-verified properties.
MIT License
166 stars 8 forks source link

Slow loading times for full Tailwind #9

Closed landy closed 3 years ago

landy commented 3 years ago

Hello there, I was trying your library today and for me it seems slow for such a large library like Tailwind.

So I tried some experimenting with porting the underlying library to dotnet 5. After some testing using provided tests I found out that when I was using this library compiled for dotnet 5 the parsing time was around 0.7s instead of 1.5-1.7 (results for netstandard library)

I've tried to multitarget the library but with no luck.

I would be happy to provide a pull request but my knowledge of type providers sdk is basically none and I don't know where to start and I don't really know if what I'm trying to do will bring any benefits. So please if you have any pointers I would be more than happy to help :)

https://devblogs.microsoft.com/dotnet/regex-performance-improvements-in-net-5/ this is the article that led me to the path to explore a possibility that using dotnet 5 would be a perf improvement

zanaptak commented 3 years ago

Interesting that the parse performance can be improved, but I'm not sure if that's the issue you are having. The parse is done only once and then cached.

Some IDEs can be slow to render completion lists with thousands of items. See the comment here: https://github.com/zanaptak/TypedCssClasses/pull/8

Try enabling logging in the type provider (see logFile parameter) and verify whether there are ongoing delays in the type provider itself. In my experience only the initial parse will be slow, subsequent queries from IDE to TP will return cached results instantly from TP's perspective, so the delay is happening on IDE side after we have returned the results, not much we can do about it.

You can try reducing the number of classes generated by Tailwind, or code-generating a static file to reference instead of going through the type provider (see getProperties parameter).

landy commented 3 years ago

you are right! I guess it will be some kind of Rider issue. It even has a problem with dashes in names of classes and starts the intelisense from the start when I try to write something like tw.bg-gray-900

thank you for the pointers tho. I will have a more detailed look.