Purefiler - An alternative profiler

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
Ramihyn_
Enthusiast
Enthusiast
Posts: 314
Joined: Fri Feb 24, 2006 9:40 am

Re: Purefiler - An alternative profiler

Post by Ramihyn_ »

Didelphodon wrote:Hm, I don't know why everyone is always horny for one's source-code ;-)
New PB releases regularly break usefull binary PB tools/libs, people leave the community or lose interest up to the point that even the binary tools disappear with them. You can find several examples of this happening on the forums. I can fully relate to your reasons though and mostly do the same, up to each author anyway :)
Didelphodon wrote:Indeed the loading can be very slow. In the dimensions of your software I guess we're not talking about 1000000 line-invocations anymore. I guess that the traces are more about Gigs of diskspace.
It crashed much earlier, resulting in a 166MB trace data file which should be around 2.5mil traced invocations. But to get the results i need, would indeed require many gig's of trace information this way. So it simply wont work :/
Didelphodon wrote:Besides that I have the guess that it's actually the loading of the source-code which is implemented kinda poorly (shame on me).
Yes, loading the sourcecode file results in over 12 minutes of initialisation and afterwards it crashes. It could simply be a matter of excessive memory use as the process quickly jumps to 1.85gig memory before crashing.
Didelphodon wrote:It initially wasn't my intention to have this Profiler for 40k lines (!!) of code. Hm, don't know how I can help you this way, though I want, but I guess you wouldn't want to give me your sourcecode or your traces (which have the source-code included). ;-)
Sadly i cant do that, but i gave purefiler a closer look and noticed that you also wrap direct assembler calls with Start/Stop calls. That results in trashed registers, trashed memory and crashes shortly after.

Example source to verify this problem:

Code: Select all

Procedure Windows_Get_Prozessor_String(StringAdresse)
    !mov eax,80000000h       ;Test, ob CPU aktuell genug ist um den String zu liefern
    !cpuid
    !cmp eax,80000004h
    !jae @f                  ;alles o.K.
    !xor eax,eax             ;Rückgabewert = Null für eventuelle Auswertung Fehlschlag
  ProcedureReturn
!@@:
    !mov esi,[p.v_StringAdresse]
    !xor edi,edi
!@@:   
    !mov eax,80000002h
    !add eax,edi
    !cpuid       
    !mov [esi],eax
    !mov [esi+4],ebx   
    !mov [esi+8],ecx
    !mov [esi+12],edx
    !inc edi
    !cmp edi,3
    !je @f
    !add esi,16
    !jmp @b
!@@:
    !mov eax,1               ;Rückgabewert <> Null für Erfolg
  ProcedureReturn   
EndProcedure


; set CPU info string

Temp$ = Space(100)
  
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  If (Windows_Get_Prozessor_String(@Temp$) = 0)
    Temp$ = ""
  EndIf
CompilerEndIf

Debug "CPUID: " + Temp$
Didelphodon wrote:@All: Anyone any more wishes? I'd really like to have a whole package done at once than doing many little patches.
I am using a lot other commercial profiler and tracing tools in my job, including my own one. The problem they all have is the massive amount of data which is created by these kind of traces (though profiling is only the start), because the CPU's are fast and the programs complex nowadays. A simple practical solution i use, is to limit the recording by triggers.

As an example for the most simple universal case - start the software with a flag which tells it not to record. Make an external app which is able to toggle that flag, resulting in your profiler initialising the datafile (unique timestamp via elapsedmilliseconds() as you already do). That way you can profile those situations you actually need to have a look at, without having to change and recompile a dozen times and insert TRON/TROFF or similar commands iteratively till you found what you look for. Worked wonders for me - a very simple external trigger could be a temporary file which appears. Just check for it's existance once every second, if it exists, you delete the file, toggle the recording switch. I enhanced that further by appending the content of the first line of the file to the filename of the trace data file. That way you can start profiling individual use-cases of your software and append a little note about what specifically was profiled at that moment.

ps: i would suggest to replace the dynamic forward-linked list containing individually allocated records with a static array which holds (for example) 1-mil entries. It wont fragment your memory as much, it wont slow you down with malloc/free all the time and you can just write the records by using a few large binary buffer writes instead of each value of each record individually. Plus i would definatly shrink your records and merge the Start and Stop ones to save memory.

pps: on a funny sidenote, norton sonar thinks this example is a severe threat and removed it after compilation, before execution ...
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Purefiler - An alternative profiler

Post by Didelphodon »

Thx for all the advices! I put a new version online which now shouldn't crash/get confused anymore when assembler is included (asm-code is still measured). Further running a program with enabled profiling is much (!!) faster now. Storing of the results is much faster now. Loading of profiling-logs is much faster now. Measurements are much more accurat now as pretty much any time that is consumed by profiling-code is subtracted from the measurements. Loading the sourcecode is still slow as I haven't updated this part yet.

Cheers,
Didel.

PS: Old results won't work anymore as a lot has changed, even on disk.
Go, tell it on the mountains.
nikoniko
User
User
Posts: 20
Joined: Fri Nov 11, 2011 7:58 am

Re: Purefiler - An alternative profiler

Post by nikoniko »

Bug - Purefiler (build 129) destroy Unicode strings (Russian) - change compliation mode to ascii???

2 files created in the home directory (e:\Documents and Settings\UserName) but it isn't visibled in anylyze mode and no message about miss log files....

Changing Working directory hasn't effect.

-- subscribe to email notification
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Purefiler - An alternative profiler

Post by Didelphodon »

Could you please come up with some more details? It's rather hard for me to understand what you mean in specific.

Cheers, Didel.
Go, tell it on the mountains.
nikoniko
User
User
Posts: 20
Joined: Fri Nov 11, 2011 7:58 am

Re: Purefiler - An alternative profiler

Post by nikoniko »

Window with Unicode caption without Profiler
Image

The same Window without Unicode caption with empty Profiler window on background
Image
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Purefiler - An alternative profiler

Post by Didelphodon »

* Purefiler doesn't show you live-statistics. You can only check the generated statistics *after* the according sample ended.
* You've got to choose your desired test-run from the "Purefiled Runs" box.
* Regarding Unicode => Hm, that's kinda strange. The only thing I can imagine that embedding Purefiler's monitoring-code might impact your compilation-options, which shouldn't happen, though.
Go, tell it on the mountains.
nikoniko
User
User
Posts: 20
Joined: Fri Nov 11, 2011 7:58 am

Re: Purefiler - An alternative profiler

Post by nikoniko »

Didelphodon wrote:* Purefiler doesn't show you live-statistics. You can only check the generated statistics *after* the according sample ended.*
Yeh! they are combined for screenshot only. I start Purefiler after application of course.
Didelphodon wrote: You've got to choose your desired test-run from the "Purefiled Runs" box
Where is this box?
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Purefiler - An alternative profiler

Post by Zach »

It's right at the top of the window....in the screenshot you posted :!:

It's a drop-down select by the looks of it.
nikoniko
User
User
Posts: 20
Joined: Fri Nov 11, 2011 7:58 am

Re: Purefiler - An alternative profiler

Post by nikoniko »

Seems Purefiler doesn't work with complex app -

Under Windows XP (Pro, 32 bit, Eng) cann't load profiler logs, combobox is empty.

Under WIndows 7 (HB, 64 bit, Russian) combobox has a line, but it's empty (or filled spaces), when I select it - logs loading, then Purefiler crashes...
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Purefiler - An alternative profiler

Post by Didelphodon »

Note: At the moment Purefiler is only for 32-bit.
Purefiler has to be configured (see the first page of this thread) to work properly. No compilation using Purefiler => no profile-data afterwards.

Cheers,
Didel.
Go, tell it on the mountains.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Purefiler - An alternative profiler

Post by jassing »

I've used PureFiler in some past projects and am wanting to use it again -- however, when I build my exe (normally) all is fine.
When I build with PureFiler, I get an error about unknown getip()

In my source, there is no "getip" anywhere in the code...
I'm not using any userlibs...
any ideas?

Code: Select all

Line 1486: getip(): Incorrect number of parameters.
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Purefiler - An alternative profiler

Post by Didelphodon »

Hm, strange. I got no idea, yet. I searched all of Purefilers code and couldn't find something with "getip" in it.
Go, tell it on the mountains.
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Purefiler - An alternative profiler

Post by Didelphodon »

A new version of Purefiler is online.

Changelog:
• some bugfixes
• supports continued lines feature
• typical timeconsumers can be automatically unchecked
• much much faster source code loading

have phun
Go, tell it on the mountains.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Purefiler - An alternative profiler

Post by jassing »

Should it be working with x64?
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Purefiler - An alternative profiler

Post by Didelphodon »

due to direct register/flags pushes/pops not yet. however, its planned.
Go, tell it on the mountains.
Post Reply