ExplodingCabbage / sublime-gitignorer

Sublime plugin that excludes from your Sublime project any files ignored by git
Do What The F*ck You Want To Public License
76 stars 11 forks source link

Updating every 5 seconds is crude; is it good enough? #3

Open ExplodingCabbage opened 10 years ago

ExplodingCabbage commented 10 years ago

Presently the plugin just spawns a daemon thread that checks every 5 seconds what files and folders should be ignored and shoves them into the appropriate setting in the preferences file. No attempt is made to handle any events triggered by modifying files or settings. This approach has the virtues of:

However, I have a couple of worries

ExplodingCabbage commented 10 years ago

Just shoved my entire home directory into my project including a dozen git repos and there was no performance problem; I think all is fine.

xilin commented 10 years ago

I think it is better if you provide a configuration for how long it is to check. If there is a manually way to do the check immediately, it is better.

krnlde commented 9 years ago

I experience huge performance problems due to this 5 sec check. I got a project with many files dirs and subdirs (keep in mind that node_modules/ and bower_components/ are excluded and are also constantly checked). Sublime hangs for like 2 sec every 5 secs constantly. Why doesn't it check all .gitignore files once per start and then adds a file listener to this file(s) just changing on demand.

I had to uninstall the plugin temporarily.

Should I create a new issue or does this fit into the current one?

ExplodingCabbage commented 9 years ago

Absolutely fits into this one - thanks for the report. I did things this way because I thought it would be good enough and I didn't want to dick around learning how to use file listeners. Sounds like that was a mistake that I now need to solve.

krnlde commented 9 years ago

Thanks man!

krnlde commented 9 years ago

2nd easier approach would be to swap the computation on an extra core/thread. Then Sublime wouldn't hang.

ExplodingCabbage commented 9 years ago

That has its own traps - there are certain methods in the sublime api that fail on windows in sublime text 2 if called from threads other than the main thread. That's why I swapped from using a background thread to using timeouts in https://github.com/ExplodingCabbage/sublime-gitignorer/commit/c7e735d4bc7fd5a11b70f5bd96562ac5e6a919ab. But perhaps I can do the expensive stuff in a background thread and then use a timeout to queue only the settings write on the main thread. I'll experiment.

krnlde commented 9 years ago

If it helps https://github.com/jisaacks/GitGutter has a non_blocking: true configuration flag. Maybe you can use some of these insights.

ExplodingCabbage commented 9 years ago

Fie and buggery, I tried the "easier" approach of moving as much as possible onto a daemon thread while wrapping the settings access in set_timeout calls, but it does nothing at all to improve the performance when dealing with large repos. I need to think a bit about why. You can see my failed attempt at a fix at https://github.com/ExplodingCabbage/sublime-gitignorer/commit/5fa0fe81d9b218d25aa171c60a068e6e086df25d if you're interested.

hdavidzhu commented 9 years ago

Is there a way to disable this 5 second update and instead update the listing through a keybinding?

ExplodingCabbage commented 9 years ago

@hdavidzhu not at present, sorry. I'll try to get round to adding that in at some point. (Feel free to offer a PR if you've got the time and inclination to do so.)

Narretz commented 8 years ago

There's really no reason to "watch" the ignored files. How often do you update your gitignore? Just run the command after you made a change and be done with it.

sffc commented 6 years ago

Every 5 seconds, this plugin makes sublime freeze and I get the beachball for about a second. My workaround is to install the plugin, let it run once, uninstall the plugin, and reboot Sublime.

sffc commented 6 years ago

Why not make this a menu option? I should be able to Command-P and run the plugin on-demand instead of having the daemon thing run automatically every 5 seconds.