CPU Clock Speed ∝ IPS?

This is a discussion on CPU Clock Speed ∝ IPS? within the Tech Board forums, part of the Community Boards category; Hello! It's been over two years since I last visited these boards. I have to say, it's good to see ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    183

    CPU Clock Speed ∝ IPS?

    Hello!

    It's been over two years since I last visited these boards. I have to say, it's good to see some old faces/avatars again!
    Code:
    while(nostalgic())
    {RefrainFromPrattlingOn();}
    As you have probably gathered from the title, I have a few questions about CPUs. Would anyone be so kind as to help me? Here's the situation:

    After having used my old laptop for a good five years so, I deemed it necessary to purchase a new one. It is a mid-to-high spec laptop: i7 Quad Core CPU at 2.70GHz (3.70GHz Max), 8GB RAM and I am running Windows 7 (64-bit). This is, theoretically, a huge improvement on my old system (Intel Core 2 Duo at 2.00GHz, 3GB RAM and running Vista). Due to the greater clock speed of the i7, I assumed that the newer system would run any given application faster than my old system, even if both laptops were only using one core. Apparently, I was mistaken.

    A while ago I wrote a program that simulated the algorithm involved in a brute force attack. (I wrote this as a programming exercise for myself and, also, to prove to a friend exactly how infeasible brute force attacks are on your average computer.) Anyway, I thought I would use this simple program as a speed test for the two systems. I configured the program to cycle through numerical characters only and print the current value (starting at 0) after each iteration. The program was executed on both laptops at the same time.

    Now, I'm aware that this, as a speed test, is rather primitive. However, it should give a general idea which system is faster, should it not? Turns out that the newer system completed loop iterations at about half the speed of the older system. Is it just me, or is that a little odd?

    Anyway, this isn't a huge deal. I am just kind of curious about what is causing the speed bottleneck. I know that there are many contributing factors, but if any theorys jump out at you guys, then please let me know! There are some extremely bright and helpful people on these boards; I'm sure any theories you can come up with will be better than mine

    Thank you for your time!
    Necrofear

    EDIT: Also, apologies about the length of this post!

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    847
    Quote Originally Posted by Necrofear View Post
    I am just kind of curious about what is causing the speed bottleneck.
    RAM speed is the obvious bottleneck, especially if you need large tables for the brute-forcing. In general, RAM speeds haven't gotten much better in the last few years for desktops and laptops, they're only gotten bigger and cheaper. Faster RAM is available, but costs more (and requires motherboard support, too).

    Did you compile the new code as 64-bit? Unless you take care, it tends to use almost twice the memory 32-bit code used, and when memory limited, it can easily make a 64-bit program slower than the equivalent 32-bit one.

    If you do lots of output using the standard I/O libraries, I've seen mentions that especially VS2010 has very slow implementations of the basic functions. And your new laptop might have a slower disk, too. Better check you are not I/O-bottlenecked; just comment all output from both programs, and recompare.

    I don't know if the OS has any impact on this, since I don't use Windows. But, since it is a laptop, it might keeps the CPU at a lower clock rate to save power. Did you test the laptop while plugged in to mains power?

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Assuming it doesn't access disk and doesn't do much printing, the most likely culprit is RAM. RAM speed is determined by many things (clock speed, latency, organization), and the easiest way is to run something like memtest86+ to measure memory throughput.

    It could also be something like a change in CPU cache replacement policy or branch predictor design change that makes it slower at running your specific sequence of instructions.

    Also, are they running the same binary?

    What does your inner loop look like?

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    2,454
    another thing you might do is to disable hyperthreading. in an intel hyperthreading CPU, each core pretends that it is actually two, and each logical core is less than half as powerful as the whole physical core. it works out great for desktop users, but for cpu-intensive tasks, it often results in poorer performance. you should be able to find this setting in the bios setup program.
    Code:
    namespace life
    {
        const bool change = true;
    }

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    another thing you might do is to disable hyperthreading. in an intel hyperthreading CPU, each core pretends that it is actually two, and each logical core is less than half as powerful as the whole physical core. it works out great for desktop users, but for cpu-intensive tasks, it often results in poorer performance. you should be able to find this setting in the bios setup program.
    That is not entirely accurate.

    Hyperthreading = duplicating the whole CPU core except ALU (2 register files, 2 instruction decoders, etc). What that means is, only one of the 2 "virtual cores" can do active computation. However, if one core is stalled by a cache miss, another thread can run on the other virtual core to do computations (on registers, without accessing memory).

    It's basically a way for you to use the idle parts of a CPU when a thread is being held up by a cache miss.

    If you only have one active thread, it shouldn't matter if you have HT enabled or not, as long as you have a HT-aware scheduler that tries to distribute work evenly among physical cores (all Windows and Linux schedulers from the past 10 years are HT-aware).

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Thank you all for the quick responses!

    To answer Cyberfish and Nominal's question, both systems are running the exact same binary. It was compiled as a 32-bit application on the old system using an ancient IDE (Dev C++ 4.9.9.2., I believe), and does not access the disk at all during each iteration of the main loop. Unless I'm mistaken, running the exact same binary should eliminate any speed differences that might occur due to slow output implementations or high memory usage. It is, however a multithreaded program; I'm running a second thread to detect and process key presses (via getch() from conio.h, if that matters), so maybe the hyperthreading is worth looking at?

    I have taken a look at the RAM of both laptops, as suggested. The old system is using Toshiba DDR2 RAM with a quoted speed of 800MHz. The new system: Samsung DDR3 quoted at 1600MHz. My knowledge of RAM, or indeed, computer hardware, is rather limited, but am I right in thinking that the Samsung RAM should at least be able to match the performance of the Toshiba RAM? If this is not necessarily the case, however, I shall run memtest86+ as suggested by Cyberfish.

    Cheers again, for all of your assistance!

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    Silly question, perhaps: but is program maximizing the cpu? If you have a i7 quad core, then you should see cpu usage go to 12.5% if your program is eating up one core. Higher if you are multithreading.
    Generally, clock speed is indeed proportional to ips, but architecture is a critical component, too. Sometimes architecture changes can make programs that ran faster before run slower, because generally cpu manufacturers use average cpu (not worst casr cpu) performance as metric for measuring speedup which guides their efforts on the architecture.
    Though I find it a little hard to believe that your program runs half as fast. It isn't running in debug mode either, is it?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Oct 2011
    Posts
    847
    Did you run the test with AC power connected?

    You might get one of those utilities that graph both the CPU usage and the CPU frequency, as changing the CPU frequency is the most common way to regulate CPU power consumption. I suspect your program runs with a lowered CPU frequency on the new laptop, to save power. It would certainly explain the results... It could be that from the OS's point of view, your one process is not CPU-consuming enough to warrant a high CPU frequency.

    (Sorry; I know exactly how to measure and control this in Linux, but like I said, I haven't used Windows in years.)

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Thank you both for the further replies; they have both been extremely helpful! The program is not running in debug mode, Elysia, but your previous, not-so-silly question has revealed to me that I may have made an incorrect assumption whilst testing the laptops. As Nominal indicated, Windows OSs apparently underclock the systems CPU whilst running on battery power. Makes sense. However, I failed to realize that the extent to which the CPU is underclocked may vary between Operating Systems (i.e. between Vista and 7).

    With the AC power connected to both systems, I ran the program again. The CPU usages, on battery power, for the newer and older systems respectively, were approximately 5% and 80%. When plugged into the mains, however, the newer system's usage jumped up to 10-11% while the older system's usage remained at 80%. I know that the i7 quads are relatively powerful processors, and I now know that Windows will try to minimize CPU usage on battery to try to save power... but surely, by default, Windows 7 should not be that much more conservative than Vista?

    Thanks again!

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    Quote Originally Posted by Necrofear View Post
    With the AC power connected to both systems, I ran the program again. The CPU usages, on battery power, for the newer and older systems respectively, were approximately 5% and 80%. When plugged into the mains, however, the newer system's usage jumped up to 10-11% while the older system's usage remained at 80%. I know that the i7 quads are relatively powerful processors, and I now know that Windows will try to minimize CPU usage on battery to try to save power... but surely, by default, Windows 7 should not be that much more conservative than Vista?
    You can change how conservative it is in power settings. You can specify min and max in power options -> change plan settings -> change advanced settings -> processor power management. It also depends on the drivers installed for your systems. More than likely, the drivers and any manufacturer software are responsible for the throttling you see.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Quote Originally Posted by Elysia View Post
    You can change how conservative it is in power settings. You can specify min and max in power options -> change plan settings -> change advanced settings -> processor power management.
    Ahh yes, so you can! I actually had no idea that the user had any real control over processing power. To be honest, before reading some of the replies in this thread, I was unsure about whether or not the Operating System itself had any real control or not; I thought it was all handled by the system's BIOS. So if I were to increase the minimum CPU usage whilst on battery from 5% to 10%, then this should increase the processing speed, whilst effectively halving my battery life, right?

  12. #12
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    No, it won't. Processing power is proportional to battery life, but the scale isn't linear.
    The BIOS handles very low-level stuff (think currents and voltages) and especially things that must run when the OS isn't running. But the OS can control most things such as speeds and yes, even voltages.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Ahh, that's useful information; thank you Elysia!

    Cheers to everyone who contributed to this thread. I can't believe I was stumped by something as simple as power management.
    Occam's Razor strikes again, eh?

  14. #14
    Registered User
    Join Date
    Oct 2006
    Posts
    2,454
    Quote Originally Posted by Elysia View Post
    Processing power is proportional to battery life, but the scale isn't linear.
    a minor nit to pick, but something that is proportional is, by definition, a linear relationship, at least mathematically speaking.

    in any case, batteries behave differently, depending on the load placed on them. higher loads (more current) will heat up a battery faster, and more heat = shorter life. different battery technologies behave differently as well. Li-Ion has different characteristics from Ni-Cd, and so on.
    Code:
    namespace life
    {
        const bool change = true;
    }

  15. #15
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    Quote Originally Posted by Elkvis View Post
    a minor nit to pick, but something that is proportional is, by definition, a linear relationship, at least mathematically speaking.
    Right you are. I don't know the right term, though.

    in any case, batteries behave differently, depending on the load placed on them. higher loads (more current) will heat up a battery faster, and more heat = shorter life. different battery technologies behave differently as well. Li-Ion has different characteristics from Ni-Cd, and so on.
    Processor power consumption don't behave linearly, either.
    Actually, it's like P = CfV^2 where P is power, C is capacitance, f is frequency and V is voltage. But if you increase frequency, you must also increase voltage or risk metastability.
    Unfortunately, the reverse is not equally true. There is a point where you can't lower the voltage, so that when you lower the frequency, the voltage is still the same.
    Then there's all the complicated internal power management built-in into cpus these days. Since power management typically changes frequency, and indirectly, voltage, it's hard to say how exactly changing the values in the power management will affect power consumption.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. #if !CLOCK
    By rsockey in forum C Programming
    Replies: 4
    Last Post: 11-10-2009, 11:51 AM
  2. Speed of pointers vs. speed of arrays/structs
    By Kempelen in forum C Programming
    Replies: 32
    Last Post: 06-27-2008, 10:16 AM
  3. High Speed IRQ Timer/Clock in C
    By andrewwan1980 in forum C Programming
    Replies: 7
    Last Post: 01-16-2008, 04:21 AM
  4. clock
    By makveli in forum C++ Programming
    Replies: 2
    Last Post: 11-13-2003, 02:35 PM
  5. VB Speed compared to VC++ Speed.
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 05-19-2002, 04:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21