Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
jooky
Jan 15, 2003


shaggar??

Adbot
ADBOT LOVES YOU

Shaggar
Apr 26, 2006

Cocoa Crispies posted:

lol but at the same time

if you did the whole thing in c it probably would have taken months extra

going from 80s to 10s is cool, but going from 8 months to 1 month is cooler

That's why you go from python to c#/java and get a 500x speed up in runtime and a 20x speed up in dev.

Shaggar
Apr 26, 2006
also threads are really easy. you just need to make sure that none of them know that the others exist.

a cyberpunk goose
May 21, 2007


:wotwot: b-b-but of course

Shaggar posted:

also threads are really easy. you just need to make sure that none of them know that the others exist.

shaggar is right

to not suffer and thread, is to use C#

Zlodo
Nov 25, 2006
threading poo poo in a way that work can be easy
threading poo poo in a way that works and that actually performs better than not using threads is harder, there's lots of performance pitfalls

Bloody
Mar 3, 2013

Shaggar posted:

also threads are really easy. you just need to make sure that none of them know that the others exist.

this is absolutely fine. the task im handling is trivially parallelized - nothing any thread is doing has any impact whatsoever on the other threads. The individual tasks are relatively long - as much as half an hour of serial execution. this triviality scales well to hundreds of cores and terabytes of ram, which has the downside that i cant just spawn a thread for each task and wait for all of them to finish at once.

changing languages is unfortunately not an option at all for a variety of uninteresting reasons.

im using gcc 4.7 so whatever is available there is available to me

Posting Principle
Dec 10, 2011

by Ralp
4.7 doesn't have the new memory model, but iirc stdlibc++ supports the new std threading library

Shaggar
Apr 26, 2006

Mido posted:

:wotwot: b-b-but of course


shaggar is right

to not suffer and thread, is to use C#

I've never done thred pooling in c# but in java its kewl and ez to fire up an executor w/ some params and shove in crap while u wait for the futures

FamDav
Mar 29, 2008
if you gay boys want to hear some c++ threading knowledge i guess lusten to this

http://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Herb-Sutter-Concurrency-and-Parallelism

Zlodo
Nov 25, 2006

Bloody posted:

this is absolutely fine. the task im handling is trivially parallelized - nothing any thread is doing has any impact whatsoever on the other threads. The individual tasks are relatively long - as much as half an hour of serial execution. this triviality scales well to hundreds of cores and terabytes of ram, which has the downside that i cant just spawn a thread for each task and wait for all of them to finish at once.

changing languages is unfortunately not an option at all for a variety of uninteresting reasons.

im using gcc 4.7 so whatever is available there is available to me

have a look at intel's tbb library: https://www.threadingbuildingblocks.org/

it provides a lot of tools to simplify writing parallel algorithms while avoiding a lot of performance hazards. for instance the amount of work that each parallel task does is tricky to get right: if you dispatch too many small tasks you're going to have too much overhead with the tasks dispatching, and its better to process a bunch of consecutive data in a given task to better use the cache etc.
thread building blocks have generic algorithms like parallel_for that takes care of this kind of gory details for you (theres some reasonable default heuristics for that which you can tune if you want).

it also provides an efficient parallel memory allocator (traditional memory allocators tend to serialize allocations between threads so memory allocation can easily become a big point of contention), lock-free containers etc.

a cyberpunk goose
May 21, 2007

Zlodo posted:

have a look at intel's tbb library: https://www.threadingbuildingblocks.org/

owns

spongeh
Mar 22, 2009

BREADAGRAM OF PROTECTION
Python was one of the initial projects included in the Coverity Scan service, which enables the open source community to find and fix critical quality and security defects in their code. Since 2006, Python has achieved a defect density of .005 (or .005 defects per 1,000 lines of code) and has eliminated all high-risk defects in its codebase.

p-langs win again

stoutfish
Oct 8, 2012

by zen death robot
not much to fix when your lang is for babbys

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
it's called python because it's a hugbox for bad programmers

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

chumpchous posted:

it's called python because it's a hugbox for bad programmers

not surprising how popular it is at google

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

jooky posted:

shaggar??

I'm shaggar lite

Nomnom Cookie
Aug 30, 2009



spongeh posted:

Python was one of the initial projects included in the Coverity Scan service, which enables the open source community to find and fix critical quality and security defects in their code. Since 2006, Python has achieved a defect density of .005 (or .005 defects per 1,000 lines of code) and has eliminated all high-risk defects in its codebase.

p-langs win again

so coverity pays a dude to go through the cpython code and put #define COVERITY_IGNORE_THIS in the right places

Nomnom Cookie
Aug 30, 2009



otoh not too long ago ruby had an honest-to-god bug in Array's bounds checking. a p-lang that would let you smash the stack

then ruby-core hosed up fixing it lol

Bloody
Mar 3, 2013

c thread s: implemented some simple boost::threading in my thing. compiles but needs testing. gently caress thread pools, i keep track of my threads in a vector and throw out used ones when they're done. when each thread will be running for at least ten minutes of 100% cpu work i don't care about whatever that overhead might be.

now i have to think about how i get my program output out of these threads

gently caress

Bloody
Mar 3, 2013

oh i know instead of spamming poo poo to cout i will make a vector<vector<string> > and pass each thread its own vector<string> and then that thread will push_back instead of cout

Bloody
Mar 3, 2013

also the boost lib that apt-get installed is a fair bit older than the current release so now i am yak shaving to install the latest release

a cyberpunk goose
May 21, 2007

Bloody posted:

oh i know instead of spamming poo poo to cout i will make a vector<vector<string> > and pass each thread its own vector<string> and then that thread will push_back instead of cout

either use a premade thread safe fifo queue class thing or use mutexes smartly

weird
Jun 4, 2012

by zen death robot

lol

FamDav
Mar 29, 2008

Bloody posted:

c thread s: implemented some simple boost::threading in my thing. compiles but needs testing. gently caress thread pools, i keep track of my threads in a vector and throw out used ones when they're done. when each thread will be running for at least ten minutes of 100% cpu work i don't care about whatever that overhead might be.

now i have to think about how i get my program output out of these threads

gently caress

do you not have a c++11 enabled compiler or what

just split up your work, push back async calls to your work into a vector of futures, then wait on every future.

Nomnom Cookie
Aug 30, 2009



Bloody posted:

c thread s: implemented some simple boost::threading in my thing. compiles but needs testing. gently caress thread pools, i keep track of my threads in a vector and throw out used ones when they're done. when each thread will be running for at least ten minutes of 100% cpu work i don't care about whatever that overhead might be.

now i have to think about how i get my program output out of these threads

gently caress

put results in a queue. queues are so great for inter-thread communication, go hog wild with queues and pretend you're doing an erlang

and ya who cares if something is SO SLOOW ONO IT TAKES A MILLISEOND when you do it less than 10 times a second. thread pools are for stuff like I/O callbacks where starting a thread is a significant cost compared to the work ur doing

Nomnom Cookie
Aug 30, 2009



Mido posted:

either use a premade thread safe fifo queue class thing or use mutexes smartly

java provides java.util.concurrent.BlockingQueue and several implementations

Posting Principle
Dec 10, 2011

by Ralp

Bloody posted:

c thread s: implemented some simple boost::threading in my thing. compiles but needs testing. gently caress thread pools, i keep track of my threads in a vector and throw out used ones when they're done. when each thread will be running for at least ten minutes of 100% cpu work i don't care about whatever that overhead might be.

now i have to think about how i get my program output out of these threads

gently caress

Use futures

Nomnom Cookie
Aug 30, 2009



futures are dumb use promises

FamDav
Mar 29, 2008

Nomnom Cookie posted:

futures are dumb use promises

one of the rare blatantly wrong and uninformed posts in the pos

Posting Principle
Dec 10, 2011

by Ralp
In c++ futures and promises are just a distinction between the producer and the consumer of a value. Promises are one of the ways that you can write to a future

Brain Candy
May 18, 2006

Bloody posted:

also the boost lib that apt-get installed is a fair bit older than the current release so now i am yak shaving to install the latest release

boost releases every five seconds, I don't know what you were expecting

Nomnom Cookie
Aug 30, 2009



FamDav posted:

one of the rare blatantly wrong and uninformed posts in the pos

im studying for my Shaggar Certified Post Architect exam

Brain Candy
May 18, 2006

those who don't understand threadpools are condemned to reinvent them, poorly

MrMoo
Sep 14, 2000

Thread pools are just horrendous boiler plate above a decent message passing system. Just look what Microsoft did with the API launched in Vista:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686766(v=vs.85).aspx

I cannot believe anyone uses any of that. I already noted the timer API is actually broken when using NTP.

Brain Candy
May 18, 2006

MrMoo posted:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686766(v=vs.85).aspx

I cannot believe anyone uses any of that. I already noted the timer API is actually broken when using NTP.

those who don't understand threadpools are condemned to reinvent them, poorly

Nomnom Cookie
Aug 30, 2009



MrMoo posted:

Thread pools are just horrendous boiler plate above a decent message passing system. Just look what Microsoft did with the API launched in Vista:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686766(v=vs.85).aspx

I cannot believe anyone uses any of that. I already noted the timer API is actually broken when using NTP.

u mean timers firing incorrectly? what if you specify duration rather than a due time. thats really lol if they gently caress up durations but what can the system do when wall clock time changes, other than roll with the punches

MrMoo
Sep 14, 2000

Thread pools are also an anachronism to the cloud, I can't recall a single implementation that allows you to scale out across the network.

Brain Candy
May 18, 2006

C++ code:
VOID WINAPI SubmitThreadpoolWork(
  _Inout_  PTP_WORK pwk
);
:stare:

MrMoo
Sep 14, 2000

Nomnom Cookie posted:

u mean timers firing incorrectly? what if you specify duration rather than a due time. thats really lol if they gently caress up durations but what can the system do when wall clock time changes, other than roll with the punches

Almost any timer mechanism:

code:
while (true)
  do something
  sleep until (last timestamp + duration)
Microsoft thread pools, which have explicit "support" for very long running tasks and high accuracy - Windows will spin a thread 100% waiting for the due time:

code:
while(true)
  do something
  sleep (duration)
There is absolutely no point using a fancy high cost thread pool timer if you are going to gently caress up the basics of timing.

Adbot
ADBOT LOVES YOU

Brain Candy
May 18, 2006

i don't disagree the message passing is for cool people. but if you doing embarrassing parallel things on one machine you shouldn't be making artisanal bespoke threads if you have an alternative.

  • Locked thread