Directly maxed the CPU 100%
SilvaQ opened this issue · comments
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
3.0.1
Link to runnable example
No response
Steps to reproduce
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkMath from "remark-math";
import remarkStringify from "remark-stringify";
import { visit } from "unist-util-visit";
import remarkGfm from "remark-gfm";
export const remarkKhan = unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkStringify)
.freeze();
useage:
remarkKhan()
.processSync(text)
.toString();
my text:
| Column A | Column B | Column C |
| -------- | -------- | -------- |
| A1 | B1 | C1 |
| A2 | B2 | C2 |
| A3 | B3 | C3 |
| torbet ismi | torbet adrehsi | torbet tili | khasliqi |
| ------------------------: | :-------------------------------------------------------: | --------------------------------: | ------------: |
| ulinish tori | http://www.ulinix.com | uyghurche | |
| elkvyi tori | https://www.alkuyi.com | uyghurche | taratqu |
| toghraq tori | https://www.tograk.tech | uyghurche | |
| losfehr tori | https://losfer.cn | uyghurche | |
| /Eliyar's Blog/ | https://eliyar.biz | khenzuche | shekhsiy blog |
| /PDF to Docx/ | https://pdf2docx.com | inhgilizche | wheqsiz qural |
| **新闻在线 | http://www.xjtvs.com.cn | khenzuche | |
| kheliq tori | http://uyghur.people.com.cn | uyghurche | taratqu |
| shinjang gehziti | http://uyghur.xjdaily.com | uyghurche | taratqu |
| ashpez tori | https://axpaz.cn | uyghurche | |
| otqash ep baziri | https://www.otkax.com | uyghurche | |
| uchur tori | https://www.uqur.cn | uyghurche | |
| aqsu uchur tori | http://www.0997.cn | uyghurche | |
| nur tori | https://www.nur.cn | uyghurche | |
| izde tori | http://izda.com | uyghurche | izdesh |
| bilogir tehkhnika munbiri | https://www.shiftt.cn | uyghurche | |
| okyan tehkhnika blogi | https://okyan.360zg.net | uyghurche | |
| izdel tehkhnika munbiri | https://www.izdal.cn/ | uyghurche | |
| izwhar blogi | http://izhar.cn<br>https://bg.izhar.cn | uyghurche & khenzuche qosh tilliq | |
| bilqut tehkhnika munbiri | https://www.bilkut.cn | uyghurche | |
| bilimnur saghlamliqi | https://www.bilimnur.com | uyghurche | |
| nurum tori | http://nur512.cn | uyghurche | |
| /LearnFans/ | https://www.learnfans.com | uyghurche | |
| alwun kechmishliri | http://alwun.cn | uyghurche | |
| julaliq blogi | http://www.julaliq.com | uyghurche | |
| /uyghurix/<br>/ugubuntu/ | https://uyghurix.net<br>https://www.uyghurix.net/ugubuntu | uyghurche | |
| bilimler tori | https://www.bilimlar.com | uyghurche | |
| uyghursoft tori | http://uighursoft.com | qosh tilliq | |
| ashpez tori | https://axpaz.cn | uyghurche | |
| khiyal tori | http://www.hiyal.com | uyghurche | |
| bigim tori | https://begem.cn | khenzuche | |
| uzdil tori | https://uzdilim.github.io | uyghurche | |
| nurum tori | http://nur512.cn | uyghurche | |
Expected behavior
normal parse and speed up
Actual behavior
Directly maxed the CPU 100%
Runtime
Node v12
Package manager
yarn v2
OS
macOS
Build and bundle tools
Vite
Only version 1.0 had no performance problems. All the other versions had performance problems and were so severely stutted that the browser crashed
@SilvaQ trying the example code you provided, I'm not seeing the issue you describe https://codesandbox.io/s/remark-gfm-issue-30-eefn6
I do however notice that you import, but don't use import { visit } from "unist-util-visit";
, and that using that with typescript 4.5 with unist-util-visit
has been causing 100% cpu on your system microsoft/TypeScript#46900 (comment) .
I strongly suspect, you are using vite with TypeScript 4.5
Hi! Thanks for taking the time to contribute! This has been marked by a maintainer as needing a reproduction: It’s not yet clear whether this is a problem. Here are a couple tips:
- Thoroughly document how to reproduce the problem, in steps or with code
- Don’t link to your complete project: make the repro as tiny as possible, preferrably with only the problematic project in question
- Make sure you’re on the latest versions of projects (and node/npm/yarn!)
- The best issue report is a failing test proving it
Thanks,
— bb
@SilvaQ trying the example code you provided, I'm not seeing the issue you describe https://codesandbox.io/s/remark-gfm-issue-30-eefn6 I do however notice that you import, but don't use
import { visit } from "unist-util-visit";
, and that using that with typescript 4.5 withunist-util-visit
has been causing 100% cpu on your system microsoft/TypeScript#46900 (comment) . I strongly suspect, you are using vite with TypeScript 4.5
Thank you very much for sparing your time. I know the problem of unist-util-vist, and I also left a temporary solution under that issue.
I now have the same CPU burst problem when I open the demo you prepared.
I encountered this problem with a markdown conversion plug-in I developed for vscode. When I executed the conversion command, the whole vscode froze and couldn't even get back to normal unless it was rebooted, which I later found out was due to remark-gfm.
And I ran the processSync in that project, so the payment request was more serious.
I tried to change it to asynchronous, but the current performance is still too expensive for me
I found another reason why I had such a serious problem
There is a huge difference in the cost of running the two types of code:
I accidentally used a bad pattern when I mimicked remark encapsulation.
the bad one :
processor =unified()
.use(remarkParse)
.use(remarkMath)
.use(remarkGfm)
.use(remarkStringify)
.freeze();
the good one :
const processor = unified().use(remarkParse).use(remarkStringify).freeze(); // it is remark doing
export const remarkKhan = processor().use(remarkMath).use(remarkGfm);
Therefore, this problem is still caused by my lack of knowledge on the whole. I apologize to you for this and thank you for making such a great project
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.
Hi team! I don’t know what’s up as there’s no phase label. Please add one so I know where it’s at.
Thanks,
— bb
Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed.
See our support docs for how and where to ask questions.
Thanks,
— bb