Skip to content

Conversation

@dajinchu
Copy link
Collaborator

@dajinchu dajinchu commented Feb 11, 2026

optimize extractDomElements to not construct a dom. instead we simply run the parser to find the open/close tags for head and body, and slice the html string using the indices.

this avoids allocating dom objects when reading and avoids the work of writing those dom objects back into strings afterwards

Testing

On AlignableWeb, used bombardier to make 100 request against /sitemap route.

Took memory and cpu profiles before and after, isolating extractDomElements function.

metric before after
cpu 300ms 170ms
memory 6 MB 1.8 MB

Copy link
Contributor

@reinabo reinabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to unit test something like this, but we would require adding support for unit tests.

@dajinchu
Copy link
Collaborator Author

@reinabo added unite tests

@dajinchu dajinchu merged commit 916c5bf into master Feb 11, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants