You are on page 1of 38

1549 Accelerating Simulations Using Efficient Programming Techniques

Lab 1: Simulation Baseline Performance


Overview
How fast can a simulation run? Lets establish the simulation speed limit for your machine. See how fast the OPN ! Simulation "ernel can process #ery simple e#ents$ establishin% the best&case simulation performance for the machine at hand.

Objectives
'un simulations with different confi%urations. (ompare the runnin% times. Learn the confi%uration settin%s for the best performance. )n#esti%ate model compilation preferences.

Lab 1 Instructions
Improving Simulation Performance Lets establish the simulation speed limit usin% different compilation and simulation confi%urations. *ary the optimi+ation settin% and ,ernel type. See the o#erhead of function stac, trace recordin% and simulation status monitorin%. Minimal_self is a simple model that processes self&scheduled e#ents. )t is about the simplest thin% a simulation can do. !his establishes the underlyin% speed limit of the simulation ,ernel. Base-Line Simulation with Development Kernel -. Open pro.ect efficiency_techniques. a. (hoose File / Open / Project. b. Select efficiency_techniques. c. (lic, on Open. d. !he minimal_self scenario should be acti#e. 0. 'un simulation. a. Press ,eys Ctrl-Shift-R. !his action is the same as choosin% DES / Run Discrete Event Simulation. 1. Obser#e run&time performance. a. Obser#e the simulation speed %raph on the Simulation Speed pa%e.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ * o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

b. 2hen the simulation completes$ the d.

essa!es pa%e becomes acti#e.

c. 'ecord "vera!e Speed3 44444444444444444444 nter the #alue in the Performance Summary table at the end of this lab.

e. (lic, on Close. Extending the Speed Limit -. (onfi%ure simulation ,ernel. a. (lic, on the Confi!ure#Run DES toolbar button. b. Set Simulation $ernel to Optimi%ed. 0. 'educe fre5uency of status updates for optimi+ed use. a. Set &pdate interval to 10000000 e#ents 6ten million7. 1. Set to recompile models without function stac, trace information. a. 8pand the tree #iew to E'ecution # "dvanced # Compilation.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ! o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

b. (hec, Force model recompilation. c. Select (o for )nclude function stac* trace information in recompiled models. 9. :inimi+e simulation status updates. a. 8pand the tree #iew to Runtime Displays # emory &sa!e. b. ;nchec, +raph total memory usa!e durin! simulation. c. ;nchec, Sho, memory statistics panel. d. 8pand the tree #iew to Runtime Displays # Other Displays. e. ;nchec, +raph event processin! speed. f. ;nchec, Display live statistics panel. <. 'un simulation. a. (lic, on Run. =. Obser#e run&time performance. a. 2hen the simulation completes$ record "vera!e Speed3 44444444444444444444 b. nter the #alue in the Performance Summary table at the end of this lab. c. (lic, on Close to finish.

Review of Simulation Kernel Performance


>ill in the followin% table with the simulation performance from the results abo#e. Kernel T pe D$.$'op/$& Op i/i0$1 !verage Spee" #events$secon"s%

;sin% the optimi+ed ,ernel and minimi+in% the debu%%in% information impro#es performance. !he optimi+ed ,ernel is much faster than the de#elopment ,ernel. )f you recompile the models with the optimi+ed ,ernel settin%$ the compiler uses the comp_fla!s_optim compiler fla%s instead of comp_fla!s_devel. !his typically includes compiler optimi+ations. 'emo#in% the function stac, trace information 6FIN/FOUT/FRET o#erhead7 no lon%er includes the function stac, in error reports for enter?e8it e8ecs of process models and user&defined functions. @ou need to recompile the models for this to ta,e effect. Simulation pro%ress %raphs also incur some o#erhead that is not necessary. 'educe the fre5uency of basic pro%ress updates as well.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ , o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

&OPTIO'!L( OP')T *ompilation Preferences )f you ha#e time$ e8plore the OPN ! compilation en#ironment preferences. Viewing Compilation Preferences -. Start OPN ! :odeler if not already runnin%. 0. (hoose Edit / Preferences. 1. As soon as the dialo% bo8 opens$ type comp. 9. 'e#iew the preferences listed after step <. <. (lic, Cancel when finished re#iewin%. !he followin% preferences affect the OPN ! compilation en#ironment3 (ompiler selection o 2indows o Solaris comp_pro! (ompiler tar%et selection o o o o o comp_tar!et_type.development_sequential_/0 comp_tar!et_type.development_parallel_/0 comp_tar!et_type.optimi%ed_sequential_/0 comp_tar!et_type.optimi%ed_parallel_/0 (orrespondin% options for =9&bit Solaris. comp_uni' or comp_cc3 Sun Dcc compiler comp_!cc 3 E(( ( compiler comp_uni'_cpp or comp_CC3 Sun (BB compiler comp_!--3 E(( (BB compiler comp_pro!$ comp_pro!_cpp comp_msvc 3 :icrosoft *isual (BB 6#ersion = or C7

comp_pro!_cpp

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ # o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

(ompiler fla%s o o o o o o comp_fla!s_common comp_fla!s_c_specific comp_fla!s_c--_specific comp_fla!s_devel3 Fe#elopment ,ernel fla%s. comp_fla!s_optim3 Optimi+ed ,ernel fla%s. comp_fla!s_mt3 Parallel ,ernel fla%s. 2indows o Solaris 1ind_so_uni'2 1ind_so_!cc 1ind_uni'2 1ind_!cc 1ind_so_msvc 1ind_msvc

Lin,er selection3 1ind_sho1j_pro!2 1ind_static_pro! o

Lin,er options o 1ind_sho1j_fla!s 1ind_sho1j_fla!s_devel 1ind_sho1j_fla!s_optim 1ind_sho1j_li1s 1ind_sho1j_li1s_devel 1ind_sho1j_li1s_optim 1ind_static_fla!s 1ind_static_fla!s_devel 1ind_static_fla!s_optim 1ind_static_li1s 1ind_static_li1s_devel 1ind_static_li1s_optim

*onclusion
)mpro#in% the performance of a simulation in#ol#es se#eral factors3 (onfi%ure the simulation en#ironment liminate debu%%in% support (ompile models with optimi+ations

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ 2 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

OPN ! :odeler --.G ma,es this confi%uration easy to do from the E;). >or further speed impro#ement$ you can a#oid the o#erhead of the OPN ! E;) by runnin% the simulation from the OPN ! (onsole 6shell command&line7.
)'+ O, L!B 1

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ 3 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

Lab -: .sing t/e OP')T Profiler


Overview
2here is your simulation spendin% time? OPN ! Profilin% tool. #aluate simulation runnin% time performance usin% the

Objectives
Learn how to use the OPN ! Profiler user interface. ;nderstand the profiler output.

Lab - Instructions
Profiling a Simulation Configuring Simulations with Profiling -. Start OPN ! :odeler$ if it is not runnin%. 0. Open pro.ect efficiency_techniques if not already open. a. File / Open / Project. b. Select efficiency_techniques. c. (lic, on Open. 1. Switch to minimal_self scenario$ if necessary. a. (hoose Scenarios / S,itch to Scenario / minimal_self. 9. (onfi%ure simulation ,ernel. a. Press ,eys Ctrl-R. b. Set Duration to 500000 seconds. c. Set Simulation $ernel to Development. <. Set fre5uency of status updates for de#elopment use. a. Set &pdate interval to 50000 e#ents.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ 4 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

=. (onfi%ure profilin%. a. 8pand the tree #iew to E'ecution # "dvanced # Compilation.. b. (hec, Force model recompilation$ if not already chec,ed. c. Select 3es for )nclude function stac* trace information in recompiled models. d. 8pand the tree #iew to E'ecution # Profilin!. e. (hec, Collect profilin! information. f. (hec, Force model recompilation. %. (hec, )nclude profilin! information in recompiled models. h. (hec, Ena1le section profilin! of process models. i. Select Output to4 Simulation pro!ress ,indo,.

C. 'estore simulation status updates. a. c. 8pand the tree #iew to Runtime Displays # emory &sa!e. b. (hec, +raph total memory usa!e durin! simulation. 8pand the tree #iew to Runtime Displays # Other Displays. d. (hec, +raph event processin! speed. H. 'un simulation. a. (lic, on Run. I. Obser#e run&time profilin% results. a. 2hen simulation completes$ the Profilin! pa%e becomes acti#e. b. )f necessary$ resi+e window and column widths to #iew profilin% results.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ - o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

c. 'e#iew the results$ referencin% the column definitions below. nterpreting Profiling !esults o (lic, on column headin% to sort data by that column. (hec, Sho, time as percenta!e to normali+e time to fraction of total runnin% time. (ame is the te8t in the FIN 6or PROFILE_SECTION_BEGIN$ e8plained in Lab 1) macro statement. !his is typically the function or process enter?e8it e8ec name. odel is whether the profiled section is user or ,ernel code. Optimi+ed ,ernel does not include profilin% data of the ,ernel. 5otal 5ime is in real&time seconds$ not simulation time. 6 Calls is the number of times the profiled function or section was called. usec#call is the amount of time 6microseconds7 spent in the function and its children per call. Function 5ime is the amount of total time spent in the function and not its profiled children. Child 5ime# odel is the amount of total time spent in the portion of the functions children that comprises user model code.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ 5 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

Child 5ime#$ernel is the amount of total time spent in the portion of the functions children that comprises OPN ! "ernel Procedures. 6!his is una#ailable if usin% the Optimi+ed ,ernel.7

Clean "p -. (lose the pro.ect. a. (lic, Close when finished re#iewin% data. b. Press Ctrl-7 or choose File / Close. c. (lic, on Don8t Save.

Reference: *onfiguring *o"e for Profiling


Let us re#iew the necessary steps for profilin% models. ;se FIN/FOUT/FRET macros and recompile. o o o FIN at be%innin% of function. FOUT/FRET in place of return(). !he preference comp_trace_info or the Include function stack trace information in recompiled models chec,bo8 controls whether FIN/FOUT/FRET is e8panded at compile time.

'ecompile models with profilin% settin%s. )f runnin% simulation from console and compilin% by hand3 o o o o Add VOSD_PROFILE symbol to compiler fla%s. Add VOSD_PROFILE_SECTION symbol for enter?e8it e8ecuti#es profilin%. 'un simulation with preference prof_trac* 9 5R&E to collect profilin% results. >or 2indows$ optionally set preferences console and console_e'it_pause to 5R&E.

*onclusion
Profilin% a simulation usin% the built&in OPN ! Profiler yields #aluable information for impro#in% the efficiency of a model. Profilin% entails simple confi%uration and recompilation of the models. OPN ! :odeler --.G ma,es this confi%uration easy to do from the E;). )mpro#in% the efficiency of the user code is not tri#ial. )t re5uires careful analysis of the profile data usin% principles learned from this OPN !2O'" session.

)'+ O, L!B -

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *" o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

Lab 0: Improving a Router 1o"el


Overview
@our tas, is to impro#e the runnin% time efficiency of a simple router model. ;se the OPN ! Profiler to pinpoint the performance bottlenec,s. 8plore different ways to impro#e the runnin% time.

Objectives
)terate throu%h the profilin%?optimi+ation process. !une model code for efficiency.

Lab 0 Instructions
Router Overview !his lab uses a sample router model to demonstrate inefficient code and how to ma,e incremental impro#ements. !he node model consists of a central 5ueue with sets of recei#ers and transmitters. !he process model reads periodic hello pac,ets from other processes. !he hello messa%es contain routin% databases containin% nei%hbor information. !he nodes compute a Jellman&>ord&li,e shortest path al%orithm to obtain the %lobal routin% picture. Initial 1o"el Performance -. Start OPN ! :odeler if not already runnin%. 0. Open pro.ect efficiency_techniques. a. (hoose File / Open / Project. b. Select efficiency_techniques. c. (lic, on Open. 1. Switch to random_mesh scenario. a. Press ,eys Ctrl-0 or chose Scenarios : S,itch to Scenario : random_mesh. 9. (onfi%ure efficient simulation en#ironment. a. (lic, on the Confi!ure#Run DES toolbar button. b. Set Duration to /;;; seconds. c. Set Simulation $ernel to Optimi%ed. d. Set &pdate interval to 500000 e#ents. e. 8pand the tree #iew to E'ecution # "dvanced # Compilation.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ** o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

f. (hec, Force model recompilation. %. Select (o for )nclude function stac* trace information in recompiled models. h. .. 8pand the tree #iew to E'ecution # Profilin!. 8pand the tree #iew to Runtime Displays # emory &sa!e. i. :a,e sure Collect profilin! information is not chec,ed. ,. ;nchec, +raph total memory usa!e durin! simulation. l. ;nchec, Sho, memory statistics panel. m. 8pand the tree #iew to Runtime Displays # Other Displays. n. ;nchec, +raph event processin! speed. <. 'un simulation. a. (lic, on Run. =. Obser#e run&time performance. a. 2hen the simulation completes$ record "vera!e Speed3 444444444444444444 and 5ime4 Elapsed3 444444444444444444 b. nter the results in the table at the end of this lab. c. (lic, on Close to finish. Lets see if we can impro#e the performance. >irst$ find out where we are spendin% time in the model. Initial Profile of 1o"el Configuring Simulations with Profiling -. (onfi%ure simulation duration and ,ernel. a. Press ,eys Ctrl-R. b. Set Duration to 10 seconds for faster runs. As we ha#e found out$ the Fe#elopment ,ernel is slower than the Optimi+ed ,ernel. c. Set &pdate interval to 1000 e#ents. d. Set Simulation $ernel to Development. 0. nable profilin% in models. a. 8pand the tree #iew to E'ecution # "dvanced # Compilation. b. (hec, Force model recompilation. c. Select 3es for )nclude function stac* trace information in recompiled models.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *! o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

d.

8pand the tree #iew to E'ecution # Profilin!.

e. (hec, Collect profilin! information. f. (hec, Force model recompilation. %. (hec, )nclude profilin! information in recompiled models. h. (hec, Ena1le section profilin! of process models. i. Select Output to4 Simulation pro!ress ,indo,. 1. 'un simulation. a. (lic, on Run. #nal$%ing Profiler Data -. *iew profiler output. a. 2hen the simulation completes$ the Profilin! pa%e becomes acti#e. b. )f necessary$ resi+e the window to #iew profilin% results. c. (lic, on the 5otal 5ime column headin% to sort in descendin% order.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *, o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

"nowled%e of call&%raph from code is helpful here. Process eff_router consumes the bul, of the runnin% time. :ost of that time is spent in its Hello enter e8ecuti#es. A lot of time is spent in eff_router_hello_data_proce eff_router_hello_pac"et_proce !). 2hat is the brea,down of eff_router_hello_data_proce !) called from !)?

o About half of the time is in the function itself$ the rest in children$ with a small amount in the OPN ! ,ernel. Lets try to find where in eff_router_hello_data_proce Profiling Detailed Sections of &unctions -. (lic, on Close. 0. Open the eff_router process model. a. )n the Pro.ect ditor$ double&clic, on any node. b. Fouble&clic, on the eff_queue module in the center. 1. Locate offendin% code. a. (lic, on the Edit Function <loc* toolbar button. b. Press ,eys Ctrl-F and search for hello_data_process to locate function eff_router_hello_data_proce !)$ or press Ctrl-2 6control and comma7 and %o to line 00-. ,eys !) we are spendin% time.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *# o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

c. Note the for!) loop$ a li,ely source of inefficiencies. :acros#PROFILE_SECTION_BEGIN and PROFILE_SECTION_END define a section of code to be profiled separately from the function. !his helps to identify areas of an e8pensi#e function to narrow the optimi+ation candidate. Profile this function in three areas3 top$ middle$ and bottom. 9. Add top profile section. a. Add a profile section after the for!)statement 6line 01C7 and after the op_$%a_o&'_attr_(et!7 call 6line 09H7. :a,e sure that the BEGIN and END ar%uments match e8actly.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *2 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

<. Add middle profile section. a. Add another profile section around the call to eff_router_)e$(h&or_co t_(et!) 6line 0<C7.

=. Add bottom profile section. a. Add the bottom profile section before eff_router_d&_f$)d!)6line 0=17 and .ust before the end of the for!) loop bloc, 6line 0H97.

C. :a,e sure that the PROFILE_SECTION#ta%s between the parentheses match up. H. Sa#e the model. a. Press ,eys Ctrl-S to sa#e the function bloc, code chan%es. b. Press ,eys Ctrl-S a%ain to sa#e the process model in the Process ditor.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *3 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

I. (hec, for synta8 errors. a. (hoose Compile / Compile Code ="dvanced>. b. (hec, )nclude function call stac* support. c. (hec, ? ,ith profilin! information. d. (hec, ? and section profilin!. e. (lic, Compile to ma,e sure there are no errors in the code. f. (lic, on Close. -G. Eo bac, to the Pro.ect ditor. a. (hoose 7indo,s / Project / efficiency_techniques. --. (onfi%ure simulation ,ernel. a. Press ,eys Ctrl-R. b. Set Duration to 5 seconds to sa#e some time. c. 8pand the tree #iew to E'ecution # "dvanced # Compilation. d. ;nchec, Force model recompilation to a#oid unnecessary model compilation. -0. 'un simulation. a. (lic, on Run. -1. *iew the profiler output.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *4 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

!he ma.ority of time spent in eff_router_hello_data_proce !) is now in the bottom section. Another round of PROFILE_SECTIONs can isolate the problem within the bottom section. Howe#er$ eff_router_d&_f$)d!) consumes a lot of run time$ so it is the li,ely culprit. Note also that it is called fre5uently. -9. Analy+e eff_router_d&_f$)d!). a. Fo not close the profiler output window yet. b. Eo bac, to the eff_router Process ditor. c. (lic, on the Edit Function <loc* toolbar button. d. Press ,eys Ctrl-F and search for db4find to locate function eff_router_d&_f$)d!) 6line 1<17. !his is a simple function with a for!) loop and calls to op_pr(_l$ t_acce for searchin% the destination node )F. !)

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *- o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

!hou%h it is simple$ fre5uent e8ecution of this function contributes to the lar%e !otal !ime spent in function.

-<. See profile of list accesses. a. Press ,eys Ctrl-7 to close the code editor. b. Eo bac, to the Pro.ect ditor by choosin% 7indo,s / Project / efficiency_techniques. c. )n the profiler output window that is still open$ note the Child 5ime # $ernel for eff_router_d&_f$)d!). d. Also note the (um1er of Calls to op_pr(_l$ t_acce !) and op_pr(_l$ t_ $*e!)$ the ma.ority of which are probably called from eff_router_d&_f$)d!). Linear searchin% throu%h a lin,ed list is O6n7. Possible performance impro#ements include3 !rees K O6lo% n7 searchin%. Hash tables K O6-7 searchin%.

Lets try to impro#e the performance by usin% another searchin% al%orithm. Tuning t/e *o"e Searchin% throu%h a list for a particular matchin% element is O6n7. Searchin% items in a hash table is O6-7. Since searchin% is a fre5uent operation here$ lets try to use a hash table implementation for the destination node )Fs to see if there is any performance impro#ement. Hash tables are appropriate in this conte8t because we want an al%orithm and data structure that is efficient at searchin% but is %ood at insertions as well.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ *5 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

"sing a Better Searching #lgorithm -. Locate code to modify. a. (lose the profiler output window if it is still open. b. (hoose 7indo,s / Process odel / eff_router. !) in the function bloc, of the c. Eo bac, to eff_router_hello_data_proce eff_router process model 6line 00-7.

2e ha#e started to define a new function to replace eff_router_d&_f$)d!). !his new function uses hash tables. )t is a %ood idea to lea#e the ori%inal code around in case the new code does not yield any performance impro#ements. 0. 'ewor, the searchin% desi%n. a. 'eplace the call to eff_router_d&_f$)d!) in the bottom section with eff_router_d&_ha h_f$)d!)6line 0=17+ b. Also replace the call to eff_router_d&_add!) with eff_router_d&_ha h_add!) in the same section.

c. Press ,eys Ctrl-F and search for other instances of calls to eff_router_d&_add!) or eff_router_d&_f$)d!)and replace them with eff_router_d&_ha h_add!) or eff_router_d&_ha h_f$)d!). 1. Fefine hash table searchin% code. a. At the #ery bottom of the function bloc,$ re#iew the code for functions eff_router_d&_ha h_f$)d!) and eff_router_d&_ha h_add!). 2e ha#e not modified them from the ori%inals$ yet. b. )n eff_router_d&_ha h_add!)$ replace op_pr(_l$ t_$) ert!) with pr(_ tr$)(_ha h_ta&le_$te%_$) ert!). Note that the first ar%ument is now SV_data&a e_ha h for the new state #ariable data structure. c. Strin% hash tables re5uire a ,ey strin%. 2e modify the rest of the function as follows.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !" o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

d. )n eff_router_d&_ha h_f$)d!)$ replace the for!) loop entirely with a call to pr(_ tr$)(_ha h_ta&le_$te%_(et!). !his replaces a se5uential search with a hash table search. A%ain$ see the function below for actual chan%es.

9.

nable other hash table searchin%&related chan%es. a. 2e ha#e already chan%ed other parts of the model that depend on the router database data structure. ;ncomment the ,def$)e at the be%innin% of the function bloc, to enable these chan%es.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !* o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

<. Sa#e the model. a. Press Ctrl-S to sa#e the function bloc, code chan%es. b. Press Ctrl-S a%ain to sa#e the process model in the Process ditor. =. (hec, for synta8 errors. a. (lic, on the Compile Process code. b. (lic, Close. C. Eo bac, to Pro.ect ditor. a. (hoose 7indo,s / Project / efficiency_techniques. H. (onfi%ure simulation ,ernel to compare a%ainst initial run. a. Press ,eys Ctrl-R. b. Set Duration to 3000 seconds. c. Set Simulation $ernel to Optimi%ed. d. Set &pdate interval to 500000 e#ents. e. 8pand the tree #iew to E'ecution # "dvanced # Compilation. f. (hec, Force model recompilation. %. Select (o for )nclude function stac* trace information in recompiled models. h. 8pand the tree #iew to E'ecution # Profilin!. i. ;nchec, Collect profilin! information. I. 'un simulation. a. (lic, on Run. -G. Obser#e run&time performance. a. 2hen the simulation completes$ record "vera!e Speed3 444444444444444444 and 5ime4 Elapsed3 444444444444444444 b. nter the results in the table at the end of this lab. c. (lic, on Close to finish. Profiling Current Performance -. (onfi%ure simulation duration and ,ernel. a. Press ,eys Ctrl-R. b. Set Duration to 10 seconds for faster runs. odel toolbar button to ma,e sure there are no errors in the

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !! o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

c. Set &pdate interval to 1000 e#ents. d. Set Simulation $ernel to Development. 0. nable profilin% in models. a. 8pand the tree #iew to E'ecution # "dvanced # Compilation. b. (hec, Force model recompilation. c. Select 3es for )nclude function stac* trace information in recompiled models. d. 8pand the tree #iew to E'ecution # Profilin!. e. (hec, Collect profilin! information. f. (hec, Force model recompilation. %. (hec, )nclude profilin! information in recompiled models. h. (hec, Ena1le section profilin! of process models. i. Select Output to4 Simulation pro!ress ,indo,. 1. 'un simulation. a. (lic, on Run. 9. *iew profile results. a. (lic, on Close when finished re#iewin% results.

!hou%h we ha#e tried to use better al%orithms$ eff_router_hello_data_proce !) is still a factor. Lets ta,e a different approach and try to see if there are any possible bi%&picture optimi+ations. Re"ucing *omputations t/roug/ *ac/ing :ost of the runnin% time is spent in processin% the hello messa%es 6eff_router_hello_data_proce 7. (an we reduce the number of hellos? Suppose that the topolo%y does not chan%e fre5uently. !he routers database remains constant. !he hello messa%e data$ thou%h constructed$ does not chan%e from before. !hus$ there is no need to repeatedly perform the e8pensi#e computation of processin% the data. )t is sufficient to remember the results of the pre#ious computation by reusin% the last Hello data. How can we reduce the number of hello pac,ets recei#ed?LFo not send the hello pac,et for the recei#er to process in the first place. Lets desi%n a cachin% al%orithm for both the sender and the recei#er of the Hello messa%es3

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !, o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

!he sender remembers when its own database last chan%ed. )t also remembers when it last sent Hello messa%es. )f the database is still #alid for the last Hello messa%es$ send an empty Hello messa%e. !his a#oids the time spent pac,in% up the database information into a Hello messa%e. !he recei#er adds an e8tra field in its nei%hbor information for each nei%hbor storin% the last hello messa%e. )t updates this field upon recei#in% a non&empty Hello messa%e. )f the nei%hbor sends an empty messa%e$ reuse the cached data. !he memory o#erhead is simply the number of nei%hbor entries multiplied by the si+e of the lar%est Hello messa%e. !o sa#e time$ we ha#e already implemented this for you. Lets re#iew the performance impro#ements. #ssess Performance with Caching -. (han%e 5ueue module implementation. a. Eo bac, to the Pro.ect ditor. b. Fouble&clic, on any node. c. 'i%ht&clic, on 5ueue module eff_queue. d. (hoose Edit "ttri1utes in the pop&up menu. e. (lic, on the *alue column of attribute process model. f. Select eff_router_hello_cache. %. (lic, on O$. h. Press ,eys Ctrl-S to sa#e the node model. i. Eo bac, to the Pro.ect ditor. 0. (onfi%ure simulation ,ernel to compare a%ainst initial run. a. Press ,eys Ctrl-R. b. Set Duration to 3000 seconds. c. Set Simulation $ernel to Optimi%ed. d. Set &pdate interval to 500000 e#ents. e. 8pand the tree #iew to E'ecution # "dvanced # Compilation. f. (hec, Force model recompilation. %. Select (o for )nclude function stac* trace information in recompiled models. h. 8pand the tree #iew to E'ecution # Profilin!. i. ;nchec, Collect profilin! information. 1. 'un simulation. a. (lic, on Run.
P)g$ !# o+ ,-

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

1549 Accelerating Simulations Using Efficient Programming Techniques

9. Obser#e run&time performance. a. 2hen the simulation completes$ record "vera!e Speed3 444444444444444444 and 5ime4 Elapsed3 444444444444444444 b. nter the results in the table at the end of this lab. c. (lic, on Close.

&OPTIO'!L( Caching mplementation )f you ha#e time$ lets re#iew the chan%es we ha#e made for this performance impro#ement. -. Open function bloc, of process model. a. )n the Pro.ect ditor$ double&clic, on any node. b. Fouble&clic, on the eff_queue module in the center to open process model eff_router_hello_cache. c. *iew the >unction Jloc,. 0. Sender&side implementation. a. !he sender records the last time the database was modified in eff_router_hello_data_proce !) 6lines 109 M 11=7.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !2 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

b. !he sender also records the last time a hello was sent in eff_router_hello_ e)d!) 6line -=-7.

c. )f the database has not chan%ed since the last hello$ then there is no need to recompute it 6line -0=7.

d. Send an empty pac,et to let the recei#er ,now 6line -9H7.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !3 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

1. 'ecei#er&side implementation in eff_router_hello_pac"et_proce a. 'ecei#er caches the last hello from each nei%hbor.

!) 6line 01C7.

b. 2hen the sender si%nals that the hello information has not chan%ed by sendin% an empty pac,et$ retrie#e the cached messa%e and process it.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !4 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

9. (lose all open windows.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !- o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

Review of *o"e Tuning Improvements >ill in the followin% table with the e#ent speed and the total runnin% time of the simulations from the results abo#e. Improvement Origi&)' H)(h T)6'$ H$''o C)%h$ )vents$Secon" Running Time #secon"s%

*onclusion
)mpro#in% the runnin% time in#ol#es repeated iterations of profilin% and code tunin%. )f the performance does not impro#e after code tunin%$ of course$ undo that chan%e. )t is important to #erify the correctness of the simulation by comparin% the results between the iterations. @ou do not want to introduce unintentional errors into the code. !he ma.or performance wins come from rethin,in% the desi%n of the model. Jased on the profilin% results$ tar%et the e8pensi#e parts of the code first 6thin, HG?0G7. A#oid fine&tuned platform& specific optimi+ations unless absolutely necessary. !hey are %enerally not portable and are hard to maintain o#er time. Jetter al%orithms and appropriate data structures often yield the desired performance impro#ements.

)'+ O, L!B 0

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ !5 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

Lab 2: Profiling 1emor .se


Overview
:emory is often the limitin% factor when it comes to performance issues. Simulations can consume 5uite a lot of memory. )n this lab$ you will learn how to profile the models memory usa%e usin% the OPN ! memory AP) and memstats tools. )n a lea,y #ariant of the router model$ it is difficult to trac, the memory lea, without usin% the OPN ! :emory AP). >ind out where the memory lea, is usin% the memory profilin% tools in OPN ! --.G.

Objectives
Learn how to use the memory statistics tools. ;nderstand the memstats output.

Lab 2 Instructions
Trac3ing 1emor .se in OP')T Configuring and !unning Simulations with 'emor$ Profiling -. Start OPN ! :odeler$ if not already runnin%. 0. Open pro.ect efficiency_techniques$ if not already open. a. (hoose File / Open / Project. b. Select efficiency_techniques. c. (lic, on Open. 1. Switch to random_mesh_leaks scenario. a. Press ,eys Ctrl-/ or choose Scenarios / S,itch to Scenario / random_mesh_lea*s. 9. (onfi%ure memory profile output at end of simulation. a. Press ,eys Ctrl-R. b. 8pand the tree #iew to Runtime Displays # emory &sa!e. c. (hec, +raph total memory usa!e durin! simulation. d. (hec, Sho, memory statistics panel. e. (hec, +enerate final usa!e data once simulation ends.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ," o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

<. 'un simulation. a. 'e#iew steps = to C below before startin% the simulation. @ou will perform actions while the simulation runs. b. (lic, on Run when ready. =. )mmediately$ chec, memory profile durin% simulation run. a. As soon as the simulation enters sta%e Je%innin% Simulation and the pro%ress bar updates itself$ clic, on the emory Stats tab. b. (lic, on +et @atest Data. c. Obser#e the memory profile statistics table. C. Obser#e memory lea,. a. (lic, on the emory &sa!e tab. b. !his %raph shows the real&time memory usa%e as the simulation proceeds. c. Obser#e the steady increase in memory usa%e.

H. *iew simulation termination memory profile. a. At the end of simulation$ memory statistics appear on the emory Stats pa%e. b. 'esi+e the Simulation Se5uence dialo% bo8 to ma,e the memory statistics table better #isible.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ,* o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

c. (hec, Sho, detailed data for additional statistics columns. d. (hec, Sho, differences for the difference in statistics between the last sample point and the simulation end. e. ;nchec, Sho, Differences.

I. *iew memory profilin% results. 5ype3 !ype of OPN ! :emory 6Pooled$ (ate%ori+ed$ %eneral$ or other7. (ame3 Name of the memory cate%ory. odel3 2hether cate%ory is owned by OPN ! internally or by models. <ytes3 Number of bytes for the pooled memory ob.ect 6not countin% H&byte o#erhead7. &se =6>3 Number of memory ob.ects in acti#e use. &se =$<>3 Amount of memory consumed by memory ob.ects in use. "lloc =6>3 Number of times ob.ects were allocated. Dealloc =6>3 Number of times ob.ects were deallocated. Free =6>3 Number of pooled ob.ects in free pool. Reserved =6>3 Number of reser#ed pooled ob.ects unused in bloc,s.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ,! o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

5otal =6>3 !otal number of allocated pooled ob.ects. Overhead =$<>3 !he internal o#erhead consumed by the OPN ! :emory AP). 5otal =$<>3 !otal ,ilobytes of allocated memory includin% all o#erhead.

-G. Obser#e lac, of debu%%in% information. a. (lic, on the &se =$<> column headin% to sort the data by the total number of bytes. Note that op_prg memory is the lar%est memory cate%ory. 2e do not ha#e any further brea,down of where this memory actually resides.

--. (lic, on Close. -0. Fo not close the pro.ect. )t is difficult to dia%nose a memory lea, without model&specific information. !he ne8t section will remedy that. (P)E* Pooled and Categori%ed 'emor$ + 'emor$ "sage )ode -. Switch to random4mesh4lea,s4pmo scenario. a. Press ,eys Ctrl- or choose Scenarios / S,itch to Scenario / random_mesh_lea*s_pmo. 0. Add a :emory ;sa%e node to pro.ect. a. Open the Ob.ect Palette. b. Switch to the &tilities palette$ if not already open.

c. Fra% a

emory &sa!e node to the pro.ect wor,space 6anywhere7.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ,, o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

d. 'i%ht&clic, on an empty spot in the Pro.ect ditor to end node creation mode. 1. (onfi%ure the :emory ;sa%e node. a. 'i%ht&clic, on the newly created :emory ;sa%e node. b. (hoose Edit "ttri1utes from the pop&up menu. c. Set the column. d. Set the emory &sa!e Samplin! )nterval attribute to 50 by double&clic,in% on the Aalue inimum emory &sa!e 5hreshold attribute to 200.

e. (lic, O$. f. Press ,eys Ctrl-S to sa#e the pro.ect. 9. (onfi%ure simulation ,ernel and console settin%s. a. Press ,eys Ctrl-R. b. Select the tree&#iew node Common. c. (hec, Sho, OP(E5 Console durin! simulation.
P)g$ ,# o+ ,-

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

1549 Accelerating Simulations Using Efficient Programming Techniques

d. (hec, Pause for user input 1efore closin! OP(E5 Console ,hen simulation ends. <. 'un simulation. a. (lic, on Run. =. See :emory ;sa%e node in action. a. Switch to the OPN ! (onsole window. b. !he :emory ;sa%e node %enerates memory statistics output e#ery <G simulation seconds 6as you confi%ured it7. C. *iew simulation termination memory profile. a. Jac, in the Pro.ect ditor$ at the end of the simulation$ memory statistics appear on the emory Stats pa%e. b. 'esi+e the Simulation Se5uence dialo% bo8 to ma,e the memory statistics table better #isible. c. (lic, on the &se =$<> column headin% to sort the data by the total number of bytes used.

Note that there are two new rows for hello entry and hello data that are :odel memory cate%ories. )t is li,ely that hello entry ob.ects are lea,in%. op_prg memory is not as lar%e as it was.

H. Switch to the OPN ! (onsole. I. Press the Enter ,ey to close the simulation console. -G. (lic, on Close in the Simulation Se5uence e8ecution dialo% bo8.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ,2 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

&OPTIO'!L( @ou can e8plore a snapshot of the models memory profile while the simulation runs. Lets see how to do this$ if you ha#e e8tra time. 'emor$ Profiling in the (P)E* De,ugger -(DB. -. (onfi%ure simulation ,ernel and console settin%s. a. Eo bac, to the Pro.ect ditor. b. Press ,eys Ctrl-R. c. Set Simulation $ernel to Development. d. 8pand the tree #iew to E'ecution # OP(E5 De1u!!er. e. (hec, &se OP(E5 Simulation De1u!!er =OD<>. 0. 'un simulation. a. (lic, on Run. b. Notice the OPN ! (onsole appear. c. 2ait for the OFJ prompt. d. 'un the simulation to time -GG seconds by typin% the followin% at the prompt3 od&-#tstop 100 od&-#c 1. Ad.ust the console window si+e for memory statistics #iewin%. a. )n the OPN ! (onsole$ press ,eys "lt-Space <ar. b. Select Properties. c. (lic, on tab @ayout. d. Set the Screen <uffer Si%e 7idth to 140. e. Set the 7indo, Si%e 7idth to 140. f. (lic, O$. %. Select Save properties for future ,indo,s ,ith same title. h. (lic, O$. 9. *iew li#e memory statistics in OFJ. a. !ype memstats at the OFJ prompt. b. !he memory statistics output is similar to the memory statistics in the Simulation Se5uence dialo% bo8.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ,3 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

c. !ype help memstats to #iew the different options for the command. d. !ype memstats long model data to #iew the profilin% entry for the hello data cate%ory.

<.

nd simulation. a. !ype quit at the OFJ prompt. b. Press the Enter ,ey to close the console window. c. Jac, in the Simulation Sequence dialo% bo8$ clic, Close.

"sing the (P)E* 'emor$ #P )f you ha#e time left$ lets re#iew the code chan%es made to use the OPN ! pooled memory AP) in our router model. -. Open the e8ternal source code editor. a. )n any editor$ choose File / Open : E'ternal Source =C code>.

b. (hec, Sho, all files of type BE'ternal Source =C code>C. c. Select eff_router_sup_pmo_ref$ which is an 8ternal >ile of process model eff_router_leaky_pmo. 0. *iew OPN ! :emory AP) use. a. *iew function eff_hello_data_create!) on line =G by pressin% ,eys Ctrl-2.

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ,4 o+ ,-

1549 Accelerating Simulations Using Efficient Programming Techniques

!his function calls op_pr(_p%o_def$)e!) once to set up the pooled memory handle. Allocations simply use the handle #ia op_pr(_p%o_alloc!). #ery time the pooled memory AP) allocates a new bloc, of ob.ects$ it will do so in -GGG&ob.ect increments.

1. (lose the editor. a. (hoose File / Close.

*onclusion
!he OPN ! :emory Statistics output and the :emory ;sa%e node ob.ect aid debu%%in% memory utili+ation issues in simulations. !he :emory Stats updates in the Simulation Se5uence e8ecution dialo% bo8 pro#ide a con#enient user interface for #iewin% the memory profilin% statistics output. @ou can in#esti%ate the primary memory consumers by usin% the OPN ! :emory AP)s pooled and cate%ori+ed memory ob.ects. @ou can also obtain more detailed memory profiles usin% the OPN ! Febu%%er and the %e% tat command in a li#e simulation. !he OF" %ta( family of commands help trac, down memory lea,s in the model. See session -<G1 for more details on usin% the OPN ! Simulation Febu%%er. ;sin% the tools learned in the lab$ you can dia%nose memory utili+ation issues in your simulations. After identifyin% candidates for memory optimi+ation$ use the principles from this session to reduce memory consumption of the model.
)'+ O, L!B 2

CONFIDENTIAL INFORMATION: DO NOT DISCLOSE, FORWARD, DISTRIBUTE, SHARE, OR MAKE COPIES OF THIS DOCUMENT IN WHOLE OR IN PART. Copyrigh !""# OPNET T$%h&o'ogi$(, I&%.

P)g$ ,- o+ ,-