kostafey / ejc-sql

Emacs SQL client uses Clojure JDBC.
278 stars 29 forks source link

ejc-sql company-mode is slow on completion with profiling data #141

Closed stardiviner closed 1 year ago

stardiviner commented 4 years ago

I used Emacs package explain-pause-mode profiled ejc-sql company-mode candidates completion. It's slow. Here is the profile data output:

- ...                                                                                  31 100%
 - #<compiled 0x4fe48adf20f077e>                                                       31 100%
  - apply                                                                              31 100%
   - #<compiled -0xcfb1de8da13d0b1>                                                    31 100%
    - company--perform                                                                 31 100%
     - company--continue                                                               29  93%
      - company-calculate-candidates                                                   29  93%
       - company--fetch-candidates                                                     29  93%
        - company-call-backend-raw                                                     29  93%
         - apply                                                                       29  93%
          - company--multi-backend-adapter                                             29  93%
           - company--multi-backend-adapter-candidates                                 29  93%
            - ejc-company-backend                                                      29  93%
             - ejc-company-candidates                                                  29  93%
              - ejc-colomns-candidates                                                  8  25%
               - ejc-get-colomns-candidates                                             5  16%
                - clomacs-ensure-nrepl-run                                              5  16%
                 - apply                                                                4  12%
                  - #<compiled 0x97eecaec6480c35>                                       4  12%
                   - nrepl-sync-request:eval                                            4  12%
                    - nrepl-send-sync-request                                           3   9%
                     - accept-process-output                                            3   9%
                      - #<compiled 0xe0c7c00bc55ada3>                                   3   9%
                       - apply                                                          3   9%
                        - explain-pause--wrap-callback                                  3   9%
                         - apply                                                        3   9%
                          - nrepl-client-filter                                         3   9%
                           - nrepl-bdecode                                              3   9%
                            - fundamental-mode                                          2   6%
                             - kill-all-local-variables                                 2   6%
                              - yas-global-mode-cmhh                                    1   3%
                               - add-hook                                               1   3%
                                - explain-pause--wrap-add-hook                          1   3%
                                 - advice-add                                           1   3%
                                  - advice--add-function                                1   3%
                                     advice--make                                       1   3%
                              - mode-local-on-major-mode-change                         1   3%
                               - add-hook                                               1   3%
                                - explain-pause--wrap-add-hook                          1   3%
                                 - advice-add                                           1   3%
                                  - advice--add-function                                1   3%
                                   - advice--remove-function                            1   3%
                                    - advice--tweak                                     1   3%
                                     - #<compiled -0x14ee3bcee4aa2baf>                  1   3%
                                        advice--remove-function                         1   3%
                            - nrepl--bdecode-message                                    1   3%
                               nrepl--bdecode-1                                         1   3%
                 - clomacs-get-connection                                               1   3%
                  - clomacs-search-connection                                           1   3%
                   - maphash                                                            1   3%
                      #<compiled 0xb76f49269b00b0a>                                     1   3%
               - ejc-get-sql-boundaries-at-point                                        3   9%
                - ejc-get-border-top                                                    2   6%
                 - beginning-of-buffer                                                  2   6%
                  - push-mark                                                           2   6%
                   - apply                                                              2   6%
                      helm--advice-push-mark                                            2   6%
                - ejc-get-border-bottom                                                 1   3%
                 - end-of-buffer                                                        1   3%
                  - push-mark                                                           1   3%
                   - apply                                                              1   3%
                      helm--advice-push-mark                                            1   3%
              - ejc-packages-candidates                                                 7  22%
               - ejc-get-packages-candidates                                            4  12%
                - clomacs-ensure-nrepl-run                                              4  12%
                 - apply                                                                4  12%
                  - #<compiled 0x97eecaec6480c35>                                       4  12%
                   - nrepl-sync-request:eval                                            3   9%
                    - nrepl-send-sync-request                                           3   9%
                     - accept-process-output                                            1   3%
                      - #<compiled 0xe0c7c00bc55ada3>                                   1   3%
                       - apply                                                          1   3%
                        - explain-pause--wrap-callback                                  1   3%
                         - apply                                                        1   3%
                          - nrepl-client-filter                                         1   3%
                             nrepl-bdecode                                              1   3%
                   - clomacs-get-result                                                 1   3%
                    - #<compiled 0x64945663f25481c>                                     1   3%
                       clomacs-format-result                                            1   3%
               - ejc-get-sql-boundaries-at-point                                        2   6%
                - ejc-get-border-bottom                                                 2   6%
                 - end-of-buffer                                                        2   6%
                  - push-mark                                                           2   6%
                   - apply                                                              2   6%
                      helm--advice-push-mark                                            2   6%
               - ejc-buffer-connected-p                                                 1   3%
                - clomacs-get-connection                                                1   3%
                 - clomacs-search-connection                                            1   3%
                  - maphash                                                             1   3%
                     #<compiled 0xb76f49269b00b0a>                                      1   3%
              - ejc-tables-candidates                                                   5  16%
               - ejc-get-sql-boundaries-at-point                                        4  12%
                - ejc-get-border-top                                                    2   6%
                 - beginning-of-buffer                                                  2   6%
                  - push-mark                                                           2   6%
                   - apply                                                              2   6%
                      helm--advice-push-mark                                            2   6%
                - ejc-get-border-bottom                                                 2   6%
                 - end-of-buffer                                                        2   6%
                  - push-mark                                                           1   3%
                   - apply                                                              1   3%
                      helm--advice-push-mark                                            1   3%
               - ejc-get-tables-candidates                                              1   3%
                - clomacs-ensure-nrepl-run                                              1   3%
                 - apply                                                                1   3%
                  - #<compiled 0x97eecaec6480c35>                                       1   3%
                   - clomacs-get-connection                                             1   3%
                    - clomacs-search-connection                                         1   3%
                     - maphash                                                          1   3%
                        #<compiled 0xb76f49269b00b0a>                                   1   3%
              - ejc-views-candidates                                                    5  16%
               - ejc-get-sql-boundaries-at-point                                        3   9%
                - ejc-get-border-top                                                    2   6%
                 - beginning-of-buffer                                                  2   6%
                  - push-mark                                                           2   6%
                   - apply                                                              2   6%
                      helm--advice-push-mark                                            2   6%
                - ejc-get-border-bottom                                                 1   3%
                 - end-of-buffer                                                        1   3%
                  - push-mark                                                           1   3%
                   - apply                                                              1   3%
                      helm--advice-push-mark                                            1   3%
               - ejc-get-views-candidates                                               2   6%
                - clomacs-ensure-nrepl-run                                              2   6%
                 - apply                                                                2   6%
                  - #<compiled 0x97eecaec6480c35>                                       2   6%
                   - clomacs-format-arg                                                 1   3%
                    - clomacs-alist-to-map                                              1   3%
                     - cl-reduce                                                        1   3%
                      - #<compiled 0x1e982b6be908d30c>                                  1   3%
                       - clomacs-format-arg                                             1   3%
                          clomacs-add-quotes                                            1   3%
                   - nrepl-sync-request:eval                                            1   3%
                      nrepl-send-sync-request                                           1   3%
              - ejc-owners-candidates                                                   4  12%
               - ejc-get-sql-boundaries-at-point                                        3   9%
                - ejc-get-border-bottom                                                 2   6%
                 - end-of-buffer                                                        2   6%
                  - push-mark                                                           2   6%
                   - apply                                                              2   6%
                      helm--advice-push-mark                                            2   6%
                - ejc-get-border-top                                                    1   3%
                 - beginning-of-buffer                                                  1   3%
                  - push-mark                                                           1   3%
                   - apply                                                              1   3%
                      helm--advice-push-mark                                            1   3%
               - ejc-get-owners-candidates                                              1   3%
                - clomacs-ensure-nrepl-run                                              1   3%
                 - apply                                                                1   3%
                  - #<compiled 0x97eecaec6480c35>                                       1   3%
                   - nrepl-sync-request:eval                                            1   3%
                      nrepl-send-sync-request                                           1   3%
     - company-call-frontends                                                           2   6%
      - company-box-frontend                                                            2   6%
       - cond                                                                           2   6%
        + company-box-show                                                              2   6%
   Automatic GC                                                                         0   0%

From the output, can see not other extensions caused slow. Is there space to improve the speed for company-mdoe?

kostafey commented 1 year ago

@stardiviner, can you still reproduce the issue?

stardiviner commented 1 year ago

Currenct seems not slow as before.

I redo profiling again, and attached new result here. (P.S. If you're insterested)

CPU-Profiler-Report.txt Memory-Profiler-Report.txt