Reputation: 9213
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.
Upvotes: 5
Views: 1200
Reputation: 4740
You don't say whether you use eshell
or shell
. In my experience, shell
works just fine, but eshell
is completely unusable for anything that wants to put >1k lines through a pipe (which is sad, because the other features of eshell look quite nice).
Note eshell is slow even if output is just one line, as long as you use a |
, so it seems to be the actual |
operator (that's implemented in emacs-lisp in eshell) that's being slow.
Upvotes: 0
Reputation: 155406
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.
Upvotes: 3
Reputation: 53694
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.
Upvotes: 2