milkypostman / powerline

emacs powerline

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Emacs 26 pixel-scroll-mode + powerline = insane amount of GCs

wyuenho opened this issue · comments

On Emacs 26, I have pixel-scroll-mode turned on and set gc-cons-threshold to 30mb, I then scrolled on my 1150-line long .emacs from top to bottom a couple of times. This is the memory profiling result:

- command-execute                                         551,621,177  95%
 - call-interactively                                     551,603,225  95%
  - apply                                                 551,603,225  95%
   - call-interactively@ido-cr+-record-current-command    551,595,833  95%
    - apply                                               551,595,833  95%
     - #<subr call-interactively>                         551,585,273  95%
      - funcall-interactively                             551,583,161  95%
       - mwheel-scroll                                    510,013,781  88%
        - pixel-scroll-up                                 330,574,847  57%
         - pixel-scroll-pixel-up                          195,280,496  33%
          - pixel--whistlestop-line-up                    115,137,483  19%
           - scroll-up                                     38,770,616   6%
            - eval                                         38,770,616   6%
             - let*                                        38,770,616   6%
              - list                                       24,430,275   4%
               + when                                       6,988,648   1%
               + powerline-buffer-id                        4,571,096   0%
               + funcall                                    4,225,848   0%
               + powerline-raw                              2,841,916   0%
               + powerline-major-mode                       2,603,512   0%
               + powerline-minor-modes                      2,388,976   0%
                 powerline-fill                               141,168   0%
                 unless                                        22,176   0%
              + concat                                      8,325,177   1%
                intern                                         75,984   0%
           + pixel--whistlestop-pixel-up                   37,533,682   6%
           - pixel-line-height                             36,621,101   6%
            - pixel-visual-line-height                     36,621,101   6%
             - pixel-visible-pos-in-window                 36,471,149   6%
              - pos-visible-in-window-p                    35,363,645   6%
               - eval                                      35,363,645   6%
                - let*                                     35,363,645   6%
                 - list                                    26,363,801   4%
                  + when                                    6,894,784   1%
                  + funcall                                 6,317,217   1%
                  + powerline-buffer-id                     4,610,984   0%
                  + powerline-raw                           2,778,732   0%
                  + powerline-major-mode                    2,553,900   0%
                  + powerline-minor-modes                   2,420,816   0%
                    powerline-fill                            131,776   0%
                    unless                                     27,456   0%
                 + concat                                   5,034,600   0%
                   intern                                      21,812   0%
                end-of-visual-line                            231,264   0%
              + window-inside-pixel-edges                     194,304   0%
                beginning-of-visual-line                      173,184   0%
                delete-dups                                     2,120   0%
           + sit-for                                        1,929,796   0%
          + pixel-line-height                              80,138,431  13%
         + pixel-point-at-top-p                            81,620,290  14%
         + pixel-line-height                               39,620,496   6%
         + scroll-up                                       13,330,869   2%
           pixel-scroll-in-rush-p                               1,064   0%
        + pixel-scroll-down                               174,967,270  30%
        + run-with-timer                                       67,584   0%
          #<compiled 0x400dc823>                               20,260   0%
       + amx                                               41,568,906   7%
       + beginning-of-buffer                                      474   0%
+ redisplay_internal (C function)                          22,065,920   3%
+ winner-save-old-configurations                            1,079,584   0%
+ timer-event-handler                                         850,624   0%
+ purpose-x-code1-debounced-update-changed                    507,936   0%
+ jit-lock-function                                           172,574   0%
+ ibuffer-auto-update-changed                                  76,714   0%
+ sp--save-pre-command-state                                   75,032   0%
+ ...                                                          18,504   0%
+ undo-auto--add-boundary                                       6,336   0%
+ eldoc-schedule-timer                                          3,168   0%
+ global-eldoc-mode-check-buffers                               1,056   0%
+ global-company-mode-check-buffers                             1,056   0%
+ global-move-dup-mode-check-buffers                            1,056   0%
+ show-smartparens-global-mode-check-buffers                    1,056   0%
+ blink-cursor-end                                              1,056   0%

This amount of memory consumption causes GC too frequently, and the GC pauses amounts of 11% of the time the CPU spends on.

+ command-execute                                                3604  86%
- ...                                                             479  11%
   Automatic GC                                                   479  11%
+ redisplay_internal (C function)                                  47   1%
+ timer-event-handler                                              18   0%
+ ibuffer-auto-update-changed                                       2   0%
+ sp--save-pre-command-state                                        1   0%
+ delete-selection-pre-hook                                         1   0%

This results on quite a bad UX since I can't scroll a couple of pages without see stutters for a few seconds.

Memory:

- command-execute                                         370,916,131  92%
 - call-interactively                                     370,833,763  92%
  - apply                                                 370,833,763  92%
   - call-interactively@ido-cr+-record-current-command    370,785,187  92%
    - apply                                               370,785,187  92%
     - #<subr call-interactively>                         370,740,835  92%
      - funcall-interactively                             370,714,435  92%
       - mwheel-scroll                                    326,141,341  81%
        - pixel-scroll-down                               309,225,013  77%
         - pixel-point-at-bottom-p                        175,192,501  43%
          - pixel-posn-y-at-point                         104,629,570  26%
           - posn-at-point                                  8,689,522   2%
            - eval                                          8,130,988   2%
               if                                           4,633,012   1%
             + mode-line-auto-compile-control               2,895,916   0%
               unless                                         136,224   0%
             + replace-regexp-in-string                        85,016   0%
             beginning-of-visual-line                       3,836,712   0%
          - pixel-visual-line-height                       69,070,691  17%
           - pixel-visible-pos-in-window                   65,360,590  16%
            - pos-visible-in-window-p                       7,875,652   1%
             - eval                                         7,875,652   1%
                if                                          4,610,024   1%
              + mode-line-auto-compile-control              2,683,644   0%
              + replace-regexp-in-string                      191,720   0%
                unless                                        117,216   0%
              end-of-visual-line                            4,844,752   1%
              beginning-of-visual-line                      3,873,584   0%
            + window-inside-pixel-edges                       739,200   0%
              delete-dups                                     169,680   0%
              number-sequence                                  11,740   0%
             line-pixel-height                                 22,724   0%
          + window-inside-pixel-edges                         770,880   0%
         - pixel-scroll-pixel-down                         59,687,160  14%
          + sit-for                                        31,601,856   7%
          - pixel-line-height                              16,809,024   4%
           - pixel-point-at-unseen-line                     9,449,576   2%
            - beginning-of-visual-line                      9,449,576   2%
             - line-move                                    7,596,032   1%
                line-move-visual                            3,457,840   0%
              + default-line-height                         2,242,944   0%
              + window-inside-pixel-edges                     366,432   0%
           + pixel-visual-line-height                       7,301,368   1%
          + pixel-scroll-down-and-set-window-vscroll       10,670,343   2%
            window-vscroll                                     22,724   0%
         + pixel-line-height                               17,036,704   4%
         + scroll-down                                      4,502,752   1%
           pixel-eob-at-top-p                                  62,304   0%
           pixel-scroll-in-rush-p                               7,448   0%
        + pixel-scroll-up                                  12,446,230   3%
        + run-with-timer                                      244,816   0%
          #<compiled 0x400dc823>                               11,874   0%
       + amx                                               44,572,852  11%
       + beginning-of-buffer                                      242   0%
+ redisplay_internal (C function)                          16,893,667   4%
+ winner-save-old-configurations                            8,243,224   2%
+ purpose-x-code1-debounced-update-changed                  3,740,176   0%
+ timer-event-handler                                         461,740   0%
+ sp--save-pre-command-state                                  316,920   0%
  eldoc-pre-command-refresh-echo-area                          35,240   0%
+ ibuffer-auto-update-changed                                  22,876   0%
+ undo-auto--add-boundary                                      15,840   0%
+ ...                                                           8,188   0%
  undefined                                                       834   0%

CPU:

+ command-execute                                               12209  85%
+ redisplay_internal (C function)                                1713  11%
- ...                                                             350   2%
   Automatic GC                                                   350   2%
+ timer-event-handler                                              32   0%
+ sp--save-pre-command-state                                        8   0%
+ purpose-x-code1-debounced-update-changed                          3   0%
+ ibuffer-auto-update-changed                                       2   0%
+ undo-auto--add-boundary                                           2   0%
+ winner-save-old-configurations                                    2   0%
  sp--post-command-hook-handler                                     1   0%
+ global-hl-line-maybe-unhighlight                                  1   0%

Obviously the next thing dominates memory usage, except that this time I can scroll and scroll for minutes with barely any stuttering, since GC now only counts as 2% of CPU time.

yeah this stinks. thanks for running the numbers. unfortunately i'm not maintaining this actively anymore so it'd take someone submitting a PR to fix things...