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

Page 5 - 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.

ModestGamer

Banned
Jun 30, 2010
1,140
0
0
i wasn't arguing that your well crafted asm was not faster than the windows c++. but good C++ compiled, vs good asm, is not going to be a huge difference.

inefficient code is going to be terrible in general.

i used to work for a big AV vendor for the consumer division. i remember once a decision was made to have an animated globe during scans that would spin while it waws scanning. to animate the globe the devs who were well apparently retarded put the code to animate in the main thread...

anyhow this made the scan about 20% slower. since it was close to the ship date and they didnt wnat to have to fix everything, all that was done was it was changed into a stock progress bar instead of an animated globe... it only was 5% slower, but still.

bad code is goin gto be slow. good code, compiled with a good compiler, vs. asm is a totally different story.


well good code with a dedicated compiler "IE microcontroller units" is going to be efficient. think about this. without code bloat what would drive hardware sales ??
 

Acanthus

Lifer
Aug 28, 2001
19,915
2
76
ostif.org
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:

add the salary of the employees (it would take at least two orders of magnitude more than you're proposing to get anything done in a timely fashion) and the resources they consume and you've got a push at best.
 

ModestGamer

Banned
Jun 30, 2010
1,140
0
0
the thing the OP isn't considering is that the code has to be written very open and non optimized due to the nature of PC hardware. What would be better is if windows compiled itself on install to optimize for the hardware config. Just laziness on there end.
 

BoT

Senior member
May 18, 2010
365
0
86
www.nanoleap.com
assembler is low level machine code and it is stellar just at that.
build anything GUI like with assembler would take tremendous amounts of code, much more then modern compilers would need which would make it then actually inefficient as a code base. executing all the extra code would result in the same amount, if not more, of processing cycles/ power used.

but i agree that many of todays programs, apps and windows is a poster boy for that, are not written very efficient. all to often you can find orphan strings and program paths that simply have not been removed or cleaned up.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
When something becomes bloated you have two choices. throw away ballast or optimize. if you have too much stuff in your room you either throw away a couch or opimize the whole order, the latter being more difficult. or you can say humanity has become bloated. you can either nuke a big part of it D: or optimize it :rolleyes:. "I know" for a fact that windows is bloated. I mean whenever I come across a win vista or 7, the first thing I do is disable the aero and other annoying stuff which are supposed to be the selling arguments for them. So their concern for their next versions should not be adding more bolatware, but rather optimizing it.
 

DrMrLordX

Lifer
Apr 27, 2000
23,055
13,158
136
Or you just leave the bloat where it is, sit back, and watch hardware become so robust that it doesn't really matter.
 

Ancalagon44

Diamond Member
Feb 17, 2010
3,274
202
106
When something becomes bloated you have two choices. throw away ballast or optimize. if you have too much stuff in your room you either throw away a couch or opimize the whole order, the latter being more difficult. or you can say humanity has become bloated. you can either nuke a big part of it D: or optimize it :rolleyes:. "I know" for a fact that windows is bloated. I mean whenever I come across a win vista or 7, the first thing I do is disable the aero and other annoying stuff which are supposed to be the selling arguments for them. So their concern for their next versions should not be adding more bolatware, but rather optimizing it.

So what you are saying is that everyone should go back to terminal windows? No fancy GUIs or anything, waste of energy. Yes it will take us 10x as long to get the spreadsheet to add up, but at least we wont waste electricity on things like windows!

Until you've worked in the Real World, you really have no clue.
 

0roo0roo

No Lifer
Sep 21, 2002
64,795
84
91
of course it has an impact on performance. suppose you are looking for a certain string somewhere on your computer. Every byte on your computer is running through various loops. optimizing those loops is almost hoily for an OS.
Yes. my procedure does everything windows API does and more. Mine even returns some more values which could be useful for further savings.
It is compatible all the way.
By the way, I am just a third class ( or even less ) programmer, I am sure professionals could do much better than that.

have you worked on any large scale software projects?
 

veri745

Golden Member
Oct 11, 2007
1,163
4
81
I will concede to the OP that it is theoretically possible to write code more optimally in ASM than it would be written in C/C++. However, I would submit that the most important optimizations that could be accomplished in any given program could almost certainly be accomplished in whatever language the program is written in.

Second, the reason high level languages are useful is almost entirely about maintainability and expandability. Sure, you could probably write a better search algorithm in ASM, but what if your constraints changed or you needed to find a bug? You are then screwed.

This is one of the reasons why scripts written at my workplace have been slowly transitioning from perl to ruby and sometimes Python. If another engineer can't sit down and figure out what a piece of code is doing and figure out how to alter it to meet his needs, the development time to write that code was basically wasted.

Readability and modularity are extremely important in a large scale and professional development environment. If you want to talk about wasted energy, think of a way to reduce code duplication and duplicated work between different groups in an organization. If you do that, then maybe YOU will directly benefit from the millions of $'s saved per day.
 

DominionSeraph

Diamond Member
Jul 22, 2009
8,386
32
91
Let's put it this way, Crisis with optimized asm code would run ok on a netburst cpu.

Which is not to say that DirectX is inefficient. Nor does it say that any electricity would be saved.

Look at Neverwinter Nights 2 when originally shipped. In order for it to be playable on even an Athlon X2 5200+ with a Geforce 8800 GTX (a high-end system when it came out), its graphics settings had to be set so low that it looked MUCH worse than Half Life or Homeworld (games that were playable on a Celeron 300a with a TNT and absolutely rocked on a Geforce 2).

Horribly unoptimized, buggy as hell, but in what way was this Windows' fault? Half-Life and Homeworld both play great on Windows.
And in what way would optimizing it save any electricity? If a game takes 40 hours to finish, what does it matter power-wise whether it is maxing out your system at 10FPS or 100FPS? It's still 40 hours of your computer being under load.

If a browser written in assembly could load a page in 0.1 seconds whereas Chrome loaded in 0.3, am I going to visit 3x the webpages, or be on the computer for 1/3rd the time? No.
System speed is only meaningful up to a point.
Two systems doing the same tasks -- one spending 99.5% of its time idle and the other 99.0%. The former is using half the processing resources. That doesn't mean it uses half the electricity.
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
Which is not to say that DirectX is inefficient. Nor does it say that any electricity would be saved.

Look at Neverwinter Nights 2 when originally shipped. In order for it to be playable on even an Athlon X2 5200+ with a Geforce 8800 GTX (a high-end system when it came out), its graphics settings had to be set so low that it looked MUCH worse than Half Life or Homeworld (games that were playable on a Celeron 300a with a TNT and absolutely rocked on a Geforce 2).

Horribly unoptimized, buggy as hell, but in what way was this Windows' fault? Half-Life and Homeworld both play great on Windows.
And in what way would optimizing it save any electricity? If a game takes 40 hours to finish, what does it matter power-wise whether it is maxing out your system at 10FPS or 100FPS? It's still 40 hours of your computer being under load.

If a browser written in assembly could load a page in 0.1 seconds whereas Chrome loaded in 0.3, am I going to visit 3x the webpages, or be on the computer for 1/3rd the time? No.
System speed is only meaningful up to a point.
Two systems doing the same tasks -- one spending 99.5% of its time idle and the other 99.0%. The former is using half the processing resources. That doesn't mean it uses half the electricity.

The hidden and ultimate goal in computing is, to have ALMOST infinite computational speed at ALMOST zero power usage. Until we are there, no hard or software can be considered as "good enough". to achieve this, you can not rely on only hardware enhancement. but also software.
 

DominionSeraph

Diamond Member
Jul 22, 2009
8,386
32
91
The hidden and ultimate goal in computing is, to have ALMOST infinite computational speed at ALMOST zero power usage. Until we are there, no hard or software can be considered as "good enough". to achieve this, you can not rely on only hardware enhancement. but also software.

It doesn't mean either is meaningful, though.

Take a computer that idles at 100W. It is computationally perfect -- processes in zero time for zero additional watts. So it is idle 100% of the time.
How big an improvement is this over a system that's idling 99% of the time with its 1% processing time only using 120W because it doesn't even take it out of its lowest speedstep?

100W vs 100.2W @ $0.11/KWh, you're looking at 455 hours (19 days) to save a penny.
24/7 for a year, the difference is 19 cents. $96.55 vs $96.36.
So Microsoft should be doing everything in assembly, eh?
 
Last edited:

taltamir

Lifer
Mar 21, 2004
13,576
6
76
When something becomes bloated you have two choices. throw away ballast or optimize. if you have too much stuff in your room you either throw away a couch or opimize the whole order, the latter being more difficult. or you can say humanity has become bloated. you can either nuke a big part of it D: or optimize it :rolleyes:. "I know" for a fact that windows is bloated. I mean whenever I come across a win vista or 7, the first thing I do is disable the aero and other annoying stuff which are supposed to be the selling arguments for them. So their concern for their next versions should not be adding more bolatware, but rather optimizing it.

you "know" for "a fact" that aero is bloatware? really?
Did your knowledge of facts inform you that disabling aero LOWERS performance, because aero offloads to the GPU a lot of things that were previously rendered in the CPU?
Disabling Aero will save you some ram, but increase your CPU utilization in windows, and is simply not worth it (unless you are extremely hurting for ram)
 

Schmide

Diamond Member
Mar 7, 2002
5,751
1,041
126
The hidden and ultimate goal in computing is, to have ALMOST infinite computational speed at ALMOST zero power usage. Until we are there, no hard or software can be considered as "good enough". to achieve this, you can not rely on only hardware enhancement. but also software.

This is so not true. Many routines are considered good enough and are specifically designed to run in low power states. You keep bringing up this magic search routine. Did you know that many OSs use a indexing service to speed up searches? When it comes time to do a search they are more often than not bottlenecked by the harddrive and memory. I really doubt you could squeeze one milliwatt out of this situation.

TLC said it best in the 80s

Don't go chasing waterfalls
Please stick to the rivers and the lakes that you're used to
I know that you're gonna have it your way or nothing at all
But I think you're moving too fast
 

DominionSeraph

Diamond Member
Jul 22, 2009
8,386
32
91
Here's an idea: If Windows is so slow, why don't you rewrite OpenGL? The last 10 years of development hasn't resulted in a gain over Direct3D, but apparently you think that you can make things twice as fast with just a little optimization.

Have at it.
 

Martimus

Diamond Member
Apr 24, 2007
4,490
157
106
Hi,
I was just wondering if it is possible to guesstimate a number for this question. :\
I chose the CPU forum because I thought it comes down to work being done by processors.

I don't know how much electricity it would save, but I am sure it would greatly cut down the size of the operating system, and increase the speed and efficiency of the functions. Do you realize that Windows Vista was three times as many lines of code as the operating system we developed for our last major program, which was orders of magnitudes more complicated and critical than Windows Vista.

I know that I am being vague with my statements, but the comparison of the two really drove home how extremely bloated Vista was, moreso than how efficient our software was as was intended by the presentation.
 

taltamir

Lifer
Mar 21, 2004
13,576
6
76
Here's an idea: If Windows is so slow, why don't you rewrite OpenGL? The last 10 years of development hasn't resulted in a gain over Direct3D, but apparently you think that you can make things twice as fast with just a little optimization.

Have at it.

Epic burn!
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
You're accusing the entire Windows developmen team of incompetence? Wow, naive AND arrogant.

Using assembler is all well and good until you have to delay Win7 until 2020 so that you can optimize it properly. And then you find that a prima donna has used that new Intel instruction not supported by AMD, so anyone running an AMD machine gets a hard crash. So you try to debug, only thats so much harder than doing so in C/C++/C#, so that adds 2 weeks to your development time.

Really, theres a reason people dont use assembler for large projects. Until you have worked in dev, and you obviously havent, you just wouldnt have a clue. Its nice to want to improve the world, but really, this just isnt feasible or even a good idea.

This. I write a lot of embedded software, and even I wouldn't use ASM unless there was no compiler. Hell, I don't even like C that much because of no OOP.

And OP, post your code for this super efficient search you've been bragging about.
 

zephyrprime

Diamond Member
Feb 18, 2001
7,512
2
81
Suppose Microsoft employs 100 programmers to translate their c code into assembly and pays them each 5000 Dollars a month. That makes 500000 Dollars a month. That's peanuts for MS.
If MS took that approach, I guarantee you that that would result in a slower version of windows that would consumer more power. Have you ever tried to optimize assembly code better than the compiler? It's really hard. The compiler is usually better at it that any human. The compiler produces this crazy assembly code that doesn't look so good but when you actually run it, it's better than hand written assembly.

The only way that an os written in assembly would be better than an os written in c++/c would be due to a reduction in architechtural complexity of the program and a reduction in features. It would not be due to better fine tuning and squeezing more cycles out.
 
Status
Not open for further replies.