codemod icon indicating copy to clipboard operation
codemod copied to clipboard

[studio] before/after editor performance is severely degraded with many lines of code

Open with-heart opened this issue 1 year ago • 4 comments

Issue Description

Select one of: [ ] Generated codemod is not correct [ ] Bug in Codemod Studio [x] UI/UX improvement request [ ] Feature request

In a Before/After editor with thousands of lines of code, I'm experiencing ~1s of lag for each character input and when blurring the editor.

Steps to Reproduce

In the before/after editor

  1. Add thousands of lines of code
  2. Attempt to type input and notice lag
  3. Blur the editor by switching to another panel and notice lag

Actual Results

Lag!

Expected Results

No lag!

Technical details

Export-1724284382458

Browser: Arc 1.56.0 (52658) in incognito mode Device: MacBook Pro M1 Max, Sonoma 14.6.1

with-heart avatar Aug 22 '24 00:08 with-heart

great catch. this happens when that code is parsable. if its not parsable there is no lag... so i guess its something related to that.... maybe on each keystroke we parse the whole tree? will look into it later and consider it as low pri for now.

curious, how did you come across this? like why do you put so much code in before/after? did you come here via codemod learn command?

alexbit-codemod avatar Aug 22 '24 00:08 alexbit-codemod

even for rust-based parsers and ast-grep playground this problem appears.

alexbit-codemod avatar Aug 22 '24 00:08 alexbit-codemod

curious, how did you come across this? like why do you put so much code in before/after? did you come here via codemod learn command?

Yeap, codemod learn on an xstate test file.

There are a few different variations of a change I'm wanting to make to the tests so I converted that whole file by hand and then ran it.

It kinda sucks that so much of the file was included in the editor just because I changed a single import. The second change wasn't until somewhere around line 1800 I think but all of the text in between them was included.

with-heart avatar Aug 22 '24 01:08 with-heart

yeah. i wonder how we can improve codemod learn so it only extract relevant stuff to build the codemod or populate that in codemod studio.... i run this by the team to see if we can come up with some ideas. but if you have some, please share that with us.

alexbit-codemod avatar Aug 22 '24 02:08 alexbit-codemod