LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-18-2014, 07:32 AM   #1
CrazyCatLover
Member
 
Registered: Jan 2014
Posts: 39

Rep: Reputation: Disabled
Cores and Threads


Hi,

Intel® Core™ i7-4771 Processor
http://ark.intel.com/products/77656
For info, using this processor, it is mentioned to have 4 cores and 8 threads.
1. So 4 x 8 should be 32 right? Cause under my system monitor, i can only see 8 CPU, where are the rest 24? Using Debian system monitor, should be same for everyone.
2. Also when i typed pstree, i counted more than 32 threads, how is this possible? Is it only 32 process running at 1 time and rest are zombie?
Tks for reading.
 
Old 11-18-2014, 07:51 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Remember that, when a process or thread is said to be "running," it is time-slicing among the various available CPU(s). This status simply means that it is eligible to need CPU-time to be given to it ... that it is not blocked for any reason (waiting for an I/O operation to complete).

Nearly all workloads are "I/O-bound." They spend a minuscule amount of time consuming CPU resources before they initiate an I/O operation and then are blocked waiting for it to complete. So, the "ruling constraint" that determines how fast they do their job is not the speed nor the number of CPUs (cores), but the ability of the underlying hardware to perform I/O (and the availability of RAM, which leads to paging I/O...).

Basically, the workload, whatever it is, is ruled by mechanical speeds, not on-board silicon speeds.

Threading, properly deployed, allows the CPU to "keep busy" because, when one thread/process becomes blocked, there are still other runnable threads/processes that it can immediately switch to. The CPU(s) will still spend more than 90% of their time waiting, in most cases, but the number is still smaller than it otherwise would be.

"Multiple cores" are really only useful when you have a substantial CPU-bound workload that is capable of using the core's onboard caches [i](remember, multiple cores all compete for one memory-bus) ... a workload that is consistently able to consume full time-slices without becoming blocked for I/O ... on a system that can handle the amount of heat that such intense activities will generate.

Last edited by sundialsvcs; 11-18-2014 at 07:53 AM.
 
Old 11-18-2014, 09:19 AM   #3
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Your CPU has 4 physical cores. Each core can run 2 threads (due to Intel® Hyper-Threading Technology).
Thats why you can observe 8 threads, not 32.
System monitor shows 8 virtual CPUs, one per each thread.
Why you can observe more than 32 processes in pstree output? Because these threads doesn't run simultaneously. Tasks sheduler decides which task will be executed at moment depending on their priority.

Last edited by Teufel; 11-18-2014 at 09:28 AM.
 
Old 11-18-2014, 11:26 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
There is a certain amount of confusion over the two different meanings of "thread". The hardware meaning in Intel's "hyperthreading" terminology vs. the usual software meaning.

Quote:
Originally Posted by CrazyCatLover View Post
For info, using this processor, it is mentioned to have 4 cores and 8 threads.
1. So 4 x 8 should be 32 right?
They mean 4 cores per CPU package and 8 threads per CPU package, not 8 threads per core.

You have only one CPU package, so you have 8 total hardware threads.

Quote:
2. Also when i typed pstree, i counted more than 32 threads, how is this possible? Is it only 32 process running at 1 time and rest are zombie?
At most 8 (on your system) software threads are using hardware threads at any instant. Most software threads are doing I/O waits at any given instant. Software threads are distributed among hardware threads (in a manner that I don't really understand). Within those assigned to the same hardware thread, if more than one wants CPU time at the same time, the hardware thread is time sliced among them. If one hardware thread is under loaded while another is overloaded, software threads might get moved from the overloaded hardware thread to the under loaded one. That is the mechanism that I don't actually understand.

Last edited by johnsfine; 11-18-2014 at 11:27 AM.
 
1 members found this post helpful.
Old 11-19-2014, 06:27 AM   #5
CrazyCatLover
Member
 
Registered: Jan 2014
Posts: 39

Original Poster
Rep: Reputation: Disabled
Ok, i sort of get it, some other questions, lets say i have a software thread called iceweasel. My iceweasel sort of slows down whenever i open too many stuff. How do i say it, the computer has a delay in reaction. I notice that my first cpu tends to have high activity 30%-80%, while the rest only has 1-2% just roughly value.
Can it be separated into 2 different hardware threads? If i can separate it, wont it be a lot faster? How do i do it in the most easiest way?

ps. I check and debian doesnt seem to be in the list of optimised os for Hyperthread technology. The stuff is proprietary and debian doesnt like proprietary. Could this be the problem?

https://software.intel.com/en-us/art...-ht-technology
http://en.wikipedia.org/wiki/Hyper-threading
 
Old 11-19-2014, 07:12 AM   #6
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Iceweasel has a single-process architecture. It leads (e.g. when opening a lots of pages) to high CPU usage for one of cores whilst other cores are idle. In other words, iceweasel's code not optimized for running in few threads.
 
Old 11-19-2014, 07:23 AM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by CrazyCatLover View Post
My iceweasel sort of slows down whenever i open too many stuff. How do i say it, the computer has a delay in reaction. I notice that my first cpu tends to have high activity 30%-80%, while the rest only has 1-2% just roughly value.
Can it be separated into 2 different hardware threads? If i can separate it, wont it be a lot faster?
I think iceweasel is not slowing down due to CPU load, but due to some other reason. That might be disk I/O or it might be waiting for responses from the net. I have noticed that when Firefox is loading from multiple sources at once, it seems unable to respond to incoming packets effectively. It seems to wait for some expected packets that are externally delayed, while failing to process other packets that have arrived.

Most programs are single threaded, so even if they are limited by CPU (rather than disk or net) they still only use at most one hardware thread.
 
Old 11-19-2014, 04:04 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
"optimised os for Hyperthread technology."

Every modern OS has methods to try to best use HT.

A core i7 is a fantastic product. It will run Debian just fine in no uncertain terms.

As to what is going on, we'd need to know what pages, how many of them, what resources the pages require, what resources your system is using during this so called high load state. I'd bet you have more than a few cores just sitting around.

Network crc can consume a lot of cpu if not offloaded to nic.

Last edited by jefro; 11-19-2014 at 04:06 PM.
 
Old 11-20-2014, 05:35 AM   #9
CrazyCatLover
Member
 
Registered: Jan 2014
Posts: 39

Original Poster
Rep: Reputation: Disabled
Hi,
Here is a sample in iceweasel
youtube song on auto repeat, lecture, pdf notes opened in iceweasel, google search results
usually total 6 to 7 webpages
running add on gnome shell, youtube replay, ghostery, adblock, lightbeam the usual.
have gnash but i switch off as it doesnt work with youtube replay button....
So, see any problems?
 
Old 11-20-2014, 05:44 AM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
When you say that the computer has a human-visible "delayed reaction," this, in and of itself, is a direct indication that the I/O queues are piling-up. You'll probably see that the disk-drive activity light is flashing quite steadily.

If this is accompanied by idle processes or threads, this is a further indication. If there were anything for them to be doing, then they would be doing it.

"Hyperthreading," and "cores" in general, are actually quite over-rated. The hardware designers are reaching the current limits of how "small == fast" the technology can be, so they are duplicating copies of it across the chip and calling each one a "core." Trouble is, all of them share the same "pathway to the outside world," and it's a one-lane road. There's dispatching of the workload among the cores, yes, but that's still mostly to get "great benchmarks" for the chip itself, which sells more chips.

Programs such as your "iceweasel" are often built single-threaded because they can work very efficiently using a simple select() polling-loop. There's almost nothing for the CPU to do anyhow. You can always run more than one copy of the thing, in two different terminal sessions, but you will most likely find that the completion-rate is not doubled; it might actually be reduced. C'est la guerre . . .
 
Old 11-20-2014, 02:34 PM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by sundialsvcs View Post
When you say that the computer has a human-visible "delayed reaction," this, in and of itself, is a direct indication that the I/O queues are piling-up. You'll probably see that the disk-drive activity light is flashing quite steadily.

If this is accompanied by idle processes or threads, this is a further indication. If there were anything for them to be doing, then they would be doing it.

"Hyperthreading," and "cores" in general, are actually quite over-rated. The hardware designers are reaching the current limits of how "small == fast" the technology can be, so they are duplicating copies of it across the chip and calling each one a "core." Trouble is, all of them share the same "pathway to the outside world," and it's a one-lane road. There's dispatching of the workload among the cores, yes, but that's still mostly to get "great benchmarks" for the chip itself, which sells more chips.

Programs such as your "iceweasel" are often built single-threaded because they can work very efficiently using a simple select() polling-loop. There's almost nothing for the CPU to do anyhow. You can always run more than one copy of the thing, in two different terminal sessions, but you will most likely find that the completion-rate is not doubled; it might actually be reduced. C'est la guerre . . .
This post is an oversimplification of the problem, and is quite dismissive of the advantage you get from having multiple cores. Just because some processes can't make use of them doesn't mean they are "over-rated".

Every process has a bottleneck (otherwise they would all run instantly). For many processes that bottleneck is the speed of one CPU core, for others it's the total processing power of all CPU cores, for others it's the memory bandwidth, and for others still it's the disk I/O speed. If you want the process to run faster, you need to fix (or at least improve) its bottleneck. Yes, if a process's bottleneck is the disk I/O speed, then throwing more or faster CPU cores at it will accomplish nothing, but that's simply because they're not addressing the issue, not because they're "over-rated".

The OP needs to find what is holding back his system and address that. Based on this comment:
Quote:
My iceweasel sort of slows down whenever i open too many stuff. How do i say it, the computer has a delay in reaction. I notice that my first cpu tends to have high activity 30%-80%, while the rest only has 1-2% just roughly value.
His problem is probably not CPU-related, so now it's time to figure out what is the cause of the problem.

So, OP, now it's time for you to fill us in on everything else about your system. Memory capacity, speed and usage, details about your disk(s) and what it/they are being used for (capacity, available space, speed, etc.).

Last edited by suicidaleggroll; 11-20-2014 at 02:35 PM.
 
Old 11-20-2014, 09:03 PM   #12
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
I did mean it to be a simplification, although not an oversimplification.
 
Old 11-20-2014, 09:48 PM   #13
CrazyCatLover
Member
 
Registered: Jan 2014
Posts: 39

Original Poster
Rep: Reputation: Disabled
Hmm it cant be hardware right, pc less than a year. Intel Core i7 3.5GHZ, Ram 8 GB, Hard disk 2 TB shared with windows. I gave roughly 500GB to debian. Data from "top" shows I only used around 1.5GB ram. I do suspect something, my graphics card is AMD Radeon. Works fine on windows. For Linux, I am using the amd catalyst version, yes I could use the free radeon version but colour and stuff is not as good, and could not fully load gnome, some features will be missing. The amd catalyst version has some problem too, sometimes like maybe 10% of the time when I open debian , it doesn't load into gnome at all, what appears is black screen and lines of words and numbers which goes on and on, although it usually solves itself when I press restart button 2 or 3 times, so its better than open source version which is why I use it. I check debian website and it doesn't have rc bugs so yep plus I dunno how to fix anyway so can only wait. If it gets into gnome, every program works like it should be, so I dunno if it may or may not be related?
 
Old 11-20-2014, 09:57 PM   #14
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
That system ought to work great. Possible config issues, bios, heat maybe throttling.

Maybe a better resource display may lead to issues.

I'll ask a dumb question here too. You do have the 64 bit version installed?

Last edited by jefro; 11-20-2014 at 09:58 PM.
 
Old 11-21-2014, 12:03 AM   #15
CrazyCatLover
Member
 
Registered: Jan 2014
Posts: 39

Original Poster
Rep: Reputation: Disabled
Yep, installed the AMD64 version, I don't use bios, I use UEFI, other than hard disc space of 500 GB, other configuration and stuff all done by debian, I default on everything given by debian installer, so I assume configuration should be right.
I have heat monitoring on my windows side, it has never flag anything, I assume heat on linux should be ok too. The delay stuff never appeared on windows side at all unless I just log in and suddenly click a lot, but everything is always up in 5 secs or less.



I will make it as solved since my original question is already answered. Tks a lot.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
AMD Cores/Threads/Virtual Cores dman777 Linux - Hardware 2 05-07-2013 02:04 AM
Can processes/threads move between cores? DavidA Programming 4 08-09-2011 10:10 AM
[SOLVED] SMP kernel not seeing multiple cores/threads for Intel Core i7 870 processor honnefinger Linux - Kernel 10 04-18-2011 11:55 PM
thread scheduling. is it guaranteed that kernel will run threads on all cores? anilp Linux - Kernel 1 01-26-2011 02:30 PM
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 08:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration