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

parser: allocate vector with exact capacity #894

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

lucab
Copy link
Contributor

@lucab lucab commented Jan 28, 2024

This tweaks parse_content() logic in order to reduce the amount of vector growing, as the final vector capacity is already known beforehand.

@lucab
Copy link
Contributor Author

lucab commented Jan 28, 2024

For reference, parse_content() is indirectly recursive (through parse_block()) so the compounded effect of this is noticeable in memory patterns of consuming applications.

As an example, on a zola build run on the test_site this spot accounts for ~2% of all temporary allocations (where zola_patched is a local build of the next branch):
tera

@lucab
Copy link
Contributor Author

lucab commented Jan 29, 2024

MSRV bump to fix CI is at #895.

This tweaks `parse_content()` logic in order to reduce the amount
of vector growing, as the final vector capacity is already known
beforehand.
@lucab
Copy link
Contributor Author

lucab commented Feb 6, 2024

This has been rebased to latest master and CI is green, PR is now ready to be merged.

@Keats Keats merged commit cafe175 into Keats:master Feb 12, 2024
6 checks passed
@Keats
Copy link
Owner

Keats commented Feb 12, 2024

Thanks!

@lucab lucab deleted the ups/parser-vec-capacity branch February 19, 2024 08:48
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