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

free() pointer to arrow binary in Python #1273

Merged
merged 1 commit into from
Jan 6, 2021
Merged

Conversation

sc1f
Copy link
Contributor

@sc1f sc1f commented Jan 4, 2021

This PR fixes a small issue in Perspective's arrow loading code in Python - previously, the pointer to the malloc'd section for the arrow binary was never explicitly free'd (as it was in Javascript). This leads to the memory allocated for the binary leaking after the arrow is loaded into Perspective.

With testing using psutil and 25 updates using superstore.arrow, comparing memory usage with/without free() shows a significant impact:

Without free():

  • starting rss: 115539968 bytes
  • ending rss: 302710784 bytes

With free():

  • starting rss: 113532928 bytes
  • ending rss: 245538816 bytes

Memory usage grows much more slowly when free() is added, demonstrating the leak.

@sc1f sc1f added C++ internal Internal refactoring and code quality improvement Python labels Jan 4, 2021
@@ -193,6 +194,10 @@ std::shared_ptr<Table> make_table_py(t_val table, t_data_accessor accessor,
_fill_data(data_table, accessor, input_schema, index, offset, limit, is_update);
}

if (is_arrow) {
Copy link
Member

Choose a reason for hiding this comment

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

is there any case where is_arrow && is_delete?

Copy link
Member

Choose a reason for hiding this comment

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

e.g. should this match above if (is_arrow && !is_delete) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There shouldn't be any - remove only takes a list of pkeys, but this whole conditional block is kind of messy. I'll take a look and fix.

Copy link
Member

Choose a reason for hiding this comment

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

This logic is incorrect, but so is the fix suggestion - there should be (or will need to be) one case, for remove() ... when we get around to fixing this API method generally ...

Copy link
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for the PR!

@texodus texodus merged commit 63f6855 into master Jan 6, 2021
@texodus texodus deleted the fix-arrow-memory branch January 6, 2021 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ internal Internal refactoring and code quality improvement Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants