tomtom/quickfixsigns_vim

Performance impact / Profiling information

blueyed opened this issue · 1 comments

I have profiled Vim and QuickfixsignsSet showed up at the top of total time.

This is somehow expected, but could be improved probably.

(I have thought about limiting the number of autocommands that quickfixsigns hooks into (I have removed InsertEnter lately already), and map it to be manually invoked more easily.)

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    1 214.691464             ProfileStart()
 2301 191.327777   4.268072  QuickfixsignsSet()
 2297  78.658742  29.771446  <SNR>139_UpdateLineNumbers()
 3051  57.010167   0.096809  <SNR>139_UpdateSigns()
 5493  45.500201   0.395611  <SNR>139_GetList()
34019  41.921944   9.328961  QuickfixsignsListBufferSigns()
 3051  40.971002  39.554442  <SNR>139_PlaceSign()
12324  38.826146   3.417537  airline#extensions#eclim#get_warnings()
12324  35.407916  11.619772  eclim#display#signs#GetExisting()
 2046  35.288865   2.569651  <SNR>139_GetQFList()
 4092  32.798225  32.798089  QuickfixsignsUnique()
522201  29.097198             <SNR>139_ProcessSign()
 2874  27.687551   1.663351  youcompleteme#Complete()
 1437  26.024200   7.721748  <SNR>256_CompletionsForQuery()
  251  24.106949  23.851175  <SNR>256_OnBufferVisit()
323739  23.788144             <SNR>322_ParseSign()
 5633  21.483068             <SNR>139_ClearSigns()
 5488  20.365708   5.619774  <SNR>139_ClearBuffer()
 1926  17.931941   1.434201  <SNR>321_AutoUpdate()
14979  16.186684   1.890888  airline#check_mode()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    1            214.691464  ProfileStart()
 3051  40.971002  39.554442  <SNR>139_PlaceSign()
 4092  32.798225  32.798089  QuickfixsignsUnique()
 2297  78.658742  29.771446  <SNR>139_UpdateLineNumbers()
522201             29.097198  <SNR>139_ProcessSign()
  251  24.106949  23.851175  <SNR>256_OnBufferVisit()
323739             23.788144  <SNR>322_ParseSign()
 5633             21.483068  <SNR>139_ClearSigns()
   10  14.818848  14.808311  phpcomplete#CompletePHP()
12324  35.407916  11.619772  eclim#display#signs#GetExisting()
34019  41.921944   9.328961  QuickfixsignsListBufferSigns()
    2   8.459045   7.954233  tinykeymap#Call()
 1437  26.024200   7.721748  <SNR>256_CompletionsForQuery()
 7606              7.287279  <SNR>29_Highlight_Matching_Pair()
331262              6.789181  <SNR>183_MruSorter()
 5488  20.365708   5.619774  <SNR>139_ClearBuffer()
80396              4.800586  airline#highlighter#exec()
 2301 191.327777   4.268072  QuickfixsignsSet()
76784              4.199009  <SNR>247_get_syn()
    6   5.326818   4.150049  <SNR>58_CommandTShowFileFinder()


FUNCTION  QuickfixsignsSet()
Called 2301 times
Total time: 191.327777
 Self time:   4.268072

count  total (s)   self (s)
                                " TLogVAR a:event, a:000
 2301              0.035355     if exists("b:noquickfixsigns") && b:noquickfixsigns
                                    return
                                endif
 2301   1.265363   0.045378     let bufsignclasses = s:ListValues()
                                " TLogVAR bufsignclasses
 2301              0.020525     if empty(bufsignclasses)
                                    return
                                endif
                                " TLogVAR a:event, a:000
 2301              0.027200     let filename = a:0 >= 2 ? a:2 : expand('%:p')
                                " TLogVAR a:event, filename, bufname('%')
 2301              0.160028     if fnamemodify(filename, ':t') =~ g:quickfixsigns_blacklist_buffer
    4              0.000006         return
                                endif
 2297              0.030495     if !exists('b:quickfixsigns_last_line')
   39              0.000162         let b:quickfixsigns_last_line = 0
   39              0.000039     endif
 2297              0.921311     let bufnr = bufnr(filename)
 2297              0.030793     let anyway = empty(a:event)
                                " TLogVAR bufnr, anyway, a:event
 2297  78.743457   0.084715     call s:UpdateLineNumbers()
13782              0.036108     for [class, def] in bufsignclasses
                                    " TLogVAR class, def
11485              0.016887         if anyway
                                        let set = 1
                                    elseif index(get(def, 'event', ['BufEnter']), a:event) != -1
 8545              0.064863             let set = !has_key(def, 'test') || eval(def.test)
 8545              0.007741         else
 2940              0.005492             let set = 0
 2940              0.002381         endif
11485              0.036915         if a:0 >= 1 && !empty(a:1)
                                        let select = index(a:1, class) != -1
                                    else
11485              0.021334             let select = 1
11485              0.009042         endif
11485              0.019543         if set && select
                                        " TLogVAR class, set, select
 6981              0.025490             let t_d = get(def, 'timeout', 0)
 6981              0.020582             let t_l = localtime()
 6981              0.080999             let t_s = string(def)
 6981              0.032411             if !exists('b:quickfixsigns_last_run')
   39              0.000144                 let b:quickfixsigns_last_run = {}
   39              0.000035             endif
                                        " TLogVAR t_s, t_d, t_l
 6981              0.043258             if anyway || (t_d == 0) || (t_l - get(b:quickfixsigns_last_run, t_s, 0) >= t_d)
 5488              0.010332                 if g:quickfixsigns_debug
                                                call quickfixsigns#AssertNoObsoleteBuffers(g:quickfixsigns_register)
                                            endif
 5488              0.029674                 let b:quickfixsigns_last_run[t_s] = t_l
 5488  46.336360   0.895443                 let list = s:GetList(def, filename)
                                            " TLogVAR len(list)
                                            " TLogVAR list
                                            " TLogVAR class, 'scope == buffer'
 5488   0.262119   0.072753                 let scope_test = s:GetScopeTest(class, bufnr, '')
 5488              0.016247                 if !empty(scope_test)
                                                " echom "DBG" scope_test
                                                " echom "DBG" string(list)
 3443              0.079393                     call filter(list, scope_test)
 3443              0.003935                 endif
                                            " TLogVAR list
 5488              0.027498                 let maxsigns = get(def, 'maxsigns', g:quickfixsigns_max)
 5488              0.024419                 if !empty(list) && len(list) <= maxsigns
 3051  57.039302   0.029135                     call s:UpdateSigns(class, def, bufnr, list)
 3051              0.015206                     if has('balloon_eval') && g:quickfixsigns_balloon
 3051              0.015022                         if exists('g:loaded_tlib') && g:loaded_tlib >= 39  " ignore dependency
 3051   0.142567   0.025391                             call tlib#balloon#Register('QuickfixsignsBalloon()')
 3051              0.009448                         elseif !exists('b:quickfixsigns_balloon') && empty(&balloonexpr)
                                                        let b:quickfixsigns_ballooneval = &ballooneval
                                                        let b:quickfixsigns_balloonexpr = &balloonexpr
                                                        setlocal ballooneval balloonexpr=QuickfixsignsBalloon()
                                                        let b:quickfixsigns_balloon = 1
                                                    endif
 3051              0.002581                     endif
 3051              0.002307                 else
 2437              0.007457                     if !empty(list) && g:quickfixsigns_debug
                                                    echohl WarningMsg
                                                    echom 'QuickFixSigns DEBUG: not displaying' len(list) class 'signs (max' maxsigns .'; see :h g:quickfixsigns_max).'
                                                    echohl NONE
                                                endif
 2437   4.444947   0.021595                     call s:ClearBuffer(class, def.sign, bufnr, [])
 2437              0.002319                 endif
 5488              0.006581             endif
 6981              0.005059         endif
11485              0.013055     endfor
 2297              0.012752     let b:quickfixsigns_last_line = line('.')

Thanks. Are you concerned about CPU wakeups (laptop battery) or about
VIM usability?

Most sign classes have a timeout set to avoid updating signs too often
-- I now added a global option. I also added some caching to avoid
certain updates. Please let me know if these changes improve the situation.