-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cache #27
Comments
Yeah - indeed. Though I don't feel stress with > 10,000 lines objc code :) If I have enough time this feature might be implemented, however, I don't know when. |
I tested a bit and found out that the python regexp is slow. Having only single line support makes the parsing a lot faster. The python regexp was updated cuz of multiline support in issue: #12 function! ctrlp#funky#python#filters()
let filters = [
\ { 'pattern': '\v\C^\s*(def|class)\s+\w.+:',
\ 'formatter': ['\v\C^\s*', '', ''] },
\ ]
return filters
endfunction |
Or the current filter for python contains 2 items like this: let filters = [
\ { 'pattern': '\v\C^\s*class\s+\w+\s*(\([^\)]+\))?:',
\ 'formatter': ['\v\C^\s*', '', ''] },
\ { 'pattern': '\v\C^\s*def\s+\w+\s*(\_.*):',
\ 'formatter': ['\v\C^\s*', '', ''] }
\ ] I guess this is the one of the reasons the funky is slow, coz the funky parses a file 2 times. |
If you replace the filter function for python with below: function! ctrlp#funky#python#filters()
let filters = [
\ { 'pattern': '\v\C^\s*(class\s+\w+\s*(\([^\)]+\))?|def\s+\w+\s*(\_.*)):',
\ 'formatter': ['\v\C^\s*', '', ''] }
\ ]
return filters
endfunction Does it make the funky faster? |
Will try when i get back to work. Thanks for the response. |
Its still slow on large python files compared to single line version. |
Its slow cuz it was greedy. Actually it selected the whole file :) Having the second part non-greedy makes it fast and also support multiline functions. function! ctrlp#funky#python#filters()
let filters = [
\ { 'pattern': '\v\C^\s*(class\s+\w+\s*(\([^\)]+\))?|def\s+\w+\s*(\_.{-})):',
\ 'formatter': ['\v\C^\s*', '', ''] }
\ ]
return filters
endfunction |
Finally, I've tested with a huge python file which has more than 10,000 lines.
As you say, non-greedy version is very very improved!! more than 70 times faster!! Also, I've confirmed your improved regex capture both 1 line and multi-lines func defs properly. Thanks, |
Done :) |
Cool - thanks :) |
Just as a note. Its not that i have a slow PC (i have the latest i7). The problem is that most of the files that i edit are on a remote PC. So it slow cuz of slow network/IO. Thats why a local cache would make a lot of difference in my environment. :) Will try to look into how neocomplete does it and have that as the reference implementation. |
Yes, that would be a cool feature. Standard CtrlP ctags buffer definitely starts noticeably faster (immediately). I have relatively big Objective-C files that I edit every day. |
@dusans: i see that your situation. ok - I think I'll implement this feature some time soon. |
Note: This implementation is rough, so refactoring required
@dusans @EDmitry I'll improve and refactoring this implementation. Pls lemme know if you notice any problems. |
@tacahiroy thanks 👍 but on my end "function sorting (on most used)" #15 doesn't work any more. edit: now i see. This is only on the add-mru-func branch? |
Tested. Looks fine to me. As far as i see u check the sha256 of the whole file. I think u only need to check the last modified time-stamp. |
i tested this and it works fine (for me) :) diff --git a/autoload/ctrlp/funky.vim b/autoload/ctrlp/funky.vim
index f24bedf..735663b 100644
--- a/autoload/ctrlp/funky.vim
+++ b/autoload/ctrlp/funky.vim
@@ -88,8 +88,8 @@ function! s:cache.fname(bufnr, ...)
endfunction
function! s:cache.save(bufnr, defs)
- let h = sha256(string(getbufline(bufname(a:bufnr), 1, '$')))
let fname = self.fname(a:bufnr)
+ let h = getftime(fname)
" save function defs
let self.list[fname] = extend([h], a:defs)
call writefile(self.list[fname], s:cache_dir . '/' . self.conv_name(fname))
@@ -121,8 +121,9 @@ function! s:cache.read(bufnr)
endfunction
function! s:cache.is_same_file(bufnr)
+ let fname = self.fname(a:bufnr)
let prev_hash = self.hash(a:bufnr)
- let cur_hash = sha256(string(getbufline(bufname(a:bufnr), 1, '$')))
+ let cur_hash = getftime(fname)
return prev_hash == cur_hash
endfunction |
indeed - I thought hash is more accurate, but timestamp is enough in almost of the case. |
@tacahiroy how about timestamp & file_size? |
cool - that idea is ok in case of 99% I guess. |
I've implemented the timestamp and file size way. The remaining tasks are
|
Great. Will test it on Windows 7 64-bit tomorrow 👍 |
cool - but please gimme 1 day more, coz the code doesn't consider Windows environments at all. |
I've implemented Windows support for the cache feature. FYI: You need to set let g:ctrlp_funky_use_cache = 1 |
Tested on Windows. Works. What is being saved to the .cache dir? Because there is only file with the name Z that is empty. |
cool - basically, the funky saves cache files into the cache directory. I need to implement the case for unnamed buffer. |
ah - no. unnamed/nofile buffers should be ignored, coz it doesn't have timestamp and file size .Also it's not a file ofc. |
I've just merged the branch into master: 373ff9a Thanks guys |
Would it be possible to implement a cache for ctrlp-funky?
If the file didn't change since the last usage of ctrlp-funky there is no need to run the search again :)
This is noticeable when using ctrlp-funky on larger source files ( > 1000 lines) (python in my case)
The text was updated successfully, but these errors were encountered: