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

problem using semaphore with many threads #5454

Closed
p6rt opened this issue Jul 15, 2016 · 10 comments
Closed

problem using semaphore with many threads #5454

p6rt opened this issue Jul 15, 2016 · 10 comments

Comments

@p6rt
Copy link

p6rt commented Jul 15, 2016

Migrated from rt.perl.org#128628 (status was 'resolved')

Searchable as RT128628$

@p6rt
Copy link
Author

p6rt commented Jul 15, 2016

From @MARTIMM

Hi,

With Rakudo version 2016.06-234-g0189851 built on MoarVM version
2016.06-9-g8fc21d5
implementing Perl 6.c on a Asus laptop running Fedora 23 I see the
following happen. Running the code below is doing well but when the code
in the critical section gets complex (e.g. '$r += [+] $i, 3, 4, 5, 6, 7,
8, 9, 10;'), the program does not finish. The output of the '+' and '-'
stops but the cpu (2 or 3 of 8) will go to 100% usage (user time, not
system time).

my Semaphore $s .= new(1);

my @​p;
my $r;
for ^4000 {
  my $i = $_;

  @​p.push​: Promise.start( {

  $s.acquire;
  print "+";

  # critical code area
  $r += $i;

  $s.release;
  print "-";
  }
  );
}

Greetings
Marcel

@p6rt
Copy link
Author

p6rt commented Jul 21, 2016

From @jnthn

On Fri Jul 15 12​:32​:30 2016, mt1957@​gmail.com wrote​:

With Rakudo version 2016.06-234-g0189851 built on MoarVM version
2016.06-9-g8fc21d5
implementing Perl 6.c on a Asus laptop running Fedora 23 I see the
following happen. Running the code below is doing well but when the code
in the critical section gets complex (e.g. '$r += [+] $i, 3, 4, 5, 6, 7,
8, 9, 10;'), the program does not finish. The output of the '+' and '-'
stops but the cpu (2 or 3 of 8) will go to 100% usage (user time, not
system time).

my Semaphore $s .= new(1);

my @​p;
my $r;
for ^4000 {
my $i = $_;

@​p.push​: Promise.start( {

   $s\.acquire;
   print "\+";

   \# critical code area
   $r \+= $i;

   $s\.release;
   print "\-";
 \}

);
}

This is largely addressed by​:

MoarVM/MoarVM@236058a

However, there is an occasional GC orchestration hang that I'm still looking into.

@p6rt
Copy link
Author

p6rt commented Jul 21, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 22, 2016

From @MARTIMM

On 07/21/2016 02​:52 PM, jnthn@​jnthn.net via RT wrote​:

On Fri Jul 15 12​:32​:30 2016, mt1957@​gmail.com wrote​:

With Rakudo version 2016.06-234-g0189851 built on MoarVM version
2016.06-9-g8fc21d5
implementing Perl 6.c on a Asus laptop running Fedora 23 I see the
following happen. Running the code below is doing well but when the code
in the critical section gets complex (e.g. '$r += [+] $i, 3, 4, 5, 6, 7,
8, 9, 10;'), the program does not finish. The output of the '+' and '-'
stops but the cpu (2 or 3 of 8) will go to 100% usage (user time, not
system time).

my Semaphore $s .= new(1);

my @​p;
my $r;
for ^4000 {
my $i = $_;

@​p\.push​: Promise\.start\( \{

    $s\.acquire;
    print "\+";

    \# critical code area
    $r \+= $i;

    $s\.release;
    print "\-";
  \}
\);

}

This is largely addressed by​:

MoarVM/MoarVM@236058a

However, there is an occasional GC orchestration hang that I'm still looking into.
Hi Jonathan,

I'm afraid the test I've created still hangs in rakudo version
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d
implementing Perl 6.c.

This time only 80 threads started and using '$r += [+] $i, 3, 4, 5, 6,
7, 8, 9, 10;' in the critical section.

Btw, a problem in [+] might exist because changing that into '$r += $i +
3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;' the code is running flawlessly even
with 4000 threads.

Greetings,

Marcel

@p6rt
Copy link
Author

p6rt commented Jul 27, 2016

From @jnthn

On Fri Jul 22 01​:46​:53 2016, mt1957@​gmail.com wrote​:

I'm afraid the test I've created still hangs in rakudo version
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d
implementing Perl 6.c.

Ah, that's a too early MoarVM version to have the fix (it was the commit after that one); you'd need to explicitly build MoarVM master to have got it since it's beyond the current "recommended version". Hope to look into the second, GC-related, issue today also, however, so will bump the recommended version after that. :-)

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

From @MARTIMM

On 07/21/2016 02​:52 PM, jnthn@​jnthn.net via RT wrote​:

On Fri Jul 15 12​:32​:30 2016, mt1957@​gmail.com wrote​:

With Rakudo version 2016.06-234-g0189851 built on MoarVM version
2016.06-9-g8fc21d5
implementing Perl 6.c on a Asus laptop running Fedora 23 I see the
following happen. Running the code below is doing well but when the code
in the critical section gets complex (e.g. '$r += [+] $i, 3, 4, 5, 6, 7,
8, 9, 10;'), the program does not finish. The output of the '+' and '-'
stops but the cpu (2 or 3 of 8) will go to 100% usage (user time, not
system time).

my Semaphore $s .= new(1);

my @​p;
my $r;
for ^4000 {
my $i = $_;

@​p\.push​: Promise\.start\( \{

    $s\.acquire;
    print "\+";

    \# critical code area
    $r \+= $i;

    $s\.release;
    print "\-";
  \}
\);

}

This is largely addressed by​:

MoarVM/MoarVM@236058a

However, there is an occasional GC orchestration hang that I'm still looking into.
Hi Jonathan,

I'm afraid the test I've created still hangs in rakudo version
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d
implementing Perl 6.c.

This time only 80 threads started and using '$r += [+] $i, 3, 4, 5, 6,
7, 8, 9, 10;' in the critical section.

Btw, a problem in [+] might exist because changing that into '$r += $i +
3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;' the code is running flawlessly even
with 4000 threads.

Greetings,

Marcel

p.s. email sent to perl6-compiler@​perl.org before but now sent also to
perl6-bugs-followup

@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

From @jnthn

On Fri, Jul 22, 2016 at 10​:46 AM, mt1957 via RT <
perl6-bugs-followup@​perl.org> wrote​:

I'm afraid the test I've created still hangs in rakudo version
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d
implementing Perl 6.c.

That's still a too old MoarVM version. You'd need to explicitly build the
master branch of MoarVM, not version 2016.07-3-gc01472d. Also I put another
semaphore fix in yesterday, and had it run to completion 1000 times without
problem. Will bump the MoarVM version Rakudo requires shortly, anyway,
which will save the manual build.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

From @MARTIMM

On 07/28/2016 03​:00 PM, Jonathan Worthington via RT wrote​:

On Fri, Jul 22, 2016 at 10​:46 AM, mt1957 via RT <
perl6-bugs-followup@​perl.org> wrote​:

I'm afraid the test I've created still hangs in rakudo version
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d
implementing Perl 6.c.

That's still a too old MoarVM version. You'd need to explicitly build the
master branch of MoarVM, not version 2016.07-3-gc01472d. Also I put another
semaphore fix in yesterday, and had it run to completion 1000 times without
problem. Will bump the MoarVM version Rakudo requires shortly, anyway,
which will save the manual build.

/jnthn

Hi Jonathan,

Thanks very much for your work, I'll wait and see. I pull rakudo
versions directly from the github and some day it will be working :-).

Thanks again for all of your work,

Marcel

@p6rt
Copy link
Author

p6rt commented Aug 3, 2016

From @jnthn

On Thu Jul 28 09​:58​:56 2016, mt1957@​gmail.com wrote​:

Thanks very much for your work, I'll wait and see. I pull rakudo
versions directly from the github and some day it will be working :-).

The version bumps have been done. I've also added tests along the lines of your examples to the spectest suite (in S17-lowlevel/semaphore.t), and they seem to be running reliably (ran them 200 times without any hangs or incorrect results). So, hopefully the various fixes have fully resolved it.

Please re-file (or re-open this issue) if you still have problems.

Thanks,

Jonathan

@p6rt p6rt closed this as completed Aug 3, 2016
@p6rt
Copy link
Author

p6rt commented Aug 3, 2016

@jnthn - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant