Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using racket-mode to edit source in org-mode document causing 100% cpu #348

Closed
bhrgunatha opened this issue Jan 16, 2019 · 5 comments
Closed
Labels

Comments

@bhrgunatha
Copy link

bhrgunatha commented Jan 16, 2019

I'm back again with a different 100% scenario - ref previous issue #318

  • Emacs 26.1
  • racket-mode - melpa 20181206.329
  • org-mode 9.2 (see below though)

racket-bug-report output:

``` ((emacs-version "26.1") (emacs-uptime "7 minutes, 44 seconds") (system-type gnu/linux) (major-mode racket-mode) (racket--el-source-dir "/home/bhrgunatha/.emacs.d/.cask/26.1/elpa/racket-mode-20181206.329/") (racket--rkt-source-dir "/home/bhrgunatha/.emacs.d/.cask/26.1/elpa/racket-mode-20181206.329/racket/") (racket-program "racket") (racket-command-port 55555) (racket-command-timeout 10) (racket-memory-limit 2048) (racket-error-context medium) (racket-retry-as-skeleton t) (racket-error-context medium) (racket-history-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'") (racket-images-inline t) (racket-images-keep-last 100) (racket-use-repl-submit-predicate nil) (racket-images-system-viewer "display") (racket-pretty-print t) (racket-indent-curly-as-sequence t) (racket-indent-sequence-depth 0) (racket-pretty-lambda nil) (racket-smart-open-bracket-enable nil) (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)") (racket-logger-config ((cm-accomplice . warning) (GC . info) (module-prefetch . warning) (optimizer . info) (racket/contract . error) (sequence-specialization . info) (* . fatal)))) (enabled-minor-modes (auto-composition-mode) (auto-compression-mode) (auto-encryption-mode) (auto-fill-mode) (auto-save-mode) (company-mode) (delete-selection-mode) (display-line-numbers-mode) (electric-indent-mode) (file-name-shadow-mode) (font-lock-mode) (global-company-mode) (global-display-line-numbers-mode) (global-eldoc-mode) (global-font-lock-mode) (global-hl-line-mode) (global-visual-line-mode) (hs-minor-mode) (ivy-mode) (line-number-mode) (menu-bar-mode) (mouse-wheel-mode) (org-src-mode) (paredit-mode) (pcre-mode) (rainbow-delimiters-mode) (show-paren-mode) (tooltip-mode) (transient-mark-mode) (visual-line-mode) (yas-global-mode) (yas-minor-mode)) (disabled-minor-modes (abbrev-mode) (auto-fill-function) (auto-save-visited-mode) (blink-cursor-mode) (buffer-read-only) (cl-old-struct-compat-mode) (column-number-mode) (company-search-mode) (compilation-in-progress) (compilation-minor-mode) (compilation-shell-minor-mode) (completion-in-region-mode) (counsel-mode) (defining-kbd-macro) (dired-hide-details-mode) (display-time-mode) (doc-view-minor-mode) (eldoc-mode) (electric-layout-mode) (electric-pair-mode) (electric-quote-mode) (global-prettify-symbols-mode) (gnus-dead-summary-mode) (gnus-undo-mode) (hl-line-mode) (horizontal-scroll-bar-mode) (ido-everywhere) (image-minor-mode) (isearch-mode) (jit-lock-debug-mode) (mail-abbrevs-mode) (mml-mode) (next-error-follow-minor-mode) (org-bullets-mode) (org-cdlatex-mode) (outline-minor-mode) (overwrite-mode) (package-build-minor-mode) (paragraph-indent-minor-mode) (prettify-symbols-mode) (racket-check-syntax-mode) (rxt--read-pcre-mode) (rxt-global-mode) (rxt-mode) (server-mode) (sh-electric-here-document-mode) (show-smartparens-global-mode) (show-smartparens-mode) (size-indication-mode) (smartparens-global-mode) (smartparens-global-strict-mode) (smartparens-mode) (smartparens-strict-mode) (temp-buffer-resize-mode) (tool-bar-mode) (unify-8859-on-decoding-mode) (unify-8859-on-encoding-mode) (url-handler-mode) (use-hard-newlines) (view-mode) (visible-mode) (window-divider-mode) (xref-etags-mode)) ```

I use the org-plus-contrib package from their own repository http://orgmode.org/elpa which bundles org mode plus contributed packages.

To reproduce this issue:

  • create a new file test.org
  • create a racket source code block C-s C-, s TAB or just
#+begin_src racket

#+end_src
  • Use racket-mode to edit the code block in a separate window C-c '
  • In the new window type in (de| ... and a message appears in the mini-buffer immediately saying "Still trying to connect to the racket-command process on port 55555 but emacs becomes unresponsive at 100% CPU in a similar way to melpa racket-mode causes emacs to become unresponsive with 100% CPU #318

A couple of observations:
Any typing at the keyboard is inserted into the buffer after C-g is pressed and it seems C-g works consistently to end the problem.
Making a further source code block works fine and doesn't hang and the racket REPL buffer is also still present.

I think this is a racket-mode issue rather than org-mode because editing a python code block doesn't prevent company mode completion or cause a CPU spike.

@greghendershott
Copy link
Owner

Thank you for the report.

This might be some kind of variation of #344 which also involves company-mode.


Although I think company-mode is wonderful for auto-completion, I prefer pressing TAB to complete manually, so I'm afraid it doesn't get "dog-fooded" by me. An ideal fix would also include updating racket-tests.el to package-install company-mode, enable it, and try a few simple things. Maybe I should add that as an issue, in case anyone else has time to help by adding that. (I've been kind of swamped by paid contract work lately.)

greghendershott pushed a commit that referenced this issue Jan 16, 2019
I noticed when testing on Windows, that sometimes the connection would
not succeed, and furthermore get stuck in a state where
racket--cmd-connecting-p was left non-nil.

This commit fixed that for me.

Although this might have some bearing on issue #344 and issue #348, I
don't have any reason to think this fixes those.
greghendershott pushed a commit that referenced this issue Jan 16, 2019
I noticed when testing on Windows, that sometimes the connection would
not succeed, and furthermore get stuck in a state where
racket--cmd-connecting-p was left non-nil.

This commit fixed that for me.

Although this might have some bearing on issue #344 and issue #348, I
don't have any reason to think this fixes those.
@greghendershott
Copy link
Owner

I can't seem to reproduce this. When I type de, it doesn't try to connect. Instead I get a company-mode window showing candidates. I can press RET to choose one and continue. C-u ' takes me back to the org file, as expected.

racket-mode needn't start a racket process and the REPL, to get completion candidates. Ever since commit b0296d9 in July 2018, if the REPL isn't running, it doesn't try to start it. Instead it simply uses for completion candidates the same default list used for font-lock. The idea was to avoid exactly this kind of problem trying to start Racket while you're typing.

Your details suggest you have quite recent racket-mode, including this commit:

(racket--el-source-dir "/home/bhrgunatha/.emacs.d/.cask/26.1/elpa/racket-mode-20181206.329/")
(racket--rkt-source-dir "/home/bhrgunatha/.emacs.d/.cask/26.1/elpa/racket-mode-20181206.329/racket/")

So I am super confused why you're seeing this. 🙁

@bhrgunatha
Copy link
Author

bhrgunatha commented Jan 17, 2019

I'm not sure why the REPL would get started but I it seems likely that is where the issue lies.
After the window & buffer to edit source code from org mode appears:

Type (
Type d
Type e

emacs hangs - 1 core is 100% CPU in process monitor

CTRL-g - emacs returns to normal
run.rkt appears in process monitor as a separate process

Here's what appears in the *Messages* buffer during this experiment::

Indenting region...done
Checking Racket version ...
Starting racket to run /home/bhrgunatha/.emacs.d/.cask/26.1/elpa/racket-mode-20181206.329/racket/run.rkt ...
Still trying to connect to racket-command process on port 55555 ... [231391 times]
Connected to racket-command process on port 55555 after 2 attempt(s)

Seems like a tight loop checking for the racket command to appear is causing the CPU spike. CTRL-g ends that for some reason - racket command process appears and things come back to normal.

I'm not sure how or why company-mode is related but if I disable company-mode there is no hang. Re-enabling indeed cusses the hang to return. My company version is company-20190109.2336 (again from melpa).

I wonder if it's related to emacs 26.1's new threading behaviour?

EDIT: Further: it doesn't appear to be the company-mode/racket-mode combination - that works well for me - it seems to be org-mode/company-mode/racket-mode.

@bhrgunatha
Copy link
Author

After tinkering around, trying to track down the cause issue I've edited several files in racket-mode, org-mode and company-mode.
I've just nuked my whole package folder and re-installed all packages and now I can't reproduce the issue.

The README does say it might be necessary to delete and re-install racket-mode for updates and I think that has fixed my problem.

I really should have done that first, so sorry to have wasted your time.

@greghendershott
Copy link
Owner

No worries. At the time you reported this, #344 was still open so it seemed credible you'd found a variant (plus I was already looking at #344 so it wasn't much incremental effort to look at yours).

greghendershott pushed a commit that referenced this issue Apr 6, 2019
I noticed when testing on Windows, that sometimes the connection would
not succeed, and furthermore get stuck in a state where
racket--cmd-connecting-p was left non-nil.

This commit fixed that for me.

Although this might have some bearing on issue #344 and issue #348, I
don't have any reason to think this fixes those.

-----------------------------------------------------------------

PROVENANCE: Today I noticed commit 98bb9c7 and commit cedf4ba linked
to from the above issues. But I do not have either commit in any of my
local repos, not even according to `git fsck --lost-found`. WAT.

I suspect what happened was that I made a topic branch and pushed a
commit, which is why GitHub got it (and apparently will keep it
indefinitely because of the link from comments). But then I deleted
the branch without merging. Or possibly that commit was rebased away
before merging the branch.

Probably this happened on a new Windows laptop. In my defense,
mid-January I was moving between Mac and Windows, as part of an effort
to improve racket-mode support on the latter. And then, a Linux laptop
got added to the mix, as well.

In any case I'm going to recover and use this commit, now. The bit
above the horizontal line is the commit message.
greghendershott pushed a commit that referenced this issue Apr 15, 2019
I noticed when testing on Windows, that sometimes the connection would
not succeed, and furthermore get stuck in a state where
racket--cmd-connecting-p was left non-nil.

This commit fixed that for me.

Although this might have some bearing on issue #344 and issue #348, I
don't have any reason to think this fixes those.

-----------------------------------------------------------------

PROVENANCE: Today I noticed commit 98bb9c7 and commit cedf4ba linked
to from the above issues. But I do not have either commit in any of my
local repos, not even according to `git fsck --lost-found`. WAT.

I suspect what happened was that I made a topic branch and pushed a
commit, which is why GitHub got it (and apparently will keep it
indefinitely because of the link from comments). But then I deleted
the branch without merging. Or possibly that commit was rebased away
before merging the branch.

Probably this happened on a new Windows laptop. In my defense,
mid-January I was moving between Mac and Windows, as part of an effort
to improve racket-mode support on the latter. And then, a Linux laptop
got added to the mix, as well.

In any case I'm going to recover and use this commit, now. The bit
above the horizontal line is the commit message.
greghendershott pushed a commit that referenced this issue Apr 16, 2019
I noticed when testing on Windows, that sometimes the connection would
not succeed, and furthermore get stuck in a state where
racket--cmd-connecting-p was left non-nil.

This commit fixed that for me.

Although this might have some bearing on issue #344 and issue #348, I
don't have any reason to think this fixes those.

-----------------------------------------------------------------

PROVENANCE: Today I noticed commit 98bb9c7 and commit cedf4ba linked
to from the above issues. But I do not have either commit in any of my
local repos, not even according to `git fsck --lost-found`. WAT.

I suspect what happened was that I made a topic branch and pushed a
commit, which is why GitHub got it (and apparently will keep it
indefinitely because of the link from comments). But then I deleted
the branch without merging. Or possibly that commit was rebased away
before merging the branch.

Probably this happened on a new Windows laptop. In my defense,
mid-January I was moving between Mac and Windows, as part of an effort
to improve racket-mode support on the latter. And then, a Linux laptop
got added to the mix, as well.

In any case I'm going to recover and use this commit, now. The bit
above the horizontal line is the commit message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants