Finally made Go fast and not so memory hungry! :-))))
 
Using one buffered channel per 
result: 
https://github.com/funny-falcon/headon/blob/master/parallelism/go/mainmulti.go
 

headon/parallelism/go$ /usr/bin/time go run mainmulti.go -tasks 10000
Task to execute: 10000
10000 in 9.948716ms, hash = 0xb64c05b4
0.20user 0.02system 0:00.18elapsed 130%CPU (0avgtext+0avgdata 
30748maxresident)k
0inputs+2464outputs (0major+13034minor)pagefaults 0swaps
headon/parallelism/go$ /usr/bin/time go run mainmulti.go -tasks 100000
Task to execute: 100000
100000 in 149.616735ms, hash = 0x829de33c
0.67user 0.06system 0:00.32elapsed 227%CPU (0avgtext+0avgdata 
60592maxresident)k
0inputs+2464outputs (0major+28922minor)pagefaults 0swaps
headon/parallelism/go$ /usr/bin/time go run mainmulti.go -tasks 1000000
Task to execute: 1000000
1000000 in 1.537953634s, hash = 0xde68528c
5.31user 0.46system 0:01.72elapsed 334%CPU (0avgtext+0avgdata 
384608maxresident)k
256inputs+2464outputs (1major+125570minor)pagefaults 0swaps




воскресенье, 9 октября 2016 г., 12:47:48 UTC+3 пользователь Sokolov Yura 
написал:
>
> Here is results for my version https://github.com/funny-falcon/headon
> I utilize results by computing hash and summing it it main thread.
>
> .Net still faster and uses less memory. But not dramatically faster. But 
> dramatically less memory.
> It is pitty.
>
> Here is results for .NET:
>
> headon/parallelism/dotnet$ /usr/bin/time dotnet run -c Release 10000
> Project dotnet (.NETCoreApp,Version=v1.0) was previously compiled. 
> Skipping compilation.
> Task to execute: 10000
> 10000 in 00:00:00.0110531, hash = 0xb64c05b4
> 0.62user 0.07system 0:00.58elapsed 119%CPU (0avgtext+0avgdata 
> 66744maxresident)k
> 0inputs+48outputs (0major+17542minor)pagefaults 0swaps
> headon/parallelism/dotnet$ /usr/bin/time dotnet run -c Release 100000
> Project dotnet (.NETCoreApp,Version=v1.0) was previously compiled. 
> Skipping compilation.
> Task to execute: 100000
> 100000 in 00:00:00.0846664, hash = 0x829de33c
> 0.70user 0.06system 0:00.67elapsed 113%CPU (0avgtext+0avgdata 
> 66776maxresident)k
> 0inputs+48outputs (0major+20086minor)pagefaults 0swaps
> headon/parallelism/dotnet$ /usr/bin/time dotnet run -c Release 1000000
> Project dotnet (.NETCoreApp,Version=v1.0) was previously compiled. 
> Skipping compilation.
> Task to execute: 1000000
> 1000000 in 00:00:00.9544900, hash = 0xde68528c
> 1.57user 0.12system 0:01.57elapsed 107%CPU (0avgtext+0avgdata 
> 124912maxresident)k
>
>
> Here is for Go using channel for result passing:
>
> headon/parallelism/go$ /usr/bin/time go run main.go -tasks 10000
> Task to execute: 10000
> 10000 in 54.893915ms, hash = 0xb64c05b4
> 0.34user 0.03system 0:00.21elapsed 177%CPU (0avgtext+0avgdata 
> 30120maxresident)k
> 0inputs+2464outputs (0major+17786minor)pagefaults 0swaps
> headon/parallelism/go$ /usr/bin/time go run main.go -tasks 100000
> Task to execute: 100000
> 100000 in 568.61465ms, hash = 0x829de33c
> 1.85user 0.12system 0:00.76elapsed 260%CPU (0avgtext+0avgdata 
> 268676maxresident)k
> 0inputs+2464outputs (0major+77815minor)pagefaults 0swaps
> Project/headon/parallelism/go$ /usr/bin/time go run main.go -tasks 1000000
> Task to execute: 1000000
> 1000000 in 6.251455405s, hash = 0xde68528c
> 18.74user 1.17system 0:06.52elapsed 305%CPU (0avgtext+0avgdata 
> 2708028maxresident)k
> 0inputs+2464outputs (0major+668978minor)pagefaults 0swaps
>
>
> And Go result with using array for result passing and sync.WaitGroup for 
> synchronisation:
>
> headon/parallelism/go$ /usr/bin/time go run mainwait.go -tasks 10000
> Task to execute: 10000
> 10000 in 9.313603ms, hash = 0xb64c05b4
> 0.19user 0.02system 0:00.17elapsed 127%CPU (0avgtext+0avgdata 
> 30356maxresident)k
> 0inputs+2472outputs (0major+14299minor)pagefaults 0swaps
> headon/parallelism/go$ /usr/bin/time go run mainwait.go -tasks 100000
> Task to execute: 100000
> 100000 in 581.959038ms, hash = 0x829de33c
> 1.96user 0.12system 0:00.75elapsed 277%CPU (0avgtext+0avgdata 
> 230132maxresident)k
> 0inputs+2472outputs (0major+69227minor)pagefaults 0swaps
> headon/parallelism/go$ /usr/bin/time go run mainwait.go -tasks 1000000
> Task to execute: 1000000
> 1000000 in 6.258064822s, hash = 0xde68528c
> 18.75user 1.26system 0:06.54elapsed 306%CPU (0avgtext+0avgdata 
> 2784356maxresident)k
> 0inputs+2472outputs (0major+686800minor)pagefaults 0swaps
>
>
> воскресенье, 9 октября 2016 г., 12:17:51 UTC+3 пользователь Sotirios 
> Mantziaris написал:
>>
>> I am waiting for the final implementation to check them out. Looks 
>> promising.
>>
>> On Sun, Oct 9, 2016, 12:15 Jan Mercl <[email protected]> wrote:
>>
>>> On Sun, Oct 9, 2016 at 11:06 AM Sotirios Mantziaris <[email protected]> 
>>> wrote:
>>>
>>> > From what i understand goroutines are not threads either. 
>>>
>>> That's the whole point for the original claim. there's not way .net 
>>> could ever cope with 100k threads. If you want to compare apples to apples, 
>>> the Go version should run only about GOMAXPROCS goroutines. Also, be sure 
>>> to make some real work in the goroutine and collect and output its results 
>>> (sum for example) to avoid optimizing it away.
>>>
>>> Anyway, then the comparison would become that of picking a random task 
>>> to run on a thread vs a full blown goroutine scheduler with the complete 
>>> ready/running/wating state handling.
>>>
>>> BTW: How are .net channels doing? ;-)
>>>
>>> -- 
>>>
>>> -j
>>>
>> -- 
>> Kind Regards,
>>
>> S. Mantziaris
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to