redhat-developer / redhat-developer/vscode-xml
High CPU usage in some regular expressions during validation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 328
- Forks
- 101
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 7
Description
VSCode Version: 1.86.2
Extension: v0.26.1
Windows 10 22H2
Scheme in RelaxNG compact format.
Example of a valid string:
some.text-some-text-{{someText}}-text-{{some_text}}-some-text
When using this regex, the CPU load is about 50%, the waiting time is more than a minute, and no results are obtained:
Identifier = ( xsd:string { pattern="(([A-Za-z][\-.A-Za-z]*)*\{\{[_A-Za-z]+\}\}[\-A-Za-z]*)+" } )
It looks like the problem is in [\-.A-Za-z]*, when simplifying the expression the validation starts to work faster. I did some tests, here are the results:
Identifier = ( xsd:string { pattern="(([a-z][\-a-z]*)*\{\{[_a-z]+\}\}[\-a-z]*)+" } )
# elapsed time: ~1 sec
Identifier = ( xsd:string { pattern="(([_a-z][\-.a-z]*)*\{\{[_a-z]+\}\}[\-_a-z]*)+" } )
# elapsed time: ~7 sec
Identifier = ( xsd:string { pattern="(([A-Za-z][\-A-Za-z]*)*\{\{[_a-z]+\}\}[\-a-z]*)+" } )
# or
Identifier = ( xsd:string { pattern="(([A-Za-z][\-A-Za-z]*)*\{\{[_A-Za-z]+\}\}[\-A-Za-z]*)+" } )
# elapsed time: ~12 sec
Identifier = ( xsd:string { pattern="(([A-Za-z][\-.A-Za-z]*)*\{\{[_A-Za-z]+\}\}[\-A-Za-z]*)+" } )
# elapsed time: over 1 min without result
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied RelaxNG compact pattern in VSCode 1.86.2 with extension v0.26.1 on Windows 10. Compare the reported patterns and timings; done when the valid example is validated without excessive CPU use or a prolonged wait.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100