atom-community / autocomplete-paths

Autocomplete Paths for Atom
MIT License
151 stars 62 forks source link

feat: build cache with dir on Windows #247

Closed aminya closed 3 years ago

aminya commented 3 years ago

@UziTech Does this work for you on Windows?

UziTech commented 3 years ago

This seems very slow. It takes over 2 seconds for _buildInitialCacheWithFind or about .2 seconds with _buildInitialCache.

UziTech commented 3 years ago

I'm sure a lot of that time is starting the process so it will most likely be faster when there are a lot of files. If we are going for speed here I feel like we should do some sort of race between them and cancel the other when one finishes.

aminya commented 3 years ago

@UziTech

The current method does not block the main thread even if I open a big project. I don't think running both in parallel helps much. The better method is to write a cmd script to just skip the ignored folders right from the beginning.

I am doing things incrementally. I just wanted to first make it work in JavaScript, and then try to use a cmd method. Something like:

set directoryPath=%1
set ignorePattern=%2
setlocal EnableDelayedExpansion
for /D %%d in (%directoryPath%) do (
    set show=yes
    for %%a in (%ignorePattern%) do if %%d == %%a set show=no
    if !show! == yes dir %%d /A /B
)
UziTech commented 3 years ago

If I remove the ignore patterns it still takes over 2 seconds. I think starting any process is going to be the bottleneck.

Maybe moving this._buildInitialCache() to a web worker (once they are available in Atom) would be a better approach?

aminya commented 3 years ago

I meant skipping getting the files of a big folder. For example, dir takes some time getting the files of node_modules. But we should just skip that folder, and not even enter it to get its files. That's what I am saying.

We can't use worker for now because we are using atom API. See #231. We should make that Atom API to spawn a worker itself. We can't do it from this package.

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 2.13.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: