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

perf(hogql): Fix C++ parser leaks #18022

Merged
merged 8 commits into from
Oct 17, 2023
Merged

perf(hogql): Fix C++ parser leaks #18022

merged 8 commits into from
Oct 17, 2023

Conversation

Twixes
Copy link
Member

@Twixes Twixes commented Oct 16, 2023

Problem

There were some memory leaks left in #17659.

Here's how the Python parser behaves:

Python

And here's how the C++ one used to:

C++ pre

Changes

There were two classes of memory leaks I identified:

  1. PyObject*s that weren't decremented. I knew about when merging perf: Parse HogQL with C++ for a huge speedup #17659, just left that for later.
  2. ANTLR C++ objects that weren't deleted. I thought the parser class destructor handled this, but it didn't.

Parsing looks like this now:

C++ post

How did you test this code?

Added MemoryLeakTestMixin that does what it says on the tin. Half of the TestParser tests fail with that mixin on master, all pass with the fixes here.

@Twixes Twixes requested a review from mariusandra October 16, 2023 22:19
@Twixes Twixes force-pushed the turbo-parser-memory branch from a1c8bb5 to 89bb73b Compare October 16, 2023 22:40
@Twixes Twixes temporarily deployed to pypi-hogql-parser October 16, 2023 23:03 — with GitHub Actions Inactive
@Twixes Twixes force-pushed the turbo-parser-memory branch from 29bf5ca to 23c4dc7 Compare October 16, 2023 23:24
Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

This is lovely!

@mariusandra mariusandra merged commit 711f2b4 into master Oct 17, 2023
70 checks passed
@mariusandra mariusandra deleted the turbo-parser-memory branch October 17, 2023 13:27
daibhin pushed a commit that referenced this pull request Oct 23, 2023
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