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

Unionize actor heap large and small chunks #4568

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dipinhora
Copy link
Contributor

So they can better fight for their rights..

Prior to this commit, small_chunk_t and large_chunk_t were distinct types. This was great for correctness but prevented a useful optimization.

This commit changes things so that small_chunk_t and large_chunk_t have been combined into chunk_t which has a union in it for the small/large chunk specific fields. There are now a lot of assertions added in the relevant functions that deal with small and large chunks to ensure that the received chunk is of the right type because the compiler can no longer help enforce correctness.

This allows for small and large chunk recycling to take advantage of the fact that the block backing a small chunk is the same size as the block backing the smallest large chunk size allowed so they both now use the same recycled chunk list.

The large chunk recycling has also been enhanced to take advantage of the long tail distribution of allocation sizes and there are now multiple size specific chunk lists for large chunk recycling with one extra large chunk list for recycling that has all chunks bigger than the largest size specific list that is kept sorted and searched/used as the old large chunk recycling list was.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Dec 6, 2024
@jemc
Copy link
Member

jemc commented Dec 10, 2024

Looks like the CI failure is unrelated. It seems we need to update some GitHub Actions versions in our CI workflows.

@SeanTAllen
Copy link
Member

@dipinhora please rebase this against main when you have a chance.

So they can better fight for their rights..

Prior to this commit, small_chunk_t and large_chunk_t were distinct
types. This was great for correctness but prevented a useful
optimization.

This commit changes things so that small_chunk_t and large_chunk_t
have been combined into chunk_t which has a union in it for the
small/large chunk specific fields. There are now a lot of assertions
added in the relevant functions that deal with small and large
chunks to ensure that the received chunk is of the right type
because the compiler can no longer help enforce correctness.

This allows for small and large chunk recycling to take advantage
of the fact that the block backing a small chunk is the same size
as the block backing the smallest large chunk size allowed so they
both now use the same recycled chunk list.

The large chunk recycling has also been enhanced to take advantage
of the long tail distribution of allocation sizes and there are now
multiple size specific chunk lists for large chunk recycling with
one extra large chunk list for recycling that has all chunks
bigger than the largest size specific list that is kept sorted
and searched/used as the old large chunk recycling list was.
@dipinhora
Copy link
Contributor Author

rebased

@SeanTAllen SeanTAllen requested a review from a team December 17, 2024 19:45
@jemc
Copy link
Member

jemc commented Dec 17, 2024

Sorry that nobody has carved out the time to give this a meaningful review yet. Sean and I both feel this requires attention. Sorry for the delay.

@dipinhora
Copy link
Contributor Author

Sorry that nobody has carved out the time to give this a meaningful review yet. Sean and I both feel this requires attention. Sorry for the delay.

no worries.. and no need to apologize.. folks should be holidaying at this time of the year after all..

@SeanTAllen
Copy link
Member

@dipinhora what would you imagine the impact of this change would be on "the average" pony program?

@dipinhora
Copy link
Contributor Author

@dipinhora what would you imagine the impact of this change would be on "the average" pony program?

same as #4531 but more efficient as this enhances the previous work to better exploit the fact that the memory chunk backing a small chunk is the same size as that backing the smallest allowed large chunk along with allowing for some per-size recyclable large chunk lists trading some more memory to computation savings (if desired)..

@SeanTAllen
Copy link
Member

I have some worries about the "compiler used to help us, now asserts". This feels easier to break. But I am mostly ignorant about this code. It's been a long time since I worked closely with it.

Do you have suggestions for tests we can do in CI to add an additional level of assurance that nothing gets broken in the future?

@dipinhora
Copy link
Contributor Author

I have some worries about the "compiler used to help us, now asserts". This feels easier to break. But I am mostly ignorant about this code. It's been a long time since I worked closely with it.

note: this more closely matches how this code used to be before small_chunk_t/large_chunk_t were split for memory efficiency purposes a while back.. back then, the compiler also wasn't able to help enforce correctness but there also didn't used to be any type punning with unions involved like here either..

Do you have suggestions for tests we can do in CI to add an additional level of assurance that nothing gets broken in the future?

i'm not sure what you're looking for here.. pony already has a comprehensive test suite of pony programs (full-program-tests and stdlib) that are run in CI that all would likely fail if this code was broken in some way..

@SeanTAllen
Copy link
Member

@dipinhora I was thinking something that could point to "someone f'd up memory". I doubt there is anything but I wanted to see if asking shook something free as a thought.

@dipinhora
Copy link
Contributor Author

@dipinhora I was thinking something that could point to "someone f'd up memory". I doubt there is anything but I wanted to see if asking shook something free as a thought.

that's what the assertions are for... 8*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss during sync Should be discussed during an upcoming sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants