unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs crashes when writting JavaScript
       [not found] <87v9tqcd57.fsf.ref@yahoo.com.mx>
@ 2019-09-18  6:49 ` Jorge Javier Araya Navarro
  2019-09-18 12:18   ` Eli Zaretskii
  2019-09-23  0:50   ` Jackson Ray Hamilton
  0 siblings, 2 replies; 6+ messages in thread
From: Jorge Javier Araya Navarro @ 2019-09-18  6:49 UTC (permalink / raw)
  To: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]


Hello!

I'm using Emacs 27.x compiled from the master branch. I have noticed that after several hours of
work Emacs tends to crash or complete freeze the entire OS when I work on JavaScript code. I have
prettier-js which prettifies the source after saving the file to disk, but not sure if this could be
related. I also have suspicions on the parser of JS code, but because I have no idea how or where it
keeps the AST, I can't be sure if that is related to the crashes too, I come to notice that under
some circumstances –when the JSX code is fairly large and complex– Emacs slows down and feels heavy
sort-of-speak.

I would like to know if there is a way to monitor Emacs on a normal run and after it crashes get
back something that can help debugging whatever the issue happens to be. This behavior has become
recurrent during this month, IIRC.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs crashes when writting JavaScript
  2019-09-18  6:49 ` Emacs crashes when writting JavaScript Jorge Javier Araya Navarro
@ 2019-09-18 12:18   ` Eli Zaretskii
  2019-09-23  0:50   ` Jackson Ray Hamilton
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2019-09-18 12:18 UTC (permalink / raw)
  To: Jorge Javier Araya Navarro; +Cc: emacs-devel

> From: Jorge Javier Araya Navarro <jorgejavieran@yahoo.com.mx>
> Date: Wed, 18 Sep 2019 00:49:24 -0600
> 
> I'm using Emacs 27.x compiled from the master branch. I have noticed that after several hours of
> work Emacs tends to crash or complete freeze the entire OS when I work on JavaScript code. I have
> prettier-js which prettifies the source after saving the file to disk, but not sure if this could be
> related. I also have suspicions on the parser of JS code, but because I have no idea how or where it
> keeps the AST, I can't be sure if that is related to the crashes too, I come to notice that under
> some circumstances –when the JSX code is fairly large and complex– Emacs slows down and feels heavy
> sort-of-speak.
> 
> I would like to know if there is a way to monitor Emacs on a normal run and after it crashes get
> back something that can help debugging whatever the issue happens to be. This behavior has become
> recurrent during this month, IIRC.

Run Emacs under GDB, and when it crashes, produce a C-level backtrace
and report it with all the details to the bug tracker (M-x report-emacs-bug).

Thanks.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Emacs crashes when writting JavaScript
  2019-09-18  6:49 ` Emacs crashes when writting JavaScript Jorge Javier Araya Navarro
  2019-09-18 12:18   ` Eli Zaretskii
@ 2019-09-23  0:50   ` Jackson Ray Hamilton
  2019-09-23 13:29     ` Dmitry Gutov
                       ` (2 more replies)
  1 sibling, 3 replies; 6+ messages in thread
From: Jackson Ray Hamilton @ 2019-09-23  0:50 UTC (permalink / raw)
  To: jorgejavieran; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]

Hola Jorge,

Emacs’ JSX support is relatively new and could probably be optimized to 
perform better at scale.  I noticed similar slowdowns with files 
containing 300+ lines of JSX.

Before I contributed the JSX support code to Emacs, I used 
(elp-instrument-package "js-") and (elp-results) to identify choke 
points during editing.  I felt like I was able to slightly improve 
performance for large files, going from “unusable” to merely “frustrating.”

If you are familiar with Emacs Lisp and feel compelled to make things 
stabler and faster, perhaps you can find some time to benchmark and 
experiment in lisp/progmodes/js.el.  Otherwise, please open a bug report.

Some tips if you decide to help: you mentioned an AST, but there isn’t 
one.  Parsing starts in js-syntax-propertize.  Years ago, Sebastian 
Wiesner wrote some blog articles explaining how syntax highlighting 
worked in Emacs, but he’s since removed those posts from his blog and 
they aren’t available on Internet Archive. Maybe he will provide you 
with the articles if you ask him for:

  * 2014, Mar 11 Overview of Emacs Font Locking
  * 2014, Mar 12 Syntactic fontification in Emacs
  * 2014, Mar 26 Search-based fontification with keywords
  * 2014, Jun 16 Advanced syntactic fontification

Also, maybe you could separate your JSX code into smaller modules.  That 
will make it easier for tools like Emacs, prettifiers, and linters to 
process your code.  Even though the code can probably be optimized, 
since we care about accuracy parsing time will ultimately be gated by 
file length regardless. Smaller modules are also consistent with some 
programmers’ expectations for high quality code; they are more likely to 
be below length thresholds permitting easy comprehension.

Jackson


[-- Attachment #2: Type: text/html, Size: 2270 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs crashes when writting JavaScript
  2019-09-23  0:50   ` Jackson Ray Hamilton
@ 2019-09-23 13:29     ` Dmitry Gutov
  2019-09-23 18:12     ` [SPAM UNSURE] " Stephen Leake
  2019-09-23 18:30     ` Jorge Javier Araya Navarro
  2 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2019-09-23 13:29 UTC (permalink / raw)
  To: Jackson Ray Hamilton, jorgejavieran; +Cc: emacs-devel

On 23.09.2019 3:50, Jackson Ray Hamilton wrote:
> Some tips if you decide to help: you mentioned an AST, but there isn’t 
> one.  Parsing starts in js-syntax-propertize.  Years ago, Sebastian 
> Wiesner wrote some blog articles explaining how syntax highlighting 
> worked in Emacs, but he’s since removed those posts from his blog and 
> they aren’t available on Internet Archive. Maybe he will provide you 
> with the articles if you ask him for:

Even if he doesn't, though, that's no reason to give up.

For instance, this article seems to give a decent introduction: 
http://www.modernemacs.com/post/major-mode-part-1/

And there's also the manual, existing examples in the code, as well as 
this mailing list (as Emacs Help too) if you still have questions.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [SPAM UNSURE] Emacs crashes when writting JavaScript
  2019-09-23  0:50   ` Jackson Ray Hamilton
  2019-09-23 13:29     ` Dmitry Gutov
@ 2019-09-23 18:12     ` Stephen Leake
  2019-09-23 18:30     ` Jorge Javier Araya Navarro
  2 siblings, 0 replies; 6+ messages in thread
From: Stephen Leake @ 2019-09-23 18:12 UTC (permalink / raw)
  To: emacs-devel

Jackson Ray Hamilton <jackson@jacksonrayhamilton.com> writes:

> Emacs’ JSX support is relatively new and could probably be optimized
> to perform better at scale.  I noticed similar slowdowns with files
> containing 300+ lines of JSX.

ada-mode was also slow on large files (I have customers with 5k, 7k line
files!). The solution was to support partial parsing.

For example, when indenting, use regexp search to find a reasonable
start point (block start, function start), and assume it is indenting
properly. Then parse from there for one complete grammar production.

This requires modifying the grammar; lower level productions (for
statement, declaration) must be a complete grammmar parse (normally only
a complete file/package).

That doesn't work for some operations. For example, to jump to the
"context clause" in Ada ("with" statements at the start of the file;
like Java "import" statements), requires parsing the whole file.

On the whole, incremental parsing makes ada-mode useable on large files.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs crashes when writting JavaScript
  2019-09-23  0:50   ` Jackson Ray Hamilton
  2019-09-23 13:29     ` Dmitry Gutov
  2019-09-23 18:12     ` [SPAM UNSURE] " Stephen Leake
@ 2019-09-23 18:30     ` Jorge Javier Araya Navarro
  2 siblings, 0 replies; 6+ messages in thread
From: Jorge Javier Araya Navarro @ 2019-09-23 18:30 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2093 bytes --]



El domingo 22 de septiembre del 2019 a las 1850 horas, Jackson Ray Hamilton escribió:

> Hola Jorge,
>
> Emacs’ JSX support is relatively new and could probably be optimized
> to perform better at scale.  I noticed similar slowdowns with files
> containing 300+ lines of JSX.
>
> Before I contributed the JSX support code to Emacs, I used
> (elp-instrument-package "js-") and (elp-results) to identify choke
> points during editing.  I felt like I was able to slightly improve
> performance for large files, going from “unusable” to merely
> “frustrating.”
>
> If you are familiar with Emacs Lisp and feel compelled to make things
> stabler and faster, perhaps you can find some time to benchmark and
> experiment in lisp/progmodes/js.el.  Otherwise, please open a bug report.
>
> Some tips if you decide to help: you mentioned an AST, but there isn’t
> one.  Parsing starts in js-syntax-propertize.  Years ago, Sebastian
> Wiesner wrote some blog articles explaining how syntax highlighting
> worked in Emacs, but he’s since removed those posts from his blog and
> they aren’t available on Internet Archive. Maybe he will provide you
> with the articles if you ask him for:
>
>  * 2014, Mar 11 Overview of Emacs Font Locking
>  * 2014, Mar 12 Syntactic fontification in Emacs
>  * 2014, Mar 26 Search-based fontification with keywords
>  * 2014, Jun 16 Advanced syntactic fontification
>
> Also, maybe you could separate your JSX code into smaller modules.
> That will make it easier for tools like Emacs, prettifiers, and
> linters to process your code.  Even though the code can probably be
> optimized, since we care about accuracy parsing time will ultimately
> be gated by file length regardless. Smaller modules are also
> consistent with some programmers’ expectations for high quality code;
> they are more likely to be below length thresholds permitting easy
> comprehension.
>
> Jackson

Hey, Jackson!

Thanks for the pointers, I'm absolutely interested in making the JavaScript (and JSX) support in
Emacs better.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-23 18:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87v9tqcd57.fsf.ref@yahoo.com.mx>
2019-09-18  6:49 ` Emacs crashes when writting JavaScript Jorge Javier Araya Navarro
2019-09-18 12:18   ` Eli Zaretskii
2019-09-23  0:50   ` Jackson Ray Hamilton
2019-09-23 13:29     ` Dmitry Gutov
2019-09-23 18:12     ` [SPAM UNSURE] " Stephen Leake
2019-09-23 18:30     ` Jorge Javier Araya Navarro

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).