News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Profiling dynamically generated code

Started by c0d1f1ed, January 10, 2008, 07:44:08 AM

Previous topic - Next topic

c0d1f1ed

Hi guys,

I have an application that uses dynamically generated code (using SoftWire), and while performance is generally great I do would like to have a look at low-level timing results. Unfortunately, all profilers I know of can't handle dynamically generated code well. In the best case they just tell me how much time was spend in 'unknown' functions.

SoftWire is able to output its generated function as assembly source code, and this can be used to statically compile pre-generated functions. This way I do can get complete profiling results for my dynamically generated functions. However, this functionality is very cumbersome to use; SoftWire needs to know all the addresses and names of variables used during the dynamic code generation. Furthermore, it requires to run the application, retrieve the assembly source, recompile, and then profile. This approach is just impractical with a large project like mine.

So I'm really looking for a profiler solution. If you know of a profiler that can somehow 'capture' the dynamically generated functions and show their intruction-level timings that would be awesome. Or if you have any other idea to get accurate profiling results of dynamically generated code, please let me know. I was thinking along the lines of creating a DLL at runtime, placing the newly generated functions in, and linking it while running...

All ideas welcome!

Nicolas

P1

Quote from: c0d1f1ed on January 10, 2008, 07:44:08 AMSoftWire needs to know all the addresses and names of variables used during the dynamic code generation. Furthermore, it requires to run the application, retrieve the assembly source, recompile, and then profile. This approach is just impractical with a large project like mine.
Please share what you can about your 'large project'.

Quote from: c0d1f1ed on January 10, 2008, 07:44:08 AMI was thinking along the lines of creating a DLL at runtime, placing the newly generated functions in, and linking it while running...
There is some profiling code on this board, that you can adapt from.

Learn to use 'Search', it saves you and us time.

You can implement the profiling code, by using a dll to call out to the dynamically generated routines, with any kind of information you want to associate with the sub-routine timing results.  Use OutputDebugString API or a text file to capture results.

Regards,  P1   :8)

c0d1f1ed

Hi P1,
Quote from: P1 on January 10, 2008, 03:39:26 PM
Please share what you can about your 'large project'.
It's a DirectX 9 software implementation: SwiftShader. It doesn't really matter to the discussion; I want to profile dynamically generated code.
QuoteThere is some profiling code on this board, that you can adapt from.
Thanks, but I don't really want to write my own profiler for this. I'm really happy with the capabilities of a profiler like AMD's CodeAnalyst, but it just can't handle dynamic code as far as I know. I was hoping someone knew another great profiler that does, or some tricks to make sure CodeAnalyst makes a copy of my generated functions... I know I might be asking the impossible, but it's worth a shot.
QuoteLearn to use 'Search', it saves you and us time.
I have Googled for days on how to profile dynamically generated code. I was hoping to save time by actually asking people who might have dealt with this before.
QuoteYou can implement the profiling code, by using a dll to call out to the dynamically generated routines, with any kind of information you want to associate with the sub-routine timing results.  Use OutputDebugString API or a text file to capture results.
Could you elaborate on this? I don't want to time how long the functions execute (that's easy), I want to see where the hotspots are on an instruction level (i.e. long dependency chains, misaligned data, jump mispredictions, etc).

Cheers,

Nicolas

0x401000

I was searching in the forum, did not find anything like this ... also very interested in this issue