Shop OBEX P1 Docs P2 Docs Learn Events
Code optimization vs hardware lifespan — Parallax Forums

Code optimization vs hardware lifespan

W9GFOW9GFO Posts: 4,010
edited 2009-05-03 00:52 in Propeller 1
I've been wondering how important it is to make nice clean code. Not in terms of readability or ease for others to understand but in terms of being nice to the hardware. After all there are only a finite number of times that you can flip a bit, only so many electrons that can pass through a semiconductor before it fails right?

Suppose two cases. One chip running a couple lines of code to toggle an LED, the other running an absolute mess of code that invokes all eight cogs in a Rube Goldberg fashion using every last bit of processing power and memory space available - yet accomplishes the same simple goal of toggling an LED.

Does it make any difference? Would we have one happy chip with the other chip begrudged at all the extra work?

Reasonably, I would think that the chip running the clean code would outlast the other just because there are so many things happening over and over again that the likelihood of a failure would have to increase.

Rich H

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-02 03:49
    The only way you need to be nice to the hardware is not to stress it with too high a voltage or too much current. It won't work if you flog the electrons to move too quickly ... they get tired and go on strike.

    EEPROMs and similar devices have lifetimes in terms of numbers of write / erase cycles, but that's because you're trying to trap electrons within an insulating oxide layer and there's a finite possibility that they'll get stuck there. If the memory goes through too many write cycles, there's a high probability that too many will get stuck over time to be able to properly erase that bit.

    Logic chips break down from too high a voltage which destroys the thin gate oxide at some weak point on the chip or the current carried by a conductor is too high and the electron flow itself carries along metal atoms a short distance and eventually conductors break (wear away). It's kind of like a fast creek washing the pebbles lining the creak downstream a little way exposing the underlying dirt or rock.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2009-05-02 05:21
    As far as I know, the only chips that "wear out" are flash ram and eeprom, and electroytics that are highly stressed eg in switching power supplies. Any other sorts of circuits, from transistors up to ICs should run forever. Or until they are made obsolete by a faster/cheaper/smaller IC. Whichever happens sooner. You can flip a line up and down 4 billion times a second and it won't wear out. And if you have an application where you want mass storage that doesn't wear out, use a SRAM.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-02 05:25
    John Keats' line, "A thing of beauty is a joy forever", applies just as well to a finely crafted program or a printed circuit board as it does to flowers and fine art. Although the chip running the convoluted code will last just as long as the one running clean code, I can assure you: the universe will be a better place with the latter! smile.gif

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2009-05-02 07:58
    I spent some time trying to find some data on transistor reliability. Most of what I found was extremely detailed and involved papers on testing procedures, which produced no answers for me. From what I gather, most of the testing is accomplished by stressing the transistor for a period of time then extrapolating reliability. Some information hinted at time based degradations but it was unclear if the degradation would occur while the transistor was inactive. In fact, there was information that transistors could repair broken bonds during periods of inactivity. Nothing that I read indicated that the activity level of the transistor had any influence, except of course that the testing itself made it active. The only MTBF I could find for transistors was 10^6 hours. If that's the case then the typical transistor's expected lifetime far exceeds my own.

    What happens when you have 1 million transistors working together in a chip, how does that affect the MTBF?

    Rich H
  • heaterheater Posts: 3,370
    edited 2009-05-02 08:00
    Well even if each transistor in your processor had a finite number on/off operations in its life time many parts of your processor are used for every instruction executed, the instruction fetch logic or the program counter for examples, so presumably that would fail after the allotted number of cycles. So no matter what the code being executed looks like the processor life span would be the same.

    I will bear that in mind for my next project, a CPU made with relays[noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-05-02 11:21
    Heater, I thought we had a pact to go for an abucus next time! No relays, just solenoids!!!
  • localrogerlocalroger Posts: 3,452
    edited 2009-05-02 12:47
    Using more resources than necessary won't wear out the hardware noticeably (unless as others have noted you're churning an EEPROM) but it does waste power and generate heat. If you put it in a box with no ventilation that might shorten its life, but it would depend on other environmental factors.

    Ultimately, the reason to tighten your code is that one day you'll need to change it, and you absolutely will not remember just why you did that clever thing you did unless you leave a note to yourself. I constantly get calls along the lines of "You remember that console you built for us in 1996? Well, we need to add X to it." I've done thousands of little applications like that over the years, and the answer to the first question is usualy "Um, no." That is the situation which teaches you that comments and clean layout are your friend.
  • kwinnkwinn Posts: 8,697
    edited 2009-05-02 15:24
    Attached is a photo of the CPU board from a multiwell gamma counter. Each counter typically has two of these boards. I still service a few of these units, and they range in age from 22 to 26 years old. There are usually 14 2732 eproms mounted in the row of sockets that now has only my 2 diagnostic program chips. These instruments are typically used at least 8 hours per day, 5 days a week, and are left on 24/7/365. In all the years I have worked on them ( at one time I looked after about 20 ) I doubt that I have replaced more than a dozen chips all together on these boards.

    The greatest enemy of electronics is heat and excessive voltage/voltage spikes.
  • JoJo Posts: 55
    edited 2009-05-03 00:37
    There is one other issue that "ages" electronics: metal migration.
    But it only really applies when there are very large and very rapid current surges
    eg a modern X86 can go from standby power to full on in less than a clock cycle which causes
    a very rapid 40-50A surge into the chip and under the appropriate conditions this can cause
    wiskers to form on the metal powerlines and, should they touch, let the holy smoke out.
    Appropriate design practices reduce or eliminate this effect.
    For more details, see http://en.wikipedia.org/wiki/Metal_migration

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    Jo
  • jazzedjazzed Posts: 11,803
    edited 2009-05-03 00:52
    Holy smoke [noparse]:)[/noparse] All chips work on smoke don't they? [noparse]:)[/noparse] Smoke comes out, they stop working [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
Sign In or Register to comment.