Improving Application Performance with the PowerBuilder Trace Engine and Profiler Application...
-
Upload
dwain-malone -
Category
Documents
-
view
266 -
download
2
Transcript of Improving Application Performance with the PowerBuilder Trace Engine and Profiler Application...
Improving Application Performance with the
PowerBuilder Trace Engine and Profiler Application
William B. Heys
Senior Consultant
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 3
Stop me at any time for questions
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 4
Improving Application Performance
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 5
Topics
PowerBuilder Tracing and Profiling Features Trace Engine Profile Objects and API Profiler Application
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 6
Tracing and Profiling
Helps identify and correct errors Helps identify performance bottlenecks Collects data and traces path through a PowerBuilder
application during execution Tracing is available for both run-time executables and in
development environment
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 7
PowerBuilder Trace Engine
As the application runs, the PB Virtual Machine captures information about what the application does What events and functions (routines) are executed (including
system functions) How long routines took to execute What other routines were called by a routine The exact order in which routines were executed (including line #
information)
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 8
PowerBuilder Trace Engine
As each profiling event occurs, an entry is written to the file Profiling events are not Windows events
Trace file contains a log of timer values at certain activity points
User can control how much detail is logged
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 9
TraceFile
PowerBuilder Trace Engine
Has a default name Application name With file extension .PBP
Saved in binary format Not PBDebug - cannot be opened in a text editor
Saved in the same directory as the PBL (by default) Not portable across operating systems
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 10
PowerBuilder Trace Engine
Profiling adds overhead to the execution of the application The time taken to generate the profiling information is
subtracted from the event time in the file Relative times should be consistent, overall times will
fluctuate
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 11
Tracing Distributed Applications
Logging is separate for each session Can trace individual client sessions or the main session Can trace multiple sessions at the same using separate
trace files
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 12
Collect trace data while running the application:
Tracing and Profiling Steps
Trace Engine Data Collection
Application Trace File
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 13
DisplayAnalysisTrace File
Tracing and Profiling Steps
Analyze trace file and display results:
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 14
Tracing a PowerBuilder Application
In development environment Enable tracing from System Options dialog box profiling tab
When running a PowerBuilder executable Use the w_StartTrace window (copy from PROFILE.PBL) Use PowerScript functions to control tracing
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 15
System Options Dialog Box
Profiling Tab
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 16
System Options Dialog Box
Profiling Tab
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 17
System Options Dialog Box
Enables tracing when running application from the development environment
Traces the entire application Stops capturing data when the application stops
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 18
Trace Timer Kinds
Clock Process Thread None
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 19
Clock Timer Measures absolute time in microseconds with reference to an
external activity such as the machine’s startup time Clock timer’s resolution is machine dependent
Speed of machine’s CPU may affect timer’s resolution Resolution may be less than one microsecond - smallest measurable unit of
time
Default for Windows 95 and Windows NT Not available on Unix (always uses thread)
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 20
Process or Thread Timer Measures time in microseconds with reference to when the
process or thread being executed started More accurate measurement of actual time a process or thread
takes to execute Excludes time taken by other running processes or threads Lower resolution than clock timer
Use thread for Distributed PowerBuilder applications Not available on Win16 UNIX always uses thread timer
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 21
TraceActivity Types
Start and end of logging ActBegin!
Routine (Entry/Exit) ActRoutine!
Routine Line Hits ActLine!
Embedded SQL Verbs (Begin/End) ActESQL!
Object Creation and Destruction ActObjectCreate! and ActObjectDestroy!
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 22
TraceActivity Types
User-defined Activities ActUser!
Records an informational message
System Errors and Warnings ActError!
Garbage Collection ActGarbageCollect!
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 23
TraceActivity Types
Profile Trace ActProfile!
Includes routine entry/exit, embedded SQL verbs, object creation/destruction, and garbage collection
Complete Trace ActTrace!
Traces everything except routine line hits
Note: above are not available in development, only by calling PowerScript function
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 24
Using Profiler w_StartTrace dialog
Copy w_StartTrace window from PROFILE.PBL to your own application library (PBL)
Add code to your application to open w_StartTrace Run your application Open w_StartTrace to start tracing View the trace file in application profile
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 25
Using Profiler w_StartTrace dialog
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 26
Opening and Closing the Trace File
Open a trace file and set timer kind TraceOpen ( readonly string filename, TimerKind timer ) returns
ErrorReturn
Close the trace file TraceClose() returns ErrorReturn
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 27
Enable/Disable TraceActivity Types
Enable or Disable logging for activity types while trace file is open but when logging is inactive Enable logging for a specified activity type
TraceEnableActivity ( TraceActivity activity ) returns ErrorReturn
Disable logging of a specified activity (when trace file is open but while logging is inactive)
TraceDisableActivity ( TraceActivity activity ) returns ErrorReturn
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 28
Start and Stop Trace
Start logging all enabled activities TraceBegin ( readonly string identifier ) returns ErrorReturn
Identifier (trace block label) is optional
Stop logging all enabled activities TraceEnd() returns ErrorReturn
Note - only while trace file is open
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 29
Trace Errors or User Activities
Log a severity level and error message TraceError ( long severity, readonly string message ) returns ErrorReturn
Log a reference number and informational message TraceUser ( long info, readonly string message ) returns ErrorReturn
Note - only while tracing is active
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 30
Analyzing Trace Results
You have to interpret the results yourself Build custom analysis and display applications using new
profiling and trace system objects Read the trace file using various PowerScript functions These functions return objects or arrays of objects
containing information about the execution of the application
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 31
Two Analysis Models Are Provided
Profiling Package Performance Analysis (Call Graph model) Class or Routine
Trace Tree Package Step by step flow of application execution
Customized Trace File Analysis Trace file has raw data in readable form Uss Performance analysis functions to perform customized
analysis
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 32
Profiling Package (Call Graph)
Builds a performance analysis or call graph model Contains all the routines called in the trace file Generates accumulated time and hits relative to one
function calling another
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 33
Trace Tree Package
Builds a trace tree model Maintains the ordering of the trace file Reflects the execution sequence Used to build Trace view
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 34
Processing the Trace File
PowerBuilder provides A new Profiler API to process the trace file New Profiler classes
Raw data is returned as instance variables using interface functions
Available to PowerBuilder developers Simplifies developing custom analysis tools
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 35
Trace tree classes
Performance analysis modeling and
trace file classes
New Profiler Classes
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 36
Trace Analysis PowerScript Functions
Set trace file to analyze SetTraceFileName ( string tracefilename ) returns ErrorReturn
Use with Profiling or TraceTree Objects
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 37
Building a Trace Analysis Model
Build a call graph model BuildModel ( powerobject progressobject, string eventname, long
triggerpercent ) returns ErrorReturn Use with Profiling or TraceTree Object All arguments are optional May take a long time Can track progress of the build by specifying a user-defined event
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 38
Profiling PowerScript Functions
Get a list of classes in the model Classlist ( ref ProfileClass list[] ) returns ErrorReturn
Use with Profiling object
Get a list of routines in a model or class RoutineList ( ref profileroutine list[ ] ) returns ErrorReturn
Use with Profiling and ProfileClass objects
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 39
Profiling PowerScript Functions
Get routine root node for model SystemRoutine ( ref ProfileRoutine routine) returns ErrorReturn
Use with Profiling Object
Get list of routines calling the specified routine IncomingCallList ( ref ProfileCall list[], boolean
aggregateduplicateroutinecalls ) returns ErrorReturn Use with ProfileRoutine Object
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 40
Profiling PowerScript Functions
Get list of routines called by the specified routine OutgoingCallList ( ref profilecall list[], boolean
aggregateduplicateroutinecalls ) returns ErrorReturn Use with ProfileRoutine and ProfileLine Object
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 41
Profiling PowerScript Functions
Get list of lines in routine LineList ( ref profileline list[ ] ) returns ErrorReturn
Use with ProfileRoutine Object
Line number sequence
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 42
Trace Tree PowerScript Functions
Get a list of top-level entries in the trace tree model EntryList ( ref tracetreenode list[ ] ) returns ErrorReturn
Use With TraceTree object
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 43
Trace Tree PowerScript Functions
Get a list of children of the routine or object GetChildrenList ( ref tracetreenode list[ ] ) returns ErrorReturn
Use with TraceTreeRoutine, TraceTreeObject and TraceTreeGarbageCollect objects
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 44
Trace Analysis PowerScript Functions
Destroy the current performance analysis model DestroyModel() returns ErrorReturn
Use with Profiling or TraceTree objects Cleans up all objects associated with the model
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 45
Reading the Trace File
Open the trace file Open ( string filename )
Use with TraceFile object
Return next activity in trace file NextActivity ( ) returns TraceActivityNode
Use with TraceFile object Information about category of activity Timer value when activity occurred Activity type
TraceFile
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 46
Reading the Trace File
Reset next activity to beginning of file Reset() returns ErrorReturn
Use with TraceFile object
Close Trace file Close()
Use with TraceFile object
TraceFile
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 47
Analyzing Trace results
Use the application profiler tool provided as a companion product with the enterprise edition of PowerBuilder (PROFILE.PBL) Written in PowerBuilder Source code is provided
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 48
Application Profiler
Three views extracted from a call graph model: Class view Routine view Trace view
Numeric views can generally be sorted by by clicking on a column header
Views can be printed
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 49
Application Profiler
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 50
Application Profiler - Routines
Routine Events and functions are considered the same Different icons displayed for functions and events
Routine Aggregation Option to aggregate statistics when a routine is called from two or
more different places in a script With aggregation, each routine is listed only once within a script Without aggregation, a routine may be listed multiple times for a
script
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 51
Call Graph Model - Timing Information
Hits - number of times a routine was called Self time - time spent in the routine, excluding time spent
calling other routines AbsoluteSelfTime - total for all executions MinSelfTime - shortest single execution MaxSelfTime - longest single execution PercentSelfTime - percentage AbsoluteSelfTime to total trace time
for the run
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 52
Call Graph Model - Timing Information
Total time (self + called) - time spent in the routine including time spent calling other routines AbsoluteTotalTime - total time for all executions MinTotalTime - shortest single execution MaxTotalTime - longest single execution PercentTotalTime - percentage AbsoluteTotalTime to total trace
time for the run
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 53
Profiler Class View
Each system or user-defined class having any routines executed is listed
Displays # of hits and timing information for all routines called in a class
Embedded SQL appears in a psuedo class called ESQL Can ‘drill-down’ to see data for each routine and
subroutines it calls Three tabs: numbers, graph and source code
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 54
Profiler Class View
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 55
Profiler Routine View
Shows calls, hits, and timing information for all routines (functions and events) executed
Shows where each routine is called from and the calls it makes to other routines
Two tabs: detail and source code view Routine detail shows minimum and maximum times when a
routine is called more than once
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 56
Profiler Routine View
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 57
Profiler Trace View
Shows the elapsed time taken by each activity in chronological order (execution path)
Expandable/collapsible tree view shows details for each routine
Line by line detail of user-written routines is available (if line information was captured during profiling)
Source code is available for each line Similar to pbdebug output
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 58
ProfilerTrace View
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 59
Interpreting Trace Results
Look for classes and routines consuming a significant percentage of overall execution time
Look for routines called many times Particularly routines consuming a large percentage of overall time An small improvement here may make a big change in overall time
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 60
Interpreting Trace Results
Look for routines that are called once or twice but use a large percentage of time There may be a way to improve the routine
Look at database access Tuning the SQL can make a big difference
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 61
Demo
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 62
CPD ProfessionalCertified PowerBuilder DeveloperSince 1994
Advanced CSICertified Sybase Instructor (Tools)Since 1992
Founded Boston PowerBuilder UserGroup in 1992
About the Speaker
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 63
Special Edition Using PowerBuilder 6
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 64
Special Edition Using PowerBuilder 6
ISBN: 0-7897-1437-x Macmillan (Que) website (www.mcp.com)
Go to Site Search, Book Information and enter ISBN
Amazon.Com (www.amazon.com) Search on author: Heys, William
SoftPro Bookstore (www.SoftPro.com)
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 65
Articles on the Web “Improving Application Performance with the PowerBuilder Trace
Engine and Application Profiler”published online in Sybase Powerline magazine
“Application Partitioning – Architecting Applications for the Future”published online at PowerCard99, sponsored by Sybase in U.K.
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 66
Articles in “EASy Does IT: Migrating Applications from Distributed
PowerBuilder to Enterprise Application Server 3.0”published in PowerTimes, July-August 1999
“A Brighter future for PowerBuilder and Sybase”Guest editorial published in PowerTimes, July-August 1999
“The New Millennium is Bugging Me, PowerBuilder and the Year 2000 issue”published in PowerTimes, January-February 1999 issue.
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 67
Books and Articles by Bill Heys Special Edition Using PowerBuilder 5.0.
Co-author, published by QueJune 1996
“NVOs How and Why”Posted to CompuServe (Go PBForum)NVO Library SectionFilename is NVOHOW.ZipAugust 1995
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 68
PowerBuilder Advisor Columns “How the PowerBuilder 5.0 Foundation Class Libraries
Implement a Service-Based Architecture.” November-December 1996
“New Language Features in PowerBuilder 5.0.”September-October 1996
“Managing your PowerBuilder Objects.”May-June 1996
“Encapsulating Your Objects”March-April 1996
“Introduction to Custom Classes”January-February 1996 (Premier Issue)
Copyright 1999, Whittman-Hart, Inc. all rights reservedPage: 69
William B. HeysSenior Consultant+1 (781) 203-3171 direct+1 (617) 513-0296 cellbill.heys @ marchFIRST.combheys @ [email protected]
You can reach me...
marchFIRST, Inc.128 Corporate Center70 Blanchard Rd., 2nd FlooorBurlington, MA 01803+1 (781) 203-3000 tel+1 (781) 203-3050 faxwww.marchFIRST.com