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

Optimizing role computation and selector matching #1049

Open
takenspc opened this issue Jun 1, 2023 · 2 comments
Open

Optimizing role computation and selector matching #1049

takenspc opened this issue Jun 1, 2023 · 2 comments

Comments

@takenspc
Copy link
Contributor

takenspc commented Jun 1, 2023

There are some cases where markuplint is slow, especially when a file contains hundreds of nodes. It takes a few seconds to lint a single HTML file on my machine.

Although the bottlenecks can vary depending on the DOM structure, enabled rules, and configuration, I have identified two functionalities that can be sped up with little effort:

Role computation

Role computation is a compute-intensive process, and the same inputs always produce the same output (role). Caching the results can boost the performance of a few linting rules, including require-accessible-name.

Selector matching

A simple selector will never match if one or more parts of the selector don't match.

For example, input[type=button] will never match button[type=button] because input doesn't match button. Hence, we can skip the [type=button] matching.


Since these optimizations should not change the results, I'm not planning to add new tests and would like to check if the existing tests have passed. If this is acceptable, I can open the pull requests.

@YusukeHirao
Copy link
Member

@takenspc

Thank you for your proposal. The current cache strategy needs to be more mature.
I want to accept your idea. Please improve it.

@yonta
Copy link

yonta commented Feb 11, 2024

I am facing the same issue.
In my case, it is with about 1500 option elements in a datalist element that I am auto-generating.
Markuplint takes more than 20 seconds to check this.
For now, we are avoiding the issue by adding it to the ignore file.

The file I am encountering the issue with is located here.

I have investigated how the execution time scales with the number of option elements as additional information.
It appears that the execution time is not at least O(N) in relation to the number of elements.

image

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

No branches or pull requests

3 participants