Skip to content

cider-eldoc-beginning-of-sexp is slow in large buffers #1820

@leppert

Description

@leppert

cider-eldoc-beginning-of-sexp can cause Emacs to hang / freeze when visiting large buffers.

Test file (adjust the range end to taste):

(->>
  (map #(hash-map :foo % :bar %) (range 1 300000))
  clojure.pprint/pprint
  with-out-str
  (spit "test.edn"))

Visit the resulting test.edn file with cider-mode and eldoc-mode enabled and a repl session running, then jump from the beginning of the buffer to the end of the buffer. On my system, this causes Emacs to freeze. Disabling cider-mode is not enough as the cider-eldoc functions are still called even after cider-mode has been disabled for the buffer (is this expected?). Eldoc must be disabled or the repl session must be terminated before performance will return to normal.

This appears similar to what was addressed in #1502

Profile report:

- redisplay_internal (C function)                               10809 100%
 - debug                                                        10809 100%
  - recursive-edit                                              10797  99%
   - timer-event-handler                                        10625  98%
    - apply                                                     10625  98%
     - #<compiled 0x400e5859>                                   10623  98%
      - eldoc-print-current-symbol-info                         10623  98%
       - cider-eldoc                                            10623  98%
        - cider-eldoc-info-in-current-sexp                      10623  98%
         - cider-eldoc-info-at-point                             5424  50%
          - cider-eldoc-beginning-of-sexp                        5424  50%
             forward-sexp                                        5423  50%
         - cider-eldoc-info-at-sexp-beginning                    5199  48%
          - cider-eldoc-beginning-of-sexp                        5199  48%
             forward-sexp                                        5199  48%
     + show-paren-function                                          2   0%
   + command-execute                                              160   1%
+ ...                                                               0   0%

Environment & Version information

CIDER version information

;; CIDER 0.14.0snapshot (package: 20160806.2354), nREPL 0.2.12
;; Clojure 1.8.0, Java 1.8.0_40

Lein/Boot version

Leiningen 2.6.1 on Java 1.8.0_40 Java HotSpot(TM) 64-Bit Server VM

Emacs version

GNU Emacs 25.1.1 (x86_64-apple-darwin15.6.0, NS appkit-1404.47 Version 10.11.6 (Build 15G31)) of 2016-07-29

Operating system

Mac OS X 10.11.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions