Why are threads slower?

Everything else that doesn't fall into one of the other PB categories.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Freak,

Has this issue been addressed in PB4.30?

Thanks
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Yes.
quidquid Latine dictum sit altum videtur
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

:D

Thanks
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

I don't want to intrude on what is an interesting thread, but I have a dumb question. I was always of the opinion that the purpose of multiple threads was so different parts of the application could basically run independant of each other so as not to detrimentally affect the operation of other parts, not to increase speed?
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Personally, I usually use threads for network apps or things where serially it can take a long time but not add much load by doing in tandem. Considering if you want to ping 1000 systems that are 500ms away. Threads will do this a lot faster and not really touch the CPU much more.

In this case, I was building a benchmark tool and in the last case I hit the random() issue a gomoku game. I needed more CPU and multi cores were available.

For the benmark, I specifically wanted to measure the inprovement of 4 cores vs 1 so I had to use threads, for the game, the competition ran on a dual core server and doubling my CPU meant more depth in the alpha-beta prunned minimax search of the game tree and therefor a stonger contender.

For some apps, you want speed now and at the expense of others if needed, in these situations if you have a quad core, you are disappointed to max the app out on 25% of the system power.

The benchark showed I was getting about 5x-6x more power on my quad core with 16 threads as one thread didn't get 1 whole core to itself, I don't want that for all apps, but if I'm doing video conversion it'd be nice to use more
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

SFSxOI wrote:I don't want to intrude on what is an interesting thread, but I have a dumb question. I was always of the opinion that the purpose of multiple threads was so different parts of the application could basically run independant of each other so as not to detrimentally affect the operation of other parts, not to increase speed?
There is no "purpose" of threads. They're just there - use them for whatever you want.
Post Reply