ABAP Performance Analysis
ABAP Performance Analysis
• SCI - Code Inspector
• ST05 – Performance Trace
• SE30 ABAP Runtime Analysis
Tools of the Trade
Tools of the TradeSCI – Code Inspector
Static analysis of the quality of the code. Scans your program code and reports on potential problems particularly in the area of performance and security.
Benefits:– Analysis of SQL WHERE clause of SELECT, UPDATE and DELETE statements.– Identifies select statements that do not handle sy-subrc return codes– Use of statements that infer ominous database access– Identifies statements that bypass buffering– Drill through support from results screen to program source statement.– Etc.
Disadvantages:– Static checks cannot identify the relevancy of a piece of code– Cannot determine the frequency of execution of a statement of code.
ST05 Performance TraceThe Performance Trace allows you to record database access, locking
activities, and remote calls of reports and transactions in a trace file and to display the performance log as a list. It also provides extensive support for analyzing individual trace records.
Benefits:– Comprehensive tools set for evaluation of SQL statements– Integrated tools for accessing DDIC information
Disadvantages:– Dynamic analysis requires equivalent production data content– Limited to database access analysis, no evaluation of code path execution
Tools of the Trade
SE30 ABAP Runtime AnalysisThe runtime analysis provides an overview of the duration and performance of
your source code, from individual statements up to complete transactions.
Benefits:– Quickly identifies the percentage of time spent in database in contrast to abap
code execution.– Evaluation of modularization units, modules, performs, functions, etc.– Analyze internal table operations
Disadvantage:– Dynamic analysis requires equivalent production data content– Lacks the integration of comprehensive SQL analysis tools
Tools of the Trade
Code Inspector
Sophisticated static program checks should be part of each development process.
Standard Checks Performed
• Syntax checks and program generation
• Normal ABAP syntax check
• Extended Program Check
• Program Generation
• Security checks
• Use of statements deemed critical
• Use of statements the infers ominous database access
• Selected statements that do not handle system return code
Code Inspector
Sophisticated static program checks should be part of each development process.
Standard Checks Performed (continued)
• Performance checks
• Select statements that implicitly bypass SAP table buffers
• Check statements inside of SELETCT…ENDSELECT loops
• Nested loops over internal tables and nested SELECT statements
• Analysis of WHERE clause to determine support database indices
• Search operations
• Search for single tokens
• Search for complete statements
Code Inspector
Sophisticated static program checks should be part of each development process.
Access directly from the Abap Editor, from SE38 or SE80
16316InformationalWarningsError
Extended Program Checks
Errors:
No EXCEPTION to set SY-SUBRC Declared for CALL FUNCTION.
Evaluate to remove sy-subrc condition or possibly warrants the review of the function module for modification.
This line contains a BREAK-POINT statement.
All break points should be removed from production code unless specific reasons warrant their use.
Dangerous use of TRANSLATE in a multilingual system.
Evaluate to determine if this will have an impact when we implement other languages.
Performance Checks
Errors:
Table VEPO no field from Table Index in WHERE condition
1. Can the format of where clause be changed to use an index
2. Create an index to support where condition if warranted.
Warnings:
Table KNMT: No First Field from Table Index in WHERE condition
• Further analysis may be required to determine if this is a problem. Dynamic analysis that determines frequency of execution can be used to determine impact of the warning.
Code Inspector
Sophisticated static program checks should be part of each development process.
• Transaction ST05– Used to analyze and fine-tune program’s database access– Dynamic analysis– Must be logged into processor where job is running that is subject to the trace.– Should pre-load the application before trace is started.– Should strive to use this trace in QA unless production problem cannot be re-
created.
• Types of traces available– SQL Trace– Enqueue Trace– RFC Trace– Buffer Trace
Performance Trace
Performance Trace
Activate Trace with Filter
Used to start the trace against another process.
Activate Trace
Use to start the trace in your current dialog process. Once activated you may exit the transaction and run the program that you wish to trace.User name Useful to start a trace another users dialog session.Transaction Further limits bounder of trace to a tcode.Process ID Used to activate trace against a batch process.
Performance TraceDisplay Trace
Performance Trace
Performance Trace - SQL Statement Summary
– Is there any SELECT * statements in use?• Change them to SELECT COL1,COL2,COL3 specifying columns
– Are any CHECK statements embedded in SELECT..ENDSELECTs• Incorporate the check statement logic in WHERE clause
– Do SELECTs use appropriate DB Index or is table buffered?• Change logic, create an index, or buffer table
– Is nested SELECTs being used to retrieve data?• Convert to DB join, view or SELECT FOR ALL ENTRIES IN ITAB
– Are there SELECTs without WHERE clauses, on tables that grow?• You need to redesign the solution.
– Are SELECTs to master data tables buffered?• Store master data in itab and use READ TABLE…BINARY SEARCH to
eliminate duplicate access with same key
Performance Trace - SQL Statement Evaluation Checklist
– Is SELECT…APPEND ITAB…ENDSELECT being used?• Change processing to read data immediately into ITAB
– Is SELECT ORDER BY statements being used?• Read data to ITAB and then sort, unless DB Index supports
order by.
– Is program using calculations and summations that can be done on the database via SUM, AVG, MIN or MAX functions of SELECT?
• Use the calculations available on the SELECT statement.
– Are ITABs processed using READ TABLE itab WITH KEY?• Change table accesses to use BINARY SEARCH method.
Performance Trace - SQL Statement Evaluation Checklist
• Tips for Running Trace– Limit the duration of the trace to 10 minutes or less– Preload the program once to initialize database and cursor
buffers– To access trace results later
• Save the trace or..
• Record stop and start time of trace
– Utilize trace SQL statement summary function– 5,000ms access per execution, general rule of thumb– Make note of the appserver of the job you are tracing– Only ONE trace can be active on an appserver.
Performance Trace
Transaction SE30– Excessive or unnecessary use of modularization units– CPU intensive program functions– Inefficient or redundant database access
Runtime Analysis
Three phases of the ABAP runtime analysis.
1. Setting limits for the data that is measured
2. Measuring the data
3. Analyzing the data.
Initial ScreenSAP Menu Test Runtime analysis
Tipsand
Tricks
Measurementrestrictions
CurrentSession
ParallelSession
Transaction Program Function
Performancedata evaluation
Hit ListsABC
analysisCall
hierarchyStatistics
ABAP EditorABAP Dictionary
Standard Groups Tables Classes Instances Methods Events
List Viewer Dep. On aggregation
Tables
Runtime Analysis
Runtime Analysis
Initial Screen
Runtime Analysis
Variant: Statements Filter
Limit the trace to specified type of program statements.
Runtime Analysis
Variant: Duration and Type
Max File size default is 2meg
Aggregation:
Full – one trace record for each program part or instruction.
By Call – one trace record for every calling position
None – one trace record for each call. LARGE FILE!
Runtime Analysis
Measurement Overview
Abap interpreter
Database
System Statements
Green bar indicates less that 50% of the total runtime.
Database bar will be red when more than 25% runtime.
Runtime AnalysisDatabase Table Hit List – shows table names number of accesses , table type and buffering mode sorted by access time.
Group Hit List
Individual call instructions grouped by categories. Indicates the gross runtime and the number of times executed.
Runtime Analysis
Runtime Analysis
Internal Table Hit List
List of all internal table accesses. Shows the number of accesses, the gross and net time required and the total memory consumed.
Runtime Analysis
Call Hierarchy
Shows the chronological sequence of analyzed objects, the gross and net time taken at each call level.
Runtime Analysis -Statistics
Statistics
Runtime Analysis
Program Program name
Load Size Memory occupied by the program when loaded (in bytes)
Global data def. Memory occupied by the global data of the program when loaded (in bytes)
Defined methods Number of methods defined in the specified program
Called methods Number of methods called from the specified program
Defined forms Number of form routines defined in the specified program
Called forms Number of form routines called in the specified program
Defined F modules Number of function modules defined within a function group
Called F. modules Number of function modules called from a module pool RFC call. Number of Remote Function Calls
• Always perform static source evaluation
Summary
• Do not leave a trace running for an extended period of time, consume system resources
• You must be logged in to the same appserver as the process you are tracing.
• Powerful set of analysis tools• With power and the freedom to use them comes
responsibility
Questions?