insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

perf: improve performance when spec lint [INS-3724]

Open CurryYangxx opened this issue 1 year ago • 1 comments

use web worker

CurryYangxx avatar May 06 '24 10:05 CurryYangxx

@CurryYangxx very elegant approach. With node access in webworkers we have opened up some interesting performance options.

jackkav avatar May 07 '24 08:05 jackkav

Should we spawn a new worker on every lint command or use a shared worker?

Now it will create just one worker when component first time render.And use a unique id to distinguish worker message.

Does this function handle race conditions?

Use the unique id for every message, only the result which id match the latested id will be updated.

Don't reload the spectral ruleset on every lint command

use a cache object in worker, only reload when ruleset path change

CurryYangxx avatar May 08 '24 09:05 CurryYangxx

We still need to save spectralRun IPC because it is used in this action:https://github.com/Kong/insomnia/blob/cc421d1a3c041cebc059f5d421c4406c8fe75baf/packages/insomnia/src/ui/routes/actions.tsx#L736

CurryYangxx avatar May 08 '24 09:05 CurryYangxx

Discussed offline and resolved several concerns, just added some minor comments. Overall it looks good to me but let's wait a bit as there might be some comments from other reviewers.

@ihexxa Good catch, update more logs and necessary termination

CurryYangxx avatar May 13 '24 07:05 CurryYangxx