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

Mount python worker files after taking memory snapshot #2806

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

hoodmane
Copy link
Contributor

This ensures that the contents of worker files cannot be accessed prior to taking the snapshot and so won't appear in the linear memory.

@hoodmane hoodmane force-pushed the hoodmane/python-later-worker-files branch from 93f9e76 to 246c248 Compare September 27, 2024 11:33
Module.FS.mount(mdFS, {}, '/session/metadata');
simpleRunPython(
Module,
`import sys; sys.path.append("/session/metadata"); del sys`
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be totally off base here but wouldn't we want sys.path.insert(0, ...) here?
If a user has http.py file with his main.py file we'd want his http.py file to take precedence over the builtin http module when he uses import http no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Edit: I can see this was moved so obviously it isn't specific to this PR but just a general question

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, and sorry for being annoying but the move actually does change behaviour where now site-packages are before session/metadata in path in contrast to previous behaviour.

Copy link
Contributor Author

@hoodmane hoodmane Sep 27, 2024

Choose a reason for hiding this comment

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

Good point I put that back, and sys.path.insert(0, ...) would be better. I'll make that change in a separate PR though.

@hoodmane hoodmane force-pushed the hoodmane/python-later-worker-files branch 2 times, most recently from 045d770 to c05f0ea Compare September 30, 2024 08:28
Copy link
Collaborator

@dom96 dom96 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@@ -424,7 +424,7 @@ struct CompatibilityFlags @0x8f8c1b68151b6cef {
pythonWorkers @43 :Bool
$compatEnableFlag("python_workers")
$pythonSnapshotRelease(pyodide = "0.26.0a2", pyodideRevision = "2024-03-01",
packages = "2024-03-01", backport = 0)
packages = "2024-03-01", backport = 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious why you're bumping this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I made a new bundle with the updated code with backport number 1. I want the new bundle to be used, so I have to bump the backport number.

Copy link
Collaborator

@dom96 dom96 Oct 1, 2024

Choose a reason for hiding this comment

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

Ahh, because the .ts file changes here need a new bundle in order to be used in prod, right?

It's going to take a bit of a mind shift to keep that in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's annoying.

Copy link
Collaborator

@dom96 dom96 Oct 1, 2024

Choose a reason for hiding this comment

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

yeah.. this is the thing that I'm concerned is going to end up causing us too much pain. Like even my small PR will need a regenerated bundle, right? #2830

I guess small changes like that can wait. Anyway, we should discuss about how we want to handle this. Started a thread internally for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

This ensures that the contents of worker files cannot be accessed prior to
taking the snapshot and so won't appear in the linear memory.
@hoodmane hoodmane force-pushed the hoodmane/python-later-worker-files branch from c05f0ea to 08bad5a Compare October 1, 2024 08:37
@hoodmane hoodmane merged commit bd4c6bf into main Oct 1, 2024
14 checks passed
@hoodmane hoodmane deleted the hoodmane/python-later-worker-files branch October 1, 2024 10:36
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.

3 participants