How much electricity would be saved worldwide if Windows was writen in Assembly?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Status
Not open for further replies.

Tsavo

Platinum Member
Sep 29, 2009
2,645
37
91
So I tried to figure it out unscientifically. If each computer uses 1 Cent less energy a month, and we have a billion computers laptops and so on, we get a saving of 10 000 000 Dollars. :eek:

And if 78 million households in the US replaced ONE 75-watt bulb with a 70-watt bulb, the savings would be 93,375,921 dollars every 8 months.

By this metric, MS could save themselves a lot of effort by sending out 2.7 million 70-watt lightbulbs once every 1.31 years.
 

Tsavo

Platinum Member
Sep 29, 2009
2,645
37
91
Better yet, ban useless forum trolls planet wide and the annual energy savings would be 1.87 trillion dollars.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
You sure about this? An OS is rather dynamic, sometimes those "useless instructions" might actually be vital for proper operation. IOWs, you sure those Instructions are not there to address occasional Variables?

I can possibly see a situation where a Programmer uses a Command that does more than he/she Needs, but is that the fault of the Language or simply a poor choice by the Programmer? If it's the Language, perhaps the Language simply needs a new Command.

Come on, take my word when I say I know what I am ralking about. give me a 100 kilobyte c code and I'll give it back to you in less than 10 kilobytes. But as we all know size is not all. Loop optimization is the main advantage of assembly.
 

Idontcare

Elite Member
Oct 10, 1999
21,110
64
91
I suspect the bigger savings to be had when it comes to reducing electricity usage with personal computers would be to eliminate the need for anti-virus scanners to be running in the background all the time, processing every byte that flows through the system.

The premise of the OP though is about as practical an effort to reduce electricity usage as proposing everyone stops using automobiles for their commute and instead walk to work everyday as a means to reduce fossil fuel usage.

That and breeding unicorns that fart rainbows are two awesome goals to have in life but are not ever going to happen, ever, for fundamentally inescapable reasons.
 

sandorski

No Lifer
Oct 10, 1999
70,809
6,364
126
Come on, take my word when I say I know what I am ralking about. give me a 100 kilobyte c code and I'll give it back to you in less than 10 kilobytes. But as we all know size is not all. Loop optimization is the main advantage of assembly.

Put MS out of Business then.
 

DrMrLordX

Lifer
Apr 27, 2000
23,059
13,163
136
The last time I heard anyone extol the virtues of ASM was . . . back in the days of the Future Crew. They did a lot of amazing stuff in ASM, for the time. However, most of their stuff was canned demos or relatively simple apps (mod/m3m editors). The executable size from one of their projects was typically 2 megs or less.

Other than the fact that the OP seems to have blithely ignored The Mythical Man Month, you would need some incredibly skilled ASM hackers to convert C/C++ code to ASM at that level. There are guys out there that can do it, sort of, but . . . one hundred of them? One hundred guys that can take code meant for a high-level compiler and convert it to efficient ASM would probably cost a lot more than $500k/year, and you'd still be slowing down your development cycle.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
I am beginning to wonder if my question is as stupid as you guys make it seem. I thought it was a good question. You say it isn't? so be it.
 

hans007

Lifer
Feb 1, 2000
20,212
18
81
i spend most of my day writing c++ code for windows. And I can at least somewhat write assembly, at least well enough that if you give me a decompiled win32 app I can tell you what its doing.

I think first off it would take FOREVER to write a real program using it. The main thing though is most C++ compiled code is very well optimized by th ecompiler. Assembly code doesn't really save that much power for one thing. For example windows if it was written all in ASM would just have a lot of loops running in assembly as say services or something. The loops wouldnt be more efficient than efficiently written c++ code that had been compiled into asm.

not to mention you can write really realyl bad asm. So running a loop that say I don't know is waiting for user input in asm, vs in c++ saves you no power. Most of the power waste in a PC is already being fixed by having transistors that power off, and speedstep/power now type things, not becuase the code is slightly less efficient.

So it probably would not save much power, cause tons and tons more bugs, and make writing code take forever.


I have a coworker who used to work at a startup that wanted to make a PDA using all assembly to make it faster. It was fast all right given the hardware. But it was only a little faster than windows CE. and it took them so long to write apps that when win CE came out, they couldn't keep up and it only was barely faster unless it was for a game or something that was actually intensive.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
I suspect the bigger savings to be had when it comes to reducing electricity usage with personal computers would be to eliminate the need for anti-virus scanners to be running in the background all the time, processing every byte that flows through the system.

The premise of the OP though is about as practical an effort to reduce electricity usage as proposing everyone stops using automobiles for their commute and instead walk to work everyday as a means to reduce fossil fuel usage.

That and breeding unicorns that fart rainbows are two awesome goals to have in life but are not ever going to happen, ever, for fundamentally inescapable reasons.

Hi idontcare. I have read some of your posts and they are mostly ok. But here you are talking far below yourself. If you think a thread is stupid the clever thing to do is to keep away, unless you are stupid too. :twisted:
 

CurseTheSky

Diamond Member
Oct 21, 2006
5,401
2
0
The real question is, how much energy would be saved if the government outlawed World of Warcraft or if Crysis was never developed...

;)

Your question isn't stupid, it's just largely impractical. Having written projects that are thousands of lines of code long (which doesn't even come close to the length of an OS or more complicated applications), I can say for sure that it would take a ridiculous amount of resources (money, time, and manpower) to write something that large in assembly and then debug it.

Hardware these days is relatively fast, cool, and energy efficient. Considering you can run Windows 7 with virtually no problems on a 5-10W processor like Atom or a CULV C2D, it's easier to simply shrink what we already have and attack existing problems (the need for anti-virus is a good example) than spend the time developing something so huge in assembly.

Writing Windows 7 in assembly would be like building an Nehalem CPU by hand.
 
Last edited:

nyker96

Diamond Member
Apr 19, 2005
5,630
2
81
not as much as the amount of extra electricity required to debug the assembly code.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
i spend most of my day writing c++ code for windows. And I can at least somewhat write assembly, at least well enough that if you give me a decompiled win32 app I can tell you what its doing.

I think first off it would take FOREVER to write a real program using it. The main thing though is most C++ compiled code is very well optimized by th ecompiler. Assembly code doesn't really save that much power for one thing. For example windows if it was written all in ASM would just have a lot of loops running in assembly as say services or something. The loops wouldnt be more efficient than efficiently written c++ code that had been compiled into asm.

not to mention you can write really realyl bad asm. So running a loop that say I don't know is waiting for user input in asm, vs in c++ saves you no power. Most of the power waste in a PC is already being fixed by having transistors that power off, and speedstep/power now type things, not becuase the code is slightly less efficient.

So it probably would not save much power, cause tons and tons more bugs, and make writing code take forever.


I have a coworker who used to work at a startup that wanted to make a PDA using all assembly to make it faster. It was fast all right given the hardware. But it was only a little faster than windows CE. and it took them so long to write apps that when win CE came out, they couldn't keep up and it only was barely faster unless it was for a game or something that was actually intensive.

Windows xp search for a file used to take more than a minute on my computer. I wrote assembly code which did it in 14 seconds. I didn't even optimize it.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
What a bunch of trolls here, I'll feed you as much as you want. it is my favorite passtime. But for now please get out of my thread unless you have something positive to say. D:
 

CurseTheSky

Diamond Member
Oct 21, 2006
5,401
2
0
Why not take an open source OS (any flavor of Linux will do) and re-write it file-by-file in assembly? If you can manage a tangible speed or efficiency difference that seems worth the time invested, I'm sure you'll get a strong supporting community going in no time.
 

Idontcare

Elite Member
Oct 10, 1999
21,110
64
91
Hi idontcare. I have read some of your posts and they are mostly ok. But here you are talking far below yourself. If you think a thread is stupid the clever thing to do is to keep away, unless you are stupid too. :twisted:

My post was made in earnest. But it wouldn't be the first time I've cast pearls before swines, message received loud and clear.
 

DrMrLordX

Lifer
Apr 27, 2000
23,059
13,163
136
Windows xp search for a file used to take more than a minute on my computer. I wrote assembly code which did it in 14 seconds. I didn't even optimize it.

Did you try writing a file search program in C? Or C++? Or C#? Or . . . Java?

And did your hand-coded ASM version of XP File Search have the cute doggy that wags its tail at you when you start it up? Seriously. How many man hours do you think MS put into the animated search buddies? Or Clippy, or Bob, or, well, you get the idea.

What a bunch of trolls here, I'll feed you as much as you want. it is my favorite passtime. But for now please get out of my thread unless you have something positive to say. D:

Just because they're saying negative things doesn't make them trolls. Also, there *is* a programming forum if you'd like to discuss your idea there.
 

EarthwormJim

Diamond Member
Oct 15, 2003
3,239
0
76
I am beginning to wonder if my question is as stupid as you guys make it seem. I thought it was a good question. You say it isn't? so be it.

It's not a bad question to ask how much power savings can come from truly optimized and efficient code. It is quite clear that there is plenty of room for optimization in OS's. Just compare Mac OS to Windows battery life running the same hardware.

That's not what you asked though. You asked what if OS's were written in Assembly.

I don't know how many times it needs to be said, Assembly does not equal efficiency!!!!

You mentioned the 10kb C code down from 100kb. An OS is orders of a magnitude more complicated than that!! It is beyond the reach of a human or team of humans to optimize an OS in assembly like you're proposing. Small code yes, not a huge OS let alone writing it like that.

Assembly has a purpose now days. Being highly efficient in SMALL computers or hardware that require SMALL firmware or OSs. Even then for embedded systems C compilers are very very close to being as efficient as Assembly.
 
Last edited:

Any_Name_Does

Member
Jul 13, 2010
143
0
0
My post was made in earnest. But it wouldn't be the first time I've cast pearls before swines, message received loud and clear.

Casting pearls is exactly what I am doing here.
I came here for some interesting ( for me at least) and who knows maybe useful discussion,and I stand by my point and idontcare, because I know what I say makes good sense. Go learn assembly and you'll know what I am talking about.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
It's not a bad question to ask how much power savings can come from truly optimized and efficient code. It is quite clear that there is plenty of room for optimization in OS's. Just compare Mac OS to Windows battery life running the same hardware.

That's not what you asked though. You asked what if OS's were written in Assembly.

I don't know how many times it needs to be said, Assembly does not equal efficiency!!!!

You mentioned the 10kb C code down from 100kb. An OS is orders of a magnitude more complicated than that!! It is beyond the reach of a human or team of humans to optimize an OS in assembly like you're proposing. Small code yes, not a huge OS let alone writing it like that.

Assembly has a purpose now days. Being highly efficient in SMALL computers or hardware that require SMALL firmware or OSs. Even then for embedded systems C compilers are very very close to being as efficient as Assembly.

Yes an OS is big. But as I said you start off gradually. First optimize the kernel, then other main DLLs and keep moving on. Computers are going to be with us for a long time, and the energy saved is going to add up over years. Geeks here keep shouting and begging for optimized CPUs, but as soon as I mentioned a possible way to speed up things, they act like a virgin who is being raped by a gorrilla.
 

Idontcare

Elite Member
Oct 10, 1999
21,110
64
91
Casting pearls is exactly what I am doing here.
I came here for some interesting ( for me at least) and who knows maybe useful discussion,and I stand by my point and idontcare, because I know what I say makes good sense. Go learn assembly and you'll know what I am talking about.

Actually you posed a question...and then proceeded to berate anyone who attempted to provide an answer which ran counter to the result you were seeking.

(i.e. we didn't tell you what you wanted to hear...and that makes us all trolls, apparently)
 
Status
Not open for further replies.