Hi Dave,

I don't think there's any bugs here, but I'm also not sure I'm totally
following this, so let me know if I'm answering the wrong question.

>the system seems to busy-wait during my call to the "sleep" library
>function

Yes, this is true. Our runtime currently busy-waits during a "sleep", but
this isn't a real performance issue. Most of our tasking layers implement
sleep by doing a chpl_task_yield() in a loop until the sleep time has run
out. Something like:

    void chpl_task_sleep(double secs) {
      ...
      do {
        chpl_task_yield();
      } while (timer_secs(t) < secs);
    }

This has the unfortunate side-effect of wasting compute cycles when no other
tasks are running and inflating what `time` reports for "user", but it won't
hurt performance if other tasks have real work to do. Basically a sleeping
task will yield and let other tasks run, but if there's nothing else running
the scheduler will just immediately reschedule it, which creates a busy-wait
of sorts.

This is a known issue and is something we definitely want to fix, but it
hasn't made it to the top of our list because it doesn't hurt performance.

>when I create an array, all cores do the busy-wait instead of one
>when I create an array, n-1 cores busy-wait during a pause for input

I'm not seeing this behavior when I run this test. Can you send me the
output of `$CHPL_HOME/util/printchplenv`, `uname` and either the output of
`lscpu` or `cat /proc/cpuinfo`?

Elliot



>While tracking down the details of the performance question I reported a 
>couple of days ago (thanks, Elliot and Brad!), I have uncovered surprising 
>behavior on my system. I'm not sure if this is a bug in my code, a Chapel bug 
>(probably library, maybe compiler?), an install problem on my system, or just 
>something even stranger.
>
>The problem is this:
>the system seems to busy-wait during my call to the "sleep" library function
>when I create an array, all cores do the busy-wait instead of one
>when I create an array, n-1 cores busy-wait during a pause for input
>The simple program I wrote to demonstrate this is:
>
>davew@liskov:~/Teaching/Theses/btrush/chapel$ cat 
>WisconsinTourismFederation.chpl
>use Time;
>config const nMax    : int  = 6000;
>config const seconds : int  = 4;
>config const buildit : bool = false;
>
>if (buildit) {
>   var MatrixD: domain(2) = {1..nMax, 1..nMax};
>   var m : [MatrixD] int;
>}
>
>writeln("start by calling sleep");
>sleep(seconds);
>writeln("somebody say, 'one, two, three, go!' ...");
>var sundance=stdin.read(string);
>writeln("heard ", sundance);
>
>When I pause 0 seconds for 'sleep' and 0 seconds for 'stdin.read(string)', it 
>runs fast, regardless of the value of buildit:
>
>davew@liskov:~/Teaching/Theses/btrush/chapel$ make -f Makefile-cray.mk WTF
>chpl --fast -O WisconsinTourismFederation.chpl -o WTF
>davew@liskov:~/Teaching/Theses/btrush/chapel$ (sleep 0; echo 
>'one,_two,_three,_go!') | time ./WTF --buildit=true --seconds=0
>start by calling sleep
>somebody say, 'one, two, three, go!' ...
>heard one,_two,_three,_go!
>0.04user 0.31system 0:00.11elapsed 306%CPU (0avgtext+0avgdata 
>283600maxresident)k
>0inputs+0outputs (0major+69446minor)pagefaults 0swaps
>davew@liskov:~/Teaching/Theses/btrush/chapel$
>
>However, when I change the amounts of the pauses, it takes a lot of time, 
>especially with the array creation turned on:
>
>davew@liskov:~/Teaching/Theses/btrush/chapel$ (sleep 0; echo 
>'one,_two,_three,_go!') | time ./WTF --buildit=false --seconds=0
>start by calling sleep
>somebody say, 'one, two, three, go!' ...
>heard one,_two,_three,_go!
>0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 3116maxresident)k
>0inputs+0outputs (0major+151minor)pagefaults 0swaps
>davew@liskov:~/Teaching/Theses/btrush/chapel$ (sleep 0; echo 
>'one,_two,_three,_go!') | time ./WTF --buildit=false --seconds=20
>start by calling sleep
>somebody say, 'one, two, three, go!' ...
>heard one,_two,_three,_go!
>6.50user 13.49system 0:20.00elapsed 99%CPU (0avgtext+0avgdata 3120maxresident)k
>0inputs+0outputs (0major+151minor)pagefaults 0swaps
>davew@liskov:~/Teaching/Theses/btrush/chapel$ (sleep 20; echo 
>'one,_two,_three,_go!') | time ./WTF --buildit=false --seconds=0
>start by calling sleep
>somebody say, 'one, two, three, go!' ...
>heard one,_two,_three,_go!
>0.00user 0.00system 0:20.00elapsed 0%CPU (0avgtext+0avgdata 3064maxresident)k
>0inputs+0outputs (0major+145minor)pagefaults 0swaps
>davew@liskov:~/Teaching/Theses/btrush/chapel$ (sleep 0; echo 
>'one,_two,_three,_go!') | time ./WTF --buildit=true --seconds=20
>start by calling sleep
>somebody say, 'one, two, three, go!' ...
>heard one,_two,_three,_go!
>21.84user 56.74system 0:20.11elapsed 390%CPU (0avgtext+0avgdata 
>283640maxresident)k
>0inputs+0outputs (0major+66378minor)pagefaults 0swaps
>davew@liskov:~/Teaching/Theses/btrush/chapel$ (sleep 20; echo 
>'one,_two,_three,_go!') | time ./WTF --buildit=true --seconds=0
>start by calling sleep
>somebody say, 'one, two, three, go!' ...
>heard one,_two,_three,_go!
>16.34user 43.61system 0:20.00elapsed 299%CPU (0avgtext+0avgdata 
>283844maxresident)k
>0inputs+0outputs (0major+66375minor)pagefaults 0swaps
>davew@liskov:~/Teaching/Theses/btrush/chapel$ 
>
>When I look at the output of "htop" while running this, it shows the relevant 
>cores 100% busy, but only a part (a quarter to a third) of the bar graph for 
>each processor is green, with the rest being colored red, I think (I'm partly 
>color-blind). I'm not entirely sure what that means from htop, though. 
>
>I have attached the WisconsinTourismFederation.chpl example and the makefile 
>used above. I also have a (39MB) video file showing the results of a run with 
>4 seconds each of sleep and input waiting, in case you want to see it.
>
>For reference, "sleep 20" in the shell, which presumably calls C's 'sleep' 
>function, does not show anything interesting on "htop" or "time":
>
>$ time sleep 20
>0.00user 0.00system 0:20.00elapsed 0%CPU (0avgtext+0avgdata 1936maxresident)k
>0inputs+0outputs (0major+77minor)pagefaults 0swaps
>
>I've CC'd my sysadmin, Divesh Otwani, in case there are questions/thoughts 
>about the installation.
>
>Thanks for any guidance you can provide,
>   Dave W


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to