Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do commands run considerably slower in the emacs shell? How can I prevent this but still use it?

Tags:

unix

emacs

Today I ran a command like this in the emacs shell:

./someBinary | grep foo | cut -c30- | sort | uniq -c

which in bash takes a bit but not that long (about 15 seconds) because the output is over a million lines easily. When I ran this command in the emacs shell, however, I waited over an hour and it's still running, with the processes visibly doing work if i check with top. I wonder if this is because emacs implements the unix tools I am piping to in lisp - and if this is the reason, if there's a way to have it default to the system ones.

like image 398
Palace Chan Avatar asked Oct 31 '12 23:10

Palace Chan


People also ask

How do I run a shell command in Emacs?

You can execute an external shell command from within Emacs using ` M-! ' ( 'shell-command' ). The output from the shell command is displayed in the minibuffer or in a separate buffer, depending on the output size.

How do I stop Emacs shell?

Killing Emacs means terminating the Emacs program. To do this, type C-x C-c ( save-buffers-kill-terminal ). A two-character key sequence is used to make it harder to type by accident. If there are any modified file-visiting buffers when you type C-x C-c , Emacs first offers to save these buffers.

How do I run a script in Emacs?

If the script is executable, you can execute it with C-c C-x ( executable-interpret ). You'll be given the opportunity to pass arguments. (This command works no matter what language the program is written in, by the way, as long as the file you're editing is executable.)

How do I move around in Emacs?

The keybindings for movement by word in Emacs is almost the same as that of movement by character, but instead of the prefix C- it is M- . To move forward one word use M-f ; and to move backward one word use M-b . Movement by word will make up the bulk of your intra-line movement.


2 Answers

Emacs is capturing the final output in the shell buffer, and applying font-lock and other analysis (line number counting, for example) to display it. It also scrolls the display to show the latest output. While Emacs has provisions for culling pathologically long command output, it's not really optimized for truly huge quantities of output counting in millions of lines, so it performs visibly worse than your terminal emulator, slowing down the whole pipeline.

If you're not interested in the output, redirect it to /dev/null or to tail -500, which is how much you'd see of it in a typical terminal scrollback anyway.

like image 192
user4815162342 Avatar answered Sep 20 '22 09:09

user4815162342


no, emacs does not implement those tools. that is running the same tools you run from the command line. however, the output is being passed through various pipes and probably has various formatting applied by emacs, which is most likely the culprit for the extreme slowdown. one easy thing to try would be disabling font-lock mode in the shell buffer.

like image 25
jtahlborn Avatar answered Sep 21 '22 09:09

jtahlborn