Author Topic: Register preservation overhead  (Read 8138 times)

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Register preservation overhead
« on: July 16, 2012, 05:23:27 AM »
This is in response to a misplaced debate in this topic.

Running on my wimpy 500MHz P3, with WM_MOUSEMOVE messages being sent at a rate of 1000 per second, and ensuring that the test app is in the foreground so it will get the associated priority boost, the CPU usage on the Task Manager Processes tab seldom reaches 1%. And on my 3.0GHz P4 it stays at 0%. And note that the handler does 8 rounds of preserving and restoring EBX, ESI, and EDI.
Well Microsoft, here’s another nice mess you’ve gotten us into.

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Register preservation overhead
« Reply #1 on: July 16, 2012, 05:46:41 AM »
0.3% usage ... but surely not caused by that PUSH/POPs  :P
MREAL macros - when you need floating point arithmetic while assembling!

Gunther

  • Member
  • *****
  • Posts: 4198
  • Forgive your enemies, but never forget their names
Re: Register preservation overhead
« Reply #2 on: July 16, 2012, 06:16:03 AM »
My task manager says: ß.1% usage. Interesting point.

Gunther
You have to know the facts before you can distort them.

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Re: Register preservation overhead
« Reply #3 on: July 16, 2012, 12:55:00 PM »
What I started out to do, and didn't have time for, was to compare the CPU usage for WM_MOUSEMOVE sent by SendMessage to that for WM_MOUSEMOVE sent by PostMessage, to get an idea of how much of the usage happens in the window procedure.
Well Microsoft, here’s another nice mess you’ve gotten us into.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Register preservation overhead
« Reply #4 on: July 16, 2012, 03:48:20 PM »
Its pretty much the case that once you start using Windows API functions you can forget register overhead for preservation and for that matter most small algorithms. API functions are SSSSLLLLLOOOOOOWWWWWW !!!!
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Register preservation overhead
« Reply #5 on: July 16, 2012, 04:48:08 PM »
0.3% usage ... but surely not caused by that PUSH/POPs  :P

How did you get 0.3%? My task manager doesn't give decimals (Win7). In order to drive it above zero by manually moving the mouse, I need to insert something like this:
Code: [Select]
        CASE WM_MOUSEMOVE
mov ecx, 1000000
.Repeat
dec ecx
.Until Sign?

REPEAT 8
push ebx
...
Tested on an Athlon(tm) Dual Core Processor 4450B - the effect will be more dramatic on old CPUs.

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Register preservation overhead
« Reply #6 on: July 16, 2012, 07:05:12 PM »
How did you get 0.3%? My task manager doesn't give decimals (Win7).
The Process Hacker does  this.
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Register preservation overhead
« Reply #7 on: July 19, 2012, 04:49:08 AM »
... the effect will be more dramatic on old CPUs.

Just tested it on a trusty old Celeron M. With one Million dec ecx in the WM_MOUSEMOVE handler, you need to move the mouse rather quickly to see an effect, and never above 8%...

With 5 Mio, though, you can see up to 40%  ;)

FORTRANS

  • Member
  • *****
  • Posts: 1238
Re: Register preservation overhead
« Reply #8 on: July 19, 2012, 10:12:20 PM »
Hi,

   Between 1% and 3% on my P-III with Win2k.  On my
P-MMX with Win98, it runs, but there seems no way to
report CPU usage.  Using the task manager seens to
make the system very unhappy though.  (Was trying
to see if it reported CPU usage, it does not.)

Regards,

Steve N.

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Register preservation overhead
« Reply #9 on: July 20, 2012, 01:37:10 AM »
Between 1% and 3% on my P-III with Win2k

Hi Steve,

Is that using send.exe and test.exe together (i.e. 1,000 WM_MOUSEMOVE messages per second), or by manually moving the mouse over the window?

FORTRANS

  • Member
  • *****
  • Posts: 1238
Re: Register preservation overhead
« Reply #10 on: July 20, 2012, 02:18:45 AM »
Hi,

   That was using send.exe.  Mostly 1%, some 2%, and
a few 3%.  Figured that was what was intended.

   Wildly moving the mouse all over the place gets 1% to
9%, with more smaller numbers than large.

Regards,

Steve