nathangrigg / vim-beancount

Vim ftplugin for beancount
161 stars 41 forks source link

function! BeancountFoldexpr() causing significant lag #69

Open alexason opened 3 years ago

alexason commented 3 years ago

Hi there,

Just went through the process of installing vim-beancount on a new computer and found significant lag after installing the plugin. Seems to occur with most operations, i.e. with account auto completion and in auto aligning of the commodity.

I ran a :h profile in vim and just tried typing a commodity value, letting it auto complete then deleting. See the times below, 6.421180s for BeancountFoldexpr().

I subsequently rolled back to a version circa march last year and issue was gone. Given the last commit was implementation of the beancount#align_commodity() function I am pretty sure this is the culprit.

I have attached the profile.log file if this helps. In addition my vimrc has folding set to indent.

Please let me know if I can assist further.

Cheers, Alexason

profile.log

FUNCTIONS SORTED ON SELF TIME count total (s) self (s) function 699132 6.421180 BeancountFoldexpr() 1 0.136508 0.012212 beancount#align_commodity() 58 0.002640 0.002322 18_Highlight_Matching_Pair() 58 0.000318 18_Remove_Matches() 1 0.000042 0.000024 GetBeancountIndent() 1 0.000007 28_IsDirective() 1 0.000005 28_IsTransaction() 1 0.000003 28_IsPosting() 1 0.000003 28_IsMetadata()

mschwld commented 3 years ago

Same issue here. After switching back to this commit the issue was gone for me.

xentac commented 3 years ago

Sorry everyone. I was trying to speed up folding in my own file. Syntax folding was particularly slow for me. How big are your beancount files, how many folds do you think you have, and do you open the files with everything folded like I do?

mschwld commented 3 years ago

My beancount file currently has 828KB with around 19K lines in total. But i disabled folding using the following in $HOME/.vimrc (taken from #61):

augroup filetype_options
  autocmd Filetype beancount setlocal nofoldenable
augroup END