|
Eddy Vluggen wrote: any communication using TCP, or any disk-operation, I start a backgroundworker.
That's an I/O bound thread, not a CPU bound thread. I'm purely talking about CPU bound worker threads here.
I/O bound threads follow different rules because they spend most of their time asleep waiting for input.
ETA: I think the context got lost in the fray, but in OP, I'm talking about CPU bound worker threads. I'm not talking about I/O bound threads. You may have many more of those than you have cores. The threadpool keeps a separate pool for those.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: That's an I/O bound thread, not a CPU bound thread. I'm purely talking about CPU bound worker threads here.
I/O bound threads follow different rules because they spend most of their time asleep waiting for input. I don't tell the BGW what kind of thread it is (except that it runs in the background, so shouldn't stop a shutdown of Windows). Not sure the ThreadPool knows that difference either.
Unless you talk about design; if you only mean generic threads meant to do processing and nothing else, then yes. Not my forte to do threads that only process (like a parser, or an Isapi-worker without UI). I just see the term "threads" and go "I create a shitload of them". Lots of apps do (some excessive, my dear Chrome), and they have little cost. Can't imagine creating over 2k threads in Delphi, just to pool them "in case".
Threading is exotic to most, and I'm talking to someone who knows his fibers (without fiberpool). For processing, my main focus is on giving the user feedback, and a time-guestimate. (Number of items existing-number of items processed) per second. So clients like me as much as they like the estimate of the copy-dialogue of Explorer.
So, this thread doesn't involve me at all, even despite it being my favorite subject?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The .NET threadpool class at least, does indeed know the difference. It maintains two pools even - one for CPU bound threads, and one for IO bound threads. I'm not sure your background worker would know the difference, but if it was designed for just one, I'd bet it was designed primarily for I/O bound ops.
CPU bound ops just aren't as common I think?, not that they are uncommon. It's just weird that the .NET threadpool sets the available and max for CPU bound threads to 2047 per process. That's not I/O threads - which as i said, have their own pool
A thread doesn't know if it's I/O bound or CPU bound. How it works is what makes it one or the other. It would have to understand its own code to know what it was. But basically I/O bound threads sleep like cats. The wake up when there's reason
But the reason to treat them separate at least in the .NET realm is that the tasks are set up to be optimized for one style over another and giving it the hint as to what kind of work it's doing helps for performance. The other issue is a design one. Again, CPU bound work needs hardware to run on or it's just mashing the scheduler if it has to share time. That's fine, to a degree, but CPU bound threads should be considered carefully in an application.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: It maintains two pools even It's not named "TwoPools". And the BGW will prolly default to IO, since that's its most used pattern. Not that much people doing pure processing of data.
honey the codewitch wrote: A thread doesn't know if it's I/O bound or CPU bound. So how would the framework know? For most of the crap I spawn it wouldn't make much difference, but it sounds like it is important to distinguish between them.
honey the codewitch wrote: But basically I/O bound threads sleep like cats 36 hrs per 24 hrs day. Not sure if Goedzo is awake when eating.
honey the codewitch wrote: but CPU bound threads should be considered carefully in an application. The stuff drivers are made of? I don't know the difference; there's a pool and I draw upon it. If you need an article-idea, then this would confuse the hell out of people and get you some more downvotes
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: It's not named "TwoPools".
What's in a name? Try calling GetMaxThreads() or GetAvailableThreads() and they each return two values.
Eddy Vluggen wrote: So how would the framework know?
Because you tell it when you call QueueUserWorkItem() you're using a CPU bound thread - or at least one from the pool intended for that. When you use any of the items that use IO completion ports (like file or socket operations) .NET runs those on I/O threads for you.
multithreading - Simple description of worker and I/O threads in .NET - Stack Overflow[^]
Maybe that will help.
Eddy Vluggen wrote: The stuff drivers are made of?
No just the stuff you're running the processor ragged with when you call QueueUserWorkItem() . I'm not counting threads that spend most of their time sleeping.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: What's in a name? Try calling GetMaxThreads() or GetAvailableThreads() and they each return two values. From experimenting, they look the same; the max is always available. Would be sick if max equals allocated, but docs don't give a hint of that.
honey the codewitch wrote: Because you tell it when you call QueueUserWorkItem() I just create new BGW.
honey the codewitch wrote: Maybe that will help. I'll queue it, currently sleepdrunk. Third day, so not a problem yet. Not much hallucinations until day five.
"Even this, shall pass away". Thread carefully in answering.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: I just create new BGW.
I've never used BGW to be honest. I just call Task.Run() from my code, but i'm guessing it delegates to QueueUserWorkItem() , or Task.Run()/TaskFactory.StartNew()
In which case I was wrong before in guessing it was I/O thread - don't know why I thought that (i think i had isapi threadpools on the brain) but...
Eddy Vluggen wrote: I'll queue it, currently sleepdrunk.
I'm sleep deprived. Not quite into a several day stretch yet but I'm a little wobbly.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: I've never used BGW to be honest. I just call Task.Run() from my code, but i'm guessing it delegates to QueueUserWorkItem() , or Task.Run()/TaskFactory.StartNew()
In which case I was wrong before in guessing it was I/O thread - don't know why I thought that (i think i had isapi threadpools on the brain) but... BGW is a simple thread-wrapper for WinForms, and it has some simple methods for giving progress without mucking with critical sections or synchronizing variables. Saves some time if you do a task that requires both a thread and progress on the UI, defining an event for updates and stuff. Its mainly useful in UI-apps, and is a bit useless outside of that. So, shouldn't exist in a parser
honey the codewitch wrote: I'm sleep deprived. Not quite into a several day stretch yet but I'm a little wobbly. First day doesn't give me problems either; first day is enjoyable even. Day three I sound a bit drunk and slur speech, but day five I often see and hear things that aren't there. Day five is usually my worst day, and I often do anything to sleep at that point. Lots of alcohol and man sleeps, even if the sleeping pills don't work. I have no memories of reaching day six, but that doesn't mean much. The brain stops recording at day three.
Day four and five I often don't remember, or just parts of it as if it were a dream. Even going so far as becoming aggressive (I'm a pacifist and don't believe in violence). At that point, getting sleep means having a bad morning, being told what I did or said the day before.
If you sleep-deprived, go see a doctor and ask for bloody sleeping pills; you NEED them. Draw your line at day three. Anything beyond that eats your sanity and causes permanent damage. And take that warning seriously; on day three, you stop being honey and start being vinegar. Day four and five are simply damaging, both your relations and your brain. Never had a productive day beyond day three. Day four and five are mostly a haze, and cause (permanent) damage to the brain.
Today is day four again. Happens twice a month these days. A few more years, and I'll be talking to hamsters that other people can't see.
So.. if you having trouble getting sleep, see a doctor. If the doctor says "no", find another doctor. Simple as that. Find help or go a bit crazy. There's no middle ground. (And seemed more important than BGW's and threading, so hence the change in subject)
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Oh my gosh. I'm sorry you struggle with that. Until a few months ago I could not get more than 4 hours a night and sometimes i had to do with 2. That was for a few years, but now lately I've been sleeping too much. It's part of being schizoaffective so sleeping pills don't work.
Still, if i was going through what you were I'd try anything. I'm sorry to hear that.
Real programmers use butterflies
|
|
|
|
|
You are on the verge of struggling with the same; I may be your future. And your posts says you're not sleeping. If you close to schizoid, you need your sleep more than anyone.
Schizotypical eh? No clear diagnosis then. You just "weird" like me
You're in your thirties?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I'm schizoaffective, bipolar type. The diagnosis is relatively rare, and difficult, because it has symptoms of schizophrenia and bipolar disorder, but worse, presents very differently in different people.
For example, I get mixed episodes and delusional thinking but I don't hallucinate except when I'm manic - not a schizophrenic episode. I get manic though like a typical person with bipolar 1. My schizophrenia-like symptoms however, are subdued in some ways and pronounced in others. Some people with it lean more heavily on the bipolar end of things, and i lean more on the schizophrenic end of things in terms of symptoms these days, but that has changed over the course of my life.
Short answer is it's complicated. I prefer to consider myself simply "mad".
I'm not shy about it, but I have my opinions on the subject as someone living with it.
ETA: Early forties
Real programmers use butterflies
modified 19-Jul-20 22:36pm.
|
|
|
|
|
honey the codewitch wrote: Short answer is it's complicated. I prefer to consider myself simply "mad". If you not normal then mad is the default it seems. If man ever evolves, we'd label those mad too, because they not like us.
honey the codewitch wrote: 'm not shy about it, but I have my opinions on the subject as someone living with it. Glad you're open about it; I still trying to hide and not really working out.
honey the codewitch wrote: For example, I get mixed episodes and delusional thinking but I don't hallucinate except when I'm manic - not a schizophrenic episode. I get manic though like a typical person with bipolar 1. My schizophrenia-like symptoms however, are subdued in some ways and pronounced in others. Some people with it lean more heavily on the bipolar end of things, and i lean more on the schizophrenic end of things in terms of symptoms these days, but that has changed over the course of my life. I had some "incidents" which the doctor calls "episodes". Not enough symptoms for a clear diagnosis, and since no criminal record, so no priority.
Maybe too personal, but how did your environment react? Do you look forward to family meals?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I don't have a good relationship with my adoptive family. We never bonded in the first place (it's difficult for me to) and had a rocky time of it while I was growing up, including me spending a couple years as a homeless teen rather than live there.
My biological family and I get by, but then they're really understanding - mental illness runs in the family on my mom's side. Schizophrenia, and bipolar that i know of, probably a couple of schizoaffective cousins AFAIK.
My hubby on the other hand, has not only known since we were teens that something was up with me, he married me anyway sucker!
He's really understanding and helpful. I also feel better about it knowing he knew what he was getting into.
Real programmers use butterflies
|
|
|
|
|
I should add, it became easier when I stopped trying to hide it I think. There's a stigma around it but I care less about what other people think about me than what I think about me, and trying to put up a false front is exhausting. Besides, you can spot me from a mile off. I'm a very pronounced weirdo so my madness is kind of obvious to begin with. My situation may not be like yours, not saying it is. Just that I found it easier when i stopped hiding it.
I'm not sure what type of episodes you had but if you go manic it gets easier and easier to channel that into incredible creative energy if you practice.
Good luck to you.
And thanks for sharing.
Real programmers use butterflies
|
|
|
|
|
Yeah, 640 threads out of be enough for anybody.
Outside of a dog, a book is a man's best friend; inside of a dog, it's too dark to read. -- Groucho Marx
|
|
|
|
|
Let's be honest, Chuck Norris is just a dumb actor.
If he were really that good he'd come over to my house and smack my head on the keyboakdhca;lea;3r#F$@#$UDsCjj3822fwc@#@F:K@"w0f8232feQWJEkqqqq@HLEnl<>!C!j1cjo
|
|
|
|
|
Alas poor Sander, we knew him well.
No flowers - donations to support his new cat, please.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
|
It sounds as though good music was smoking tobacco and now it's good grimey music.
|
|
|
|
|
You just described their entire artistic aesthetic.
Real programmers use butterflies
|
|
|
|
|
WTH was that? At first I thought my speakers were blown. You actually find that entertaining?
"Go forth into the source" - Neal Morse
|
|
|
|
|
|
|
|