Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Conversation

MartinNowak
Copy link
Member

  • heavily reduce suspendAll time with many threads by signalling all N
    threads in parallel and then waiting N times for the semaphore rather
    than doing that serially
  • won't improve anything on OSX/Windows which do use a synchronous
    suspend API

@MartinNowak
Copy link
Member Author

heavily reduces suspend time with many threads

From a few ms (growing with the number of threads) to 100-200 us.

@complexmath
Copy link
Contributor

It seems like you're doing more here than just suspending threads in parallel, which could be done by changing about 10 lines of code (I think there's even a comment to this effect in core.thread). Maybe this should be broken into multiple separate pull requests?

@MartinNowak
Copy link
Member Author

It seems like you're doing more here than just suspending threads in parallel, which could be done by changing about 10 lines of code (I think there's even a comment to this effect in core.thread). Maybe this should be broken into multiple separate pull requests?

Sure, I can split of the critical sections part into a separate pull.
This pull depends on this to maintain the recent suspendagain fix for FreeBSD #1061.

See #1116

@MartinNowak
Copy link
Member Author

Now it's only a single commit remaining.

@MartinNowak
Copy link
Member Author

This is supposed to be part of 2.067's GC speedups, so a timely review would be appreciated.

@MartinNowak
Copy link
Member Author

Anyone?

Copy link
Member

Choose a reason for hiding this comment

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

This is not a change by this PR, but why isn't m_isInCriticalRegion not checked again when the thread is actually suspended? It could have been changed after the check here and before the actual suspension.

Copy link
Member

Choose a reason for hiding this comment

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

Another optimization might be to also interleave checking the critical regions of the threads, though it is probably not used that much.

Copy link
Member Author

Choose a reason for hiding this comment

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

It could have been changed after the check here and before the actual suspension.

It shouldn't and that was a bug introduced by the other pull.
See #1164 for a fix.

@rainers
Copy link
Member

rainers commented Feb 11, 2015

I'm not a Posix expert, but this looks good to me. I can merge tomorrow if there are no objections...

@MartinNowak MartinNowak removed this from the 2.067 milestone Feb 13, 2015
@MartinNowak
Copy link
Member Author

Let's wait with this until after 2.067.

@DmitryOlshansky
Copy link
Member

LGTM would be awesome to revive this.

@DmitryOlshansky
Copy link
Member

ping @MartinNowak

@MartinNowak MartinNowak added the GC garbage collector label Oct 30, 2015
@MartinNowak
Copy link
Member Author

It's still blocked by #1164.

- it's not possible to add a thread while suspendAll holds slock
- so Thread.getThis will always be set in the signal handler
- heavily reduce suspendAll time with many threads by signalling all N
  threads in parallel and then waiting N times for the semaphore rather
  than doing that serially
- won't improve anything on OSX/Windows which do use a synchronous
  suspend API

- move critical region handling into suspend method
- change FreeBSD's m_suspendagain workaround to a per thread flag
@MartinNowak
Copy link
Member Author

Resurrected, works now that we found a nice solution to the suspend during startup issue.

@MartinNowak
Copy link
Member Author

Anyone?

@dnadlinger
Copy link
Contributor

All I can say is that the diff looks sensible just skimming it. I don't quite have the time to give it a proper review right now, unfortunately. Maybe @alexrp or @complexmath can chime in?

@MartinNowak
Copy link
Member Author

Alex hasn't worked on D since about a year, and Sean only finds time very sporadically.

@DmitryOlshansky
Copy link
Member

Auto-merge toggled on

DmitryOlshansky added a commit that referenced this pull request Nov 11, 2015
@DmitryOlshansky DmitryOlshansky merged commit faa1643 into dlang:master Nov 11, 2015
@DmitryOlshansky
Copy link
Member

We have full release cycle to test and anything to help GC pauses is top priority IMO.

@MartinNowak MartinNowak deleted the parallelSuspend branch November 11, 2015 10:00
@MartinNowak
Copy link
Member Author

Thanks, the most critical part of that series was MartinNowak@7ec6520 anyhow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
GC garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants