Skip to content

Flush cache lines in TCMalloc immediately before freeing memory to OS. - #1013

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_981994488
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_981994488

Conversation

@copybara-service

Copy link
Copy Markdown

Flush cache lines in TCMalloc immediately before freeing memory to OS.

When releasing memory to the OS in SystemAllocator::ReleasePages, flush all cache lines covering the page range using clflushopt (x86) or dc civac (arm) followed by a memory barrier (sfence / dsb ish).

This evicts and writes back dirty cache lines before madvising pages away, preventing memory released back to the OS from using cache capacity/causing other still used cache lines to be evicted later.

We use an 8K limit to avoid iterating over unbounded memory during deallocation.

When releasing memory to the OS in SystemAllocator::ReleasePages, flush all cache lines covering the page range using `clflushopt` (x86) or `dc civac` (arm) followed by a memory barrier (`sfence` / `dsb ish`).

This evicts and writes back dirty cache lines before madvising pages away, preventing memory released back to the OS from using cache capacity/causing other still used cache lines to be evicted later.

We use an 8K limit to avoid iterating over unbounded memory during deallocation.

PiperOrigin-RevId: 981994488
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.

1 participant