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

Fork improvements #2907

Closed
wants to merge 3 commits into from
Closed

Conversation

ChrisJefferson
Copy link
Contributor

This PR adds SyFork, a wrapper around for which allows functions to be called pre- and post- fork. Profiling then uses this to create a new profile output for each child, to avoid the profile output getting corrupted.

If/when this is merged, I will force the IO package to use SyFork (when it is available), so forks which happen in IO can also be tracked.

@@ -3109,7 +3153,7 @@ UInt SyExecuteProcess (
func2 = &NullSignalHandler;

/* clone the process */
pid = vfork();
Copy link
Member

Choose a reason for hiding this comment

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

I think the use of vfork here is/was meant as an optimization that preserves memory and is also easier to implement on, say, Windows, than full fork. This PR silently changes it to fork, a deoptimization. Do we really want that? Perhaps a SyVFork is needed, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The spec for vfork says the only functions you are allowed to call after a vfork is _exit or exec*. We are calling chdir, open, fcntl and SyBufFileno (which is one of our functions, but I believe even that isn't acceptable). I can't find any spec that says that's acceptable, even on Linux. However, I shouldn't have bundled this into the same PR, as if we want to keep vfork a SyVfork would be easy to add.

Copy link
Contributor Author

@ChrisJefferson ChrisJefferson Oct 9, 2018

Choose a reason for hiding this comment

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

Actually, cygwin's vfork just calls fork it turns out (from some mailing list reading), although I think linux vfork actually does "proper" vfork.


/*
*F RegisterSyForkObserver( <func> )
** Register a function to be called before and after fork is called.
Copy link
Member

Choose a reason for hiding this comment

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

So, when adding documentation comments, I'd either make them match the existing ones, or radically different; but this is kind of a mishmash (only one space after **, no empty line after the *F line, no start line with /*****.

If you don't mind, I can amend this PR accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to adjust it. I want to look at why hpc-gap is crashing (I suspect switching vfork for fork, which suprises me, as I expected that to make hpc-gap more stable, not less.

@ChrisJefferson ChrisJefferson added topic: kernel release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Oct 9, 2018
@ChrisJefferson
Copy link
Contributor Author

Oh, I also removed a use of vfork, as we are using vfork in a very inapproriate way (I'm assuming on modern OSes vfork and fork must be equivalent, as by the book our use of vfork shouldn't be legal I believe).

@ChrisJefferson
Copy link
Contributor Author

I've realised, on further use, that this PR is actually not really want I wanted at the moment. I think I want to distinguish in the child between:

  • This child GAP will continue to exist as a GAP (so the profiler has to care)
  • This child will exec immediately, so there is no point making the profiler open a new file (it should still close the existing file, so the new execed process doesn't abuse it).

@ChrisJefferson
Copy link
Contributor Author

closing because this was a stupid idea. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants