Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage in some regular expressions during validation #971

Open
reprintsev opened this issue Feb 28, 2024 · 1 comment
Open

High CPU usage in some regular expressions during validation #971

reprintsev opened this issue Feb 28, 2024 · 1 comment

Comments

@reprintsev
Copy link

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
@angelozerr
Copy link
Contributor

We use Jing to validate rnc

I suggest that tou report this problem to jing repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants