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

refactor: Add NewFluxAllocator as an injection point for the GcAllocator #4651

Merged
merged 5 commits into from
Apr 13, 2022

Conversation

Marwes
Copy link
Contributor

@Marwes Marwes commented Apr 7, 2022

This removes GcAllocator from all tests but still provides a way to inject it temporarily
for testing.

@jsternberg I think something like this is what you wanted?

@Marwes Marwes requested a review from jsternberg April 7, 2022 12:46
@Marwes Marwes requested a review from a team as a code owner April 7, 2022 12:46
This removes GcAllocator from all tests but still provides a way to inject it temporarily
for testing.
@Marwes
Copy link
Contributor Author

Marwes commented Apr 8, 2022

@jsternberg I think I addressed you comments now

lang/compiler.go Outdated Show resolved Hide resolved
memory/allocator.go Outdated Show resolved Hide resolved
memory/allocator.go Outdated Show resolved Hide resolved

func (a *GcAllocator) TotalAllocated() int64 {
return a.ResourceAllocator.TotalAllocated()
func (a *GcAllocator) Allocated() int64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

These functions should be removed I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are needed for testing that we actually free things.

@@ -248,19 +252,25 @@ func (a *ResourceAllocator) allocator() memory.Allocator {
}

type GcAllocator struct {
*ResourceAllocator
mem *ResourceAllocator
Copy link
Contributor

Choose a reason for hiding this comment

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

This should just be memory.Allocator. The location that's interested in MaxAllocated() and TotalAllocated() should keep their reference to their ResourceAllocator. GcAllocator doesn't need to know this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I need a direct reference to ResourceAllocator so I can call Allocated etc in tests to verify that we actually free the allocations.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can hold onto both the ResourceAllocator and the GcAllocator to do that. There's also the CheckedAllocator included in arrow for this purpose.

mem := &memory.ResourceAllocator{}
gc := memory.NewGcAllocator(mem)

Then you can check mem in the tests.

@Marwes Marwes merged commit b48a01b into master Apr 13, 2022
@Marwes Marwes deleted the set_finalizer branch April 21, 2022 11:43
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