GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-112532: Improve mimalloc page visiting by colesbury · Pull Request #114133 · python/cpython

Conversation

@colesbury

@colesbury colesbury commented Jan 16, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This adds support for visiting abandoned pages in mimalloc and improves the performance of the page visiting code. Abandoned pages contain memory blocks from threads that have exited. At some point, they may be later reclaimed by other threads. We still need to visit those pages in the free-threaded GC because they contain live objects.

This also reduces the overhead of visiting mimalloc pages:

  • Special cases for full, empty, and pages containing only a single block.
  • Fix free_map to use one bit instead of one byte per block.
  • Use fast integer division by a constant algorithm when computing block offset from block size and index.
  • Faster looping over bitmap.
  • Fix bug where blocks in the delayed-free list were erroneously visited as if they were live.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sam Gross
pythongh-112532: Improve mimalloc page visiting
9c526f8
This adds support for visiting abandoned pages in mimalloc and improves
the performance of the page visiting code. Abandoned pages contain
memory blocks from threads that have exited. At some point, they may be
later reclaimed by other threads. We still need to visit those pages in
the free-threaded GC because they contain live objects.

This also reduces the overhead of visiting mimalloc pages:

 * Special cases for full, empty, and pages containing only a single
   block.
 * Fix free_map to use one bit instead of one byte per block.
 * Use fast integer division by a constant algorithm when computing
   block offset from block size and index.
@colesbury
colesbury requested a review from DinoV January 16, 2024 16:35
@bedevere-app bedevere-app Bot added the awaiting review label Jan 16, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Jan 16, 2024
mimalloc: additional integration and changes for --disable-gil builds #112532
Closed
@colesbury colesbury added skip news topic-free-threading labels Jan 16, 2024
@colesbury colesbury mentioned this pull request Jan 16, 2024
Mimalloc differences from upstream #113141
Open
DinoV
DinoV reviewed Jan 17, 2024
View reviewed changes

ghost left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just curious about the unused function(s), otherwise LGTM!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Objects/mimalloc/segment.c
}

// Visit all blocks in a abandoned segments
bool _mi_abandoned_pool_visit_blocks(mi_abandoned_pool_t* pool, uint8_t page_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) {

ghost Jan 17, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This (and therefore the previous 2 functions) doesn't seem to be used anywhere?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

ghost Jan 17, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

These will be used in the upcoming GC PR. Here is an example usage:

https://github.com/colesbury/cpython/blob/8314c7c1d9d9670d4a83b9dc12f23611493c8eaa/Python/gc_free_threading.c#L226-L227

I put them in this PR because:

  1. Keeping the mimalloc changes separate makes them a bit easier to track and upstream
  2. The GC PR will be big and doing this first makes the upcoming PR a bit smaller

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@colesbury

ghost commented Jan 22, 2024

Copy link
Copy Markdown
Contributor Author

@DinoV, would you please merge this when you are ready?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DinoV
DinoV merged commit 412920a into python:main Jan 22, 2024
@bedevere-app bedevere-app Bot removed the awaiting review label Jan 22, 2024
@colesbury
colesbury deleted the 112532-visitor branch January 22, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@DinoV DinoV DinoV left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news topic-free-threading

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@colesbury @DinoV
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.