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

[Performance] Reduce size of term #2022

Closed
wants to merge 6 commits into from
Closed

Conversation

yannham
Copy link
Member

@yannham yannham commented Aug 5, 2024

A sizeof shows that the main Term enum has a whopping size of 464 bytes. This is quite fat and might pressure the allocator, Drop implementation and various hardware caches. This PR boxes a bunch of large structures to reduce the size of the overall enum.

@github-actions github-actions bot temporarily deployed to pull request August 5, 2024 15:23 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 5, 2024 16:51 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 6, 2024 10:43 Inactive
@yannham
Copy link
Member Author

yannham commented Aug 6, 2024

Although the code is a bit noisier (need to box and unbox quite a bit more), the preliminary results are encouraging. After a first trimming round from 464 to 74 bytes, I see a consistent gain of around 15% on the smaller real life benchmark, and up to 25-30% on the larger one (in running time). The allocated memory also goes down significantly (because it's more expansive to measure, I only ran bytehound on the smaller example, but I get more than 60% reduction in allocated memory).

I'm going to try to reduce it further down to approximately 48 bytes (which are 24x2, where 24 is the term + position information repr) and measure the difference. Then I'll check and see if there are other pervasive enums to optimize.

@yannham
Copy link
Member Author

yannham commented Aug 6, 2024

I'm not sure of the optimum, but reducing it further to 56 bytes wasn't beneficial,and is actually less performant than 72. It also costed a lot more in term of code uglyness, so I'm tempted to keep it at 72 bytes for now, and look for other enums to optimize.

@github-actions github-actions bot temporarily deployed to pull request August 6, 2024 16:53 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 8, 2024 19:02 Inactive
@yannham
Copy link
Member Author

yannham commented Oct 2, 2024

This was an interesting experience, but this effort is superseded by #2045.

@yannham yannham closed this Oct 2, 2024
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.

1 participant