Skip to content

GH-55362: [C++] Fix jemalloc ReleaseUnused implementation - #55363

Merged
kou merged 2 commits into
apache:mainfrom
adamreeve:jemalloc-release-unused
Nov 3, 2026
Merged

kou merged 2 commits into
apache:mainfrom
adamreeve:jemalloc-release-unused

Conversation

@adamreeve

@adamreeve adamreeve commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

Makes ReleaseUnused no longer an unintentional no-op with Jemalloc.

What changes are included in this PR?

Correctly builds the mallctl argument when calling JemallocAllocator::ReleaseUnused, and adds a debug-check of the error code.

Are these changes tested?

Yes. I tested that without the fix, the DCHECK_EQ raised an error for Jemalloc/TestMemoryPool/0.ReleaseUnused:

Check failed: (err) == (0) Failed to purge jemalloc arenas: No such file or directory

With the fix, the tests pass.

I also ran an extra test that dirty pages were now released successfully and reduced to 0, when before they weren't. But I'm not sure this is worth committing as it could be affected by changes to jemalloc internals.

Are there any user-facing changes?

No.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@adamreeve
adamreeve marked this pull request as ready for review November 2, 2026 01:19
Copilot AI balanced review requested due to automatic review settings November 2, 2026 01:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the jemalloc purge-request change.

No open issues 🎉

What changed in this PR

Fixes GH-55362 by making the jemalloc-backed memory pool’s ReleaseUnused() issue a valid purge request instead of silently doing nothing.

Changes:

  • Builds the mallctl name using the numeric value of MALLCTL_ARENAS_ALL.
  • Adds a debug assertion with an error message if purging fails.
File Description
cpp/​src/​arrow/​memory_pool_jemalloc.cc Corrects the jemalloc purge request and adds debug error checking and required headers.

Review effort: Balanced

@adamreeve
adamreeve requested a review from kou November 2, 2026 20:53

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

BTW, are you using jemalloc? If so, we may want to update bundled jemalloc.

@kou kou changed the title GH-55362: [C++] Fix Jemalloc ReleaseUnused implementation GH-55362: [C++] Fix jemalloc ReleaseUnused implementation Nov 3, 2026
@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Nov 3, 2026
@kou
kou merged commit de3bdd9 into apache:main Nov 3, 2026
64 of 66 checks passed
@kou kou removed the awaiting merge Awaiting merge label Nov 3, 2026
@adamreeve

Copy link
Copy Markdown
Contributor Author

BTW, are you using jemalloc? If so, we may want to update bundled jemalloc.

No I'm not, I discovered this when testing ReleaseUnused in ParquetSharp, which builds with jemalloc enabled but uses mimalloc by default.

@adamreeve
adamreeve deleted the jemalloc-release-unused branch November 3, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants