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-94382: port multiprocessing static types to heap types by kumaraditya303 · Pull Request #94336 · python/cpython

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Jun 27, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • Issue: _multiprocessing leaks references when initialised multiple times #94382

Sorry, something went wrong.

Uh oh!

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

All reactions
kumaraditya303 added 2 commits June 27, 2022 15:13
@kumaraditya303
port multiprocssing types to heap types
ff5673f
@kumaraditya303
fix allocation
100ad99
@bedevere-bot bedevere-bot added the awaiting review label Jun 27, 2022
@kumaraditya303 kumaraditya303 added the skip news label Jun 27, 2022
@kumaraditya303 kumaraditya303 self-assigned this Jun 27, 2022
@kumaraditya303 kumaraditya303 changed the title GH-84258: port multiprocssing types to heap types GH-84258: port multiprocessing types to heap types Jun 27, 2022
@kumaraditya303 kumaraditya303 added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 27, 2022
@bedevere-bot

bedevere-bot commented Jun 27, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit 100ad99 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 27, 2022
@kumaraditya303

kumaraditya303 commented Jun 27, 2022

Copy link
Copy Markdown
Contributor Author

Refleaks bots are failing because of #94330

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
kumaraditya303 requested a review from erlend-aasland June 27, 2022 17:10
@erlend-aasland erlend-aasland added the DO-NOT-MERGE label Jun 27, 2022
@erlend-aasland

erlend-aasland commented Jun 27, 2022

Copy link
Copy Markdown
Contributor

@kumaraditya303, thanks for the PR. One of the most important aims of PEP-687 is to communicate the changes before they happen. See Part 1: Preparation. I'd prefer if you please re-read the PEP and follow its guidelines as specified. You'll notice that opening a PR comes in the second half of the process.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303

kumaraditya303 commented Jun 28, 2022

Copy link
Copy Markdown
Contributor Author

One of the most important aims of PEP-687 is to communicate the changes before they happen. See Part 1: Preparation. I'd prefer if you please re-read the PEP and follow its guidelines as specified. You'll notice that opening a PR comes in the second half of the process.

I'll create an issue to discuss it but I don't expect much as the module has no global state and the implemented types are not performance critical. I had worked on this months ago just was waiting for PEP to get accepted :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

[...] as the module has no global state and the implemented types are not performance critical [...]

If the types do not access global module state they should remain static; this is explicitly noted in the PEP.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

I'll create an issue to discuss it but I don't expect much [...]

Well, the important thing is that it gets done. Lack of communication is the single one issue that has contributed to heating the discussions regarding these changes. Even if we expect few people to participate in such a topic, it is of importance to raise awareness (and then wait at least for a week or two before continuing).

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303 kumaraditya303 mentioned this pull request Jun 28, 2022
_multiprocessing leaks references when initialised multiple times #94382
Closed
@kumaraditya303 kumaraditya303 changed the title GH-84258: port multiprocessing types to heap types GH-94382: port multiprocessing types to heap types Jun 28, 2022
@kumaraditya303

kumaraditya303 commented Jun 28, 2022

Copy link
Copy Markdown
Contributor Author

@erlend-aasland: Let's continue the discussion on the issue #94382

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

encukou
encukou reviewed Jun 28, 2022
View reviewed changes
Comment thread Modules/_multiprocessing/multiprocessing.c Resolved

Uh oh!

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

@kumaraditya303
remove mod state
08c501d
@kumaraditya303

kumaraditya303 commented Jun 28, 2022

Copy link
Copy Markdown
Contributor Author

Removing do-not-merge as no alternative PR has been proposed so far.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303 kumaraditya303 removed the DO-NOT-MERGE label Jun 28, 2022
@kumaraditya303
decref
31d44d9
@kumaraditya303
kumaraditya303 requested a review from encukou June 28, 2022 16:08
erlend-aasland
erlend-aasland requested changes Jun 28, 2022
View reviewed changes
Comment thread Modules/_multiprocessing/multiprocessing.c Resolved

Uh oh!

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

Comment thread Modules/_multiprocessing/multiprocessing.c Resolved

Uh oh!

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

@bedevere-bot bedevere-bot added awaiting changes and removed awaiting review labels Jun 28, 2022
@bedevere-bot

bedevere-bot commented Jun 28, 2022

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303 @erlend-aasland
Apply suggestions from code review
4e71aac
Co-authored-by: Erlend Egeberg Aasland <[email protected]>
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting changes labels Jun 28, 2022
@erlend-aasland

erlend-aasland commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

Removing do-not-merge as no alternative PR has been proposed so far.

Well, only three hours passed. That's a little narrow time-frame, don't you agree? :)

All reactions

Sorry, something went wrong.

Uh oh!

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

erlend-aasland
erlend-aasland reviewed Jun 28, 2022
View reviewed changes
Comment thread Modules/_multiprocessing/semaphore.c Resolved

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

As of Petr's last comment, please re-label this with do-not-merge until there is an agreement.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303 kumaraditya303 added the DO-NOT-MERGE label Jun 29, 2022
vstinner
vstinner reviewed Jul 3, 2022
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

Please add a NEWS entry explaining that the purpose of this PR is to fix memory leaks when the _multiprocessing extension module is loaded/unloaded multiple times: #94382 (comment)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Modules/_multiprocessing/semaphore.c Resolved

Uh oh!

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

Comment thread Modules/_multiprocessing/multiprocessing.c Resolved

Uh oh!

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

@kumaraditya303

kumaraditya303 commented Jul 3, 2022

Copy link
Copy Markdown
Contributor Author

Please add a NEWS entry explaining that the purpose of this PR is to fix memory leaks when the _multiprocessing extension module is loaded/unloaded multiple times: #94382 (comment)

This means I can remove do-not-merge, right ?

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
code review from Victor
ccab6e6
@kumaraditya303
kumaraditya303 requested a review from vstinner July 3, 2022 16:32
@vstinner

vstinner commented Jul 3, 2022

Copy link
Copy Markdown
Member

This means I can remove do-not-merge, right ?

That's unrelated. @erlend-aasland wrote:

As of Petr's last comment, please re-label this with do-not-merge until there is an agreement.

Since @erlend-aasland and @encukou wrote PEP 687, I understand that you need to agree on that specific PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@blurb-it
📜🤖 Added by blurb_it.
3e5cb84
@kumaraditya303 kumaraditya303 removed the skip news label Jul 3, 2022
@vstinner

vstinner commented Jul 3, 2022

Copy link
Copy Markdown
Member

Sorry, I'm no longer convinced that this PR fix an actual memory leak. The NEWS entry no looks wrong to me.

Test from #94382 (comment):

from test import support
import sys
for i in range(1, 10):
    support.run_in_subinterp("import multiprocessing")
    print("refs:", sys.gettotalrefcount(), "blocks: ", sys.getallocatedblocks())

Without this PR, Python leaks memory: refs +469, blocks +160.

refs: 162138 blocks:  47456
refs: 162201 blocks:  47476
refs: 162259 blocks:  47496
refs: 162317 blocks:  47516
refs: 162375 blocks:  47536
refs: 162433 blocks:  47556
refs: 162491 blocks:  47576
refs: 162549 blocks:  47596
refs: 162607 blocks:  47616

With this PR (rebased to main), Python still leaks memory: refs +469, blocks +160 (no change).

refs: 162138 blocks:  47446
refs: 162201 blocks:  47466
refs: 162259 blocks:  47486
refs: 162317 blocks:  47506
refs: 162375 blocks:  47526
refs: 162433 blocks:  47546
refs: 162491 blocks:  47566
refs: 162549 blocks:  47586
refs: 162607 blocks:  47606

Tell me if I did something wrong.


If I modify the test to import the _multiprocessing extension instead, I see no leak on the Python main branch (without this PR):

refs: 162674 blocks:  49018

refs: 162679 blocks:  49018
refs: 162679 blocks:  49018
refs: 162679 blocks:  49018
refs: 162679 blocks:  49018
refs: 162679 blocks:  49018
refs: 162679 blocks:  49018
refs: 162679 blocks:  49018
refs: 162679 blocks:  49018

Note: I added an empty line for readability.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303

kumaraditya303 commented Jul 3, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

I had only verified single leak #94382 (comment) which is fixed by this PR. If the multiple initialization is not fixed, there must be something in multiprocessing module which is causing it. Anyways, I'll wait for decision on the discourse now before putting anymore effort into this as there are more reason for this change other than multiple initialization.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jul 3, 2022

Copy link
Copy Markdown
Contributor

This means I can remove do-not-merge, right ?

Please wait until there is an agreement for this change on Discourse.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland erlend-aasland removed the DO-NOT-MERGE label Jul 15, 2022
kumaraditya303 added 2 commits July 15, 2022 10:10
@kumaraditya303
Merge branch 'main' of https://github.com/python/cpython into multipr…
1251e74
…ocessing
@kumaraditya303
Merge branch 'multiprocessing' of https://github.com/kumaraditya303/c…
ef7ce6c
…python into multiprocessing
@kumaraditya303 kumaraditya303 changed the title GH-94382: port multiprocessing types to heap types GH-94382: port multiprocessing static types to heap types Jul 15, 2022
@kumaraditya303
edit news
919bbe0
erlend-aasland
erlend-aasland approved these changes Jul 15, 2022
View reviewed changes
@erlend-aasland

erlend-aasland commented Jul 18, 2022

Copy link
Copy Markdown
Contributor

FYI, I'll merge this in a day or two.

kumaraditya303 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland erlend-aasland self-assigned this Jul 18, 2022
@erlend-aasland

erlend-aasland commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

I'm hesitant to backport this change. Let me know if you disagree, Victor / Petr.

All reactions

Sorry, something went wrong.

Uh oh!

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

erlend-aasland
erlend-aasland reviewed Jul 20, 2022
View reviewed changes
Comment thread Modules/_multiprocessing/semaphore.c Resolved

Uh oh!

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

@erlend-aasland
erlend-aasland merged commit 000a4ee into python:main Jul 20, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Jul 20, 2022
@erlend-aasland

erlend-aasland commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

Thanks, Kumar!

kumaraditya303 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
kumaraditya303 deleted the multiprocessing branch July 21, 2022 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@arhadthedev arhadthedev arhadthedev left review comments
@erlend-aasland erlend-aasland erlend-aasland approved these changes
@encukou encukou Awaiting requested review from encukou
@vstinner vstinner Awaiting requested review from vstinner

Uh oh!

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

Assignees

@erlend-aasland erlend-aasland

@kumaraditya303 kumaraditya303

Labels

None yet

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.

6 participants

@kumaraditya303 @bedevere-bot @erlend-aasland @vstinner @encukou @arhadthedev
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.