Author Topic: CreateThread overhead  (Read 5715 times)

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: CreateThread overhead
« Reply #15 on: February 03, 2021, 01:59:15 AM »
The old i7 is clocked at 4 gig.

Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
152 µs  for #1/1
182 µs  for #2/2
420 µs  for #3/3
444 µs  for #4/4
464 µs  for #5/5
489 µs  for #6/6
512 µs  for #7/7
551 µs  for #8/8
571 µs  for #9/9
591 µs  for #10/10
620 µs  for #11/11
649 µs  for #12/12
666 µs  for #13/13
684 µs  for #14/14
705 µs  for #15/15
736 µs  for #16/28  <---- first "outlier"

So far the most "stable" result (2nd for quarantined's AMD), in the sense of launching order == finishing order :cool:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8497
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: CreateThread overhead
« Reply #16 on: February 03, 2021, 02:31:17 AM »
Something you will find is that not all cores in a processor run at the same speed. Both with the old 6 core i7 AND the 12 core Xeon, the core speeds and loadings show some cores faster than others. I use to get the same variation with an earlier 4 core 4770k so its probably a variable factor with multi-core processors.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

quarantined

  • Regular Member
  • *
  • Posts: 22
Re: CreateThread overhead
« Reply #17 on: February 04, 2021, 03:14:20 AM »
:thumbsup:

My initial CreateThread is always above 1000 µs, on Win7-64. I wonder if Win10 has become better, or if it's cpu related :rolleyes:

For your info, all the tests I have run here are on Windows 7, 32 bit. Hope this info is useful

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: CreateThread overhead
« Reply #18 on: February 04, 2021, 07:32:10 AM »
:thumbsup:

My initial CreateThread is always above 1000 µs, on Win7-64. I wonder if Win10 has become better, or if it's cpu related :rolleyes:

For your info, all the tests I have run here are on Windows 7, 32 bit. Hope this info is useful

It is, it is, thanks :thup:

In theory, it could be related to Wow64, the thin layer that lets 32-bit executables access the 64-bit kernel stuff. However, some other members have posted very short CreateThread times, so I doubt that is the reason :cool:

HSE

  • Member
  • *****
  • Posts: 1743
  • <AMD>< 7-32>
Re: CreateThread overhead
« Reply #19 on: February 04, 2021, 08:56:59 AM »
Code: [Select]
AMD A6-3500 APU with Radeon(tm) HD Graphics
195 µs  for #1/1
233 µs  for #2/2
516 µs  for #3/3
551 µs  for #4/4
785 µs  for #5/7
869 µs  for #6/6
902 µs  for #7/11
1063 µs for #8/12
1286 µs for #9/8
1395 µs for #10/9
1507 µs for #11/10
1622 µs for #12/5
1682 µs for #13/13
1713 µs for #14/23
1838 µs for #15/15
1925 µs for #16/16
1973 µs for #17/27
2027 µs for #18/28
2090 µs for #19/19
2109 µs for #20/29
2195 µs for #21/21
2247 µs for #22/22
2300 µs for #23/30
2316 µs for #24/32
2400 µs for #25/14
2461 µs for #26/24
2513 µs for #27/25
2581 µs for #28/26
2628 µs for #29/37
2685 µs for #30/17
2777 µs for #31/18
2869 µs for #32/20
2934 µs for #33/31
3063 µs for #34/33
3142 µs for #35/34
3160 µs for #36/35
3278 µs for #37/36
3369 µs for #38/38
3426 µs for #39/39
3633 µs for #40/40
This machine have 3 cores and allow 6 subprocess.

TimoVJL

  • Member
  • ****
  • Posts: 725
Re: CreateThread overhead
« Reply #20 on: February 04, 2021, 07:05:37 PM »
Windows 10 x64
https://www.amd.com/en/products/apu/amd-ryzen-5-3400g
Code: [Select]
AMD Ryzen 5 3400G with Radeon Vega Graphics   
327 µs for #1/1
386 µs for #2/2
454 µs for #3/3
492 µs for #4/4
591 µs for #5/6
672 µs for #6/7
698 µs for #7/8
743 µs for #8/5
791 µs for #9/9
895 µs for #10/11
995 µs for #11/12
1046 µs for #12/13
1093 µs for #13/10
1121 µs for #14/16
1168 µs for #15/15
1242 µs for #16/14
1295 µs for #17/17
1349 µs for #18/18
1402 µs for #19/19
1505 µs for #20/20
1661 µs for #21/21
1708 µs for #22/22
1757 µs for #23/23
1804 µs for #24/24
1841 µs for #25/25
1912 µs for #26/26
2006 µs for #27/27
2045 µs for #28/28
2105 µs for #29/29
2157 µs for #30/30
2219 µs for #31/31
2254 µs for #32/32
2317 µs for #33/33
2370 µs for #34/34
2467 µs for #35/35
2550 µs for #36/36
2592 µs for #37/37
2637 µs for #38/38
2701 µs for #39/39
2797 µs for #40/40
May the source be with you

mikeburr

  • Member
  • **
  • Posts: 134
Re: CreateThread overhead
« Reply #21 on: February 05, 2021, 08:44:49 AM »
heres mine ... bit surprised how quick it is
Intel(R) Xeon(R) CPU           X5670  @ 2.93GHz
125 µs   for #1/1
159 µs   for #2/2
193 µs   for #3/3
217 µs   for #4/4
255 µs   for #5/5
431 µs   for #6/6
467 µs   for #7/7
487 µs   for #8/8
504 µs   for #9/11
526 µs   for #10/10
550 µs   for #11/9
577 µs   for #12/12
623 µs   for #13/13
717 µs   for #14/14
785 µs   for #15/15
794 µs   for #16/16
826 µs   for #17/17
847 µs   for #18/18
890 µs   for #19/19
938 µs   for #20/20
974 µs   for #21/21
1008 µs   for #22/22
1034 µs   for #23/23
1078 µs   for #24/24
1115 µs   for #25/25
1155 µs   for #26/26
1214 µs   for #27/27
1259 µs   for #28/28
1298 µs   for #29/29
1340 µs   for #30/30
1360 µs   for #31/31
1388 µs   for #32/32
1438 µs   for #33/33
1468 µs   for #34/34
1506 µs   for #35/35
1552 µs   for #36/36
1589 µs   for #37/37
1608 µs   for #38/38
1654 µs   for #39/39
1676 µs   for #40/40

LiaoMi

  • Member
  • ****
  • Posts: 922
Re: CreateThread overhead
« Reply #22 on: February 06, 2021, 10:58:39 AM »
Code: [Select]
Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
47 µs for creating the thread
thread resumed after 385 µs     for #1
thread resumed after 9 µs       for #2
thread resumed after 7 µs       for #3
thread resumed after 7 µs       for #4
thread resumed after 6 µs       for #5
thread resumed after 7 µs       for #6
thread resumed after 6 µs       for #7
thread resumed after 10 µs      for #8
thread resumed after 4 µs       for #9
thread resumed after 3 µs       for #10
thread resumed after 9 µs       for #11
thread resumed after 4 µs       for #12
thread resumed after 6 µs       for #13
thread resumed after 5 µs       for #14
thread resumed after 9 µs       for #15
thread resumed after 8 µs       for #16
thread resumed after 5 µs       for #17
thread resumed after 8 µs       for #18
thread resumed after 8 µs       for #19
thread resumed after 9 µs       for #20
thread resumed after 9 µs       for #21
thread resumed after 11 µs      for #22
thread resumed after 10 µs      for #23
thread resumed after 8 µs       for #24
thread resumed after 10 µs      for #25
thread resumed after 12 µs      for #26
thread resumed after 14 µs      for #27
thread resumed after 12 µs      for #28
thread resumed after 9 µs       for #29
thread resumed after 17 µs      for #30
thread resumed after 9 µs       for #31
--- hit any key ---

Code: [Select]
Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
163 µs  for #1/1
218 µs  for #2/2
439 µs  for #3/3
506 µs  for #4/5
545 µs  for #5/18
584 µs  for #6/19
632 µs  for #7/20
669 µs  for #8/8
708 µs  for #9/9
766 µs  for #10/10
796 µs  for #11/26
861 µs  for #12/12
888 µs  for #13/13
968 µs  for #14/14
1033 µs for #15/33
1137 µs for #16/4
1169 µs for #17/16
1216 µs for #18/17
1275 µs for #19/6
1378 µs for #20/7
1450 µs for #21/21
1518 µs for #22/22
1590 µs for #23/23
1673 µs for #24/24
1736 µs for #25/25
1791 µs for #26/27
1894 µs for #27/28
1957 µs for #28/29
1988 µs for #29/30
2066 µs for #30/31
2147 µs for #31/15
2190 µs for #32/34
2266 µs for #33/35
2296 µs for #34/36
2324 µs for #35/37
2353 µs for #36/38
2407 µs for #37/39
2450 µs for #38/40
2598 µs for #39/11
2730 µs for #40/32


jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: CreateThread overhead
« Reply #23 on: February 06, 2021, 12:05:44 PM »
Code: [Select]
Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
47 µs for creating the thread
thread resumed after 385 µs     for #1
thread resumed after 9 µs       for #2
thread resumed after 7 µs       for #3
thread resumed after 7 µs       for #4
thread resumed after 6 µs       for #5
thread resumed after 7 µs       for #6
thread resumed after 6 µs       for #7

Wow, that's a fast machine :thumbsup:

Gunther

  • Member
  • *****
  • Posts: 3723
  • Forgive your enemies, but never forget their names
Re: CreateThread overhead
« Reply #24 on: February 06, 2021, 05:30:37 PM »
Jochen,

sorry, I had simply overlooked your request for the test. Here is my result:
Quote

Intel(R) Core(TM) i7-7820X CPU @ 3.60GHz
353 µs   for #1/1
452 µs   for #2/10
554 µs   for #3/3
681 µs   for #4/21
782 µs   for #5/7
871 µs   for #6/27
969 µs   for #7/8
1044 µs   for #8/35
1131 µs   for #9/39
1222 µs   for #10/11
1459 µs   for #11/12
1577 µs   for #12/14
1694 µs   for #13/15
1787 µs   for #14/16
1870 µs   for #15/17
1972 µs   for #16/18
2060 µs   for #17/4
2150 µs   for #18/20
2239 µs   for #19/22
2334 µs   for #20/24
2449 µs   for #21/26
2531 µs   for #22/28
2568 µs   for #23/29
2753 µs   for #24/32
2837 µs   for #25/34
2968 µs   for #26/36
3000 µs   for #27/37
3104 µs   for #28/38
3184 µs   for #29/2
3304 µs   for #30/13
3506 µs   for #31/19
3558 µs   for #32/5
3668 µs   for #33/23
3754 µs   for #34/25
3842 µs   for #35/6
3949 µs   for #36/30
4040 µs   for #37/33
4124 µs   for #38/9
4542 µs   for #40/31
4310 µs   for #39/40

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: CreateThread overhead
« Reply #25 on: February 06, 2021, 08:00:57 PM »
Jochen,

sorry, I had simply overlooked your request for the test. Here is my result:
...
Gunther

No problem, I got already many more answers than I expected. The purpose was simply to check if splitting a short task in many threads makes any sense... and it depends, obviously :cool:

TimoVJL

  • Member
  • ****
  • Posts: 725
Re: CreateThread overhead
« Reply #26 on: February 06, 2021, 08:42:10 PM »
I wait to see how Zen 3 / Ryzen 7 perform.
Would be nice to know testing Windows OS too.

A one of my test PC AMD Ryzen 5 3400G with Radeon Vega Graphics runs normally 2.7 GHz and is cabable to 3.7 GHz
so results varies a lot.
Code: [Select]
AMD Ryzen 5 3400G with Radeon Vega Graphics   
179 µs for #1/1
221 µs for #2/2
262 µs for #3/5
308 µs for #4/3
342 µs for #5/4
386 µs for #6/6
455 µs for #7/7
505 µs for #8/8
544 µs for #9/11
573 µs for #10/10
622 µs for #11/9
650 µs for #12/15
752 µs for #13/12
781 µs for #14/13
816 µs for #15/14
843 µs for #16/22
906 µs for #17/16
947 µs for #18/17
973 µs for #19/18
1002 µs for #20/19
1025 µs for #21/20
1055 µs for #22/26
1149 µs for #23/23
1202 µs for #24/24
1239 µs for #25/25
1284 µs for #26/28
1347 µs for #27/27
1405 µs for #28/21
1455 µs for #29/29
1492 µs for #30/30
1556 µs for #31/31
1610 µs for #32/32
1670 µs for #33/33
1714 µs for #34/34
1754 µs for #35/35
1786 µs for #36/36
1839 µs for #37/37
1874 µs for #38/38
1959 µs for #39/39
2023 µs for #40/40
May the source be with you

Gunther

  • Member
  • *****
  • Posts: 3723
  • Forgive your enemies, but never forget their names
Re: CreateThread overhead
« Reply #27 on: February 06, 2021, 09:02:50 PM »
Jochen,

No problem, I got already many more answers than I expected. The purpose was simply to check if splitting a short task in many threads makes any sense... and it depends, obviously :cool:

oh yes, it really depends on a lot of factors. And we are talking about fixed coupling (multiple threads or processes on the same machine). In a cluster (loose coupling), things look quite different again.

Gunther
Get your facts first, and then you can distort them.

quarantined

  • Regular Member
  • *
  • Posts: 22
Re: CreateThread overhead
« Reply #28 on: April 20, 2021, 05:31:45 AM »

Just for kicks...

Code: [Select]
Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
26 µs for creating the thread
thread resumed after 67 µs      for #1
thread resumed after 6 µs       for #2
thread resumed after 4 µs       for #3
thread resumed after 5 µs       for #4
thread resumed after 4 µs       for #5
thread resumed after 6 µs       for #6
thread resumed after 3 µs       for #7
thread resumed after 3 µs       for #8
thread resumed after 4 µs       for #9
thread resumed after 3 µs       for #10
thread resumed after 5 µs       for #11
thread resumed after 4 µs       for #12
thread resumed after 4 µs       for #13
thread resumed after 3 µs       for #14
thread resumed after 5 µs       for #15
thread resumed after 3 µs       for #16
thread resumed after 4 µs       for #17
thread resumed after 3 µs       for #18
thread resumed after 3 µs       for #19
thread resumed after 4 µs       for #20
thread resumed after 3 µs       for #21
thread resumed after 5 µs       for #22
thread resumed after 3 µs       for #23
thread resumed after 4 µs       for #24
thread resumed after 4 µs       for #25
thread resumed after 4 µs       for #26
thread resumed after 4 µs       for #27
thread resumed after 4 µs       for #28
thread resumed after 4 µs       for #29
thread resumed after 4 µs       for #30
thread resumed after 4 µs       for #31
--- hit any key ---
Windows xp, 32 bit

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: CreateThread overhead
« Reply #29 on: April 20, 2021, 07:20:50 AM »
Windows xp, 32 bit

That's pretty fast. I wonder whether the WOW64 overhead plays a role here.