SlideShare a Scribd company logo
1 of 20
Developing low-memory-footprint 
iSeries programs 
Prithiviraj Damodaran
Background 
 We all know programs, to run are brought into memory from disk by a system 
software called loader, by that we should also agree that programs can take 
quality chunk of memory although its case by case. iSeries world is no different. 
Programs are objects which are brought into memory (a.k.a. activated) when 
invoked in a job. 
 We are in the era of commodity hardware where in CPU or memory or disk space 
are made lot cheaper, but…. still they are not unlimited resources 
 We will focus on memory usage by application programs and how to make it as 
lean as possible. By doing this we may accomplish the following. 
o We can take advantage of the available memory for a real memory intensive process to 
satisfy a business problem. 
o We can do “more” quicker, because in computing world tasks compete either for CPU 
time or Memory to accomplish things. 
2
Agenda 
1. Understanding Program Activation better 
2. Learning the Memory equation 
3. Knowing types of memory allocations 
4. Learning to use minimum memory 
5. Summary of lesson learnt and key takeaways. 
3
Revisiting program activation 
4
Memory equation ! 
T = O(m) + S(m) + R(m) + S(d1…n) + O(d1…n) + A + Misc 
Where 
• O(m) – Object size of the Main program 
• S(m) – Static Storage of the Main Program 
• R (m) – Run time memory usage ex: IO / Disk into memory 
• S(d1..n) – Static storage of nth level dependant Service programs 
• O(d1..n) – Object size of nth level dependant Service programs 
• A – Automatic Storage 
5
So what makes up static storage 
• Bytes taken by all Static variables declared by YOU !! 
• File Control blocks. 
• OS Exception handling blocks. 
• Compiler Internal Variables 
T = O(m) + S(m) + R(m) + S(d1…n) + O(d1…n) + Misc 
6
How to know how much static storage your program uses? 
• DSPPGM DETAIL(*SIZE) 
• DSPMOD DETAIL(*SIZE) 
7
What? When Allocated? When De-allocated? 
Static / Stack All variables declared in the D-spec of the main 
section of program 
All variables declared in the D-Spec inside a sub-procedure 
with a static keyword 
When Program in Initialized or 
activated 
For DFTACTGRP(*YES) 
*INLR = *On 
 RCLRSC 
 Job ended 
For DFTACTGRP(*NO) 
*INLR =*On (except for sub-procedure 
variables with static 
keyword) 
RCLACTGRP 
Activation group ended 
Job ended 
Automatic All variables declared inside a sub-procedure 
without any static keyword 
When the procedure is invoked When the procedure is ended 
Dynamic / 
heap 
All the variables declared as pointers data types 
All the variables declared with based keyword 
And this is true only when these variables are 
initialized with %ALLOC BIF or ALLOC OPCODE. 
When %ALLOC BIF or ALLOC RPGLE 
OPCODE or MALLOC C method is 
executed 
When DEALLOC RPGLE 
OPCODE is executed 
RCLACTGRP for Non DAG 
 RCLRSC for DAG 
Type of memories 
8
Static Vs Dynamic 
Please note that unlike static storage, dynamic / heap allocation is not sequential (not to be 
confused with contiguous), That’s why dynamic allocation leads to memory leaking issues, 
that’s anyway out of scope for now. 
9
Work-skeet for calculating Static Storage usage 
Projected Memory Requirement with assumptions in MB 
# Process 
Static Storage of the 
program(s) in bytes Small Enterprise Medium Enterprise Large Enterprise 
1 Architecture Programs 
2 Never Ending Jobs/Programs 
Grand Total 
Parameter Small Medium Large 
Number of Concurrent Jobs (B + I ) 
Number of Concurrent Interactive users 
10 
Plugin some real world values to see how your applications is fairing. 
• Try populating the table 2 with data from your application/product inventory. small/medium/large applies only for products 
and not applications. Feel free combine these 3 columns into one in case of applications. Expand the table if required to 
add additional line items that may make sense for your case, 
• In table 1 list all architecture programs or programs whose instances run in more numbers static storage and multiply 
them with you respective values from table 2. As told before in case of products uses small/medium/large classification, 
incase of applications combine these columns into one.
Sample space of a application Static Storage usage 
Based on the the candidates taken for this analysis you will be able to foresee where your 
application is headed to. While we cannot give any benchmarks as the requirements could 
vary from industry to industry and enterprise to enterprise. 
1. But based on your knowledge about what is normal and what is abusive memory usage if 
your applications seems to be memory intensive product sooner or later, you can 
implement some of the solutions in the coming slides to fix it. 
2. Keeping a tab of the memory usage and having an eye for this every time architectures 
are amended can prevent your application/product from being a poor performing one. 
3. It is always better to know what is the minimum memory requirement of your 
application/product (version wise if product) to meet the promised SLA’s. 
11
Second look at the memory equation 
T = O(m) + S(m) + R(m) + S(d1…n) + O(d1…n) + Misc 
1 
2 
3 
12
Optimizing Static Storage usage 
Optimizing static memory S(m) 
• Be very judicious about declaring variables (both in terms of 
memory and run time) 
• Typical candidates to look out for 
 Variables declared in all programs where *INLR = *Off (typically Architecture 
code) 
 Arrays / DS used for caching configurations values 
 File Structure based DS arrays used for bulk SQL fetches 
 Large Alphanumeric variables to accommodate descriptions or long strings like 
dynamic Commands or SQL queries. 
 Declaring File Structures/DS for enabling LIKE definitions without TEMPLATE 
keyword or as based variable. 
 Unreferenced or dead program variables 
13
Optimizing Static Storage usage contd.. 
• Try moving variable declarations inside sub-procedures wherever 
possible as they become Automatic variables. But beware of the 
limitations of the automatic variables. 16Mb per call stack**. 
• Trying using heap instead of the stack by using dynamic memory 
allocation wherever possible. 
• We will shortly be coming up with a threshold amount of static 
storage for each program that is getting promoted via Change 
management tools. 
• This small monitor added to change management tool will raise an 
exception for the respective form line items during promotion and 
flag the developer. 
*16Mb is the upper limit for Automatic Storage in Single Level Storage STGMDL 
Alternately 1TB is the upper limit for Automatic Storage in Teraspace supported STGMDL 
14
Summary of Lessons Learned 
1. DEBUG option *NONE , this will affect Automatic Storage 
2. Sub-Procedures have a limit to amount of automatic storage it can use 
3. A call stack has a limit to the amount of automatic storage it can use 
4. Use of TEMPLATE structures using dummy pointer or TEMPLATE keyword 
where-ever possible can reduce memory usage. 
5. Avoid recursive static storages by using *DEFER as opposed to *IMMED in 
case of bind-by-references (Service Programs) 
6. Release memory on exceptions use RCLRSC or RCLACTGRP. 
7. Teraspace as opposed to Single level storage model has more automatic 
storage. Use this on a case by case basis. Full support available only in 
V7R1 for RPGLE. 
15
Some handy things to do 
1. Change management tool should have the ability to monitor the static storage 
for every program. 
2. In a reactive sense programs for which multiple copies could be activated in 
your application must be revisited to ensure their static storage usage is not 
exorbitant. 
3. Compile default for DBGVIEW should be changed to *NONE 
4. All new service programs getting added should use *DEFER for activation 
unless until *IMMED is required for a specific requirement. 
5. Should we track RNF7031 only for work variables ? 
16
Side Bar 
17
Single Level Storage Vs Teraspace 
• Single Level Storage maximum is -16MB 
• Teraspace Storage maximum is - 1TB 
• Each activation will have 2 Memory Stack one per storage model. 
Until V6R1 
Two levels of support 
• Teraspace Enabled (RPGLE/COBOL) 
• Teraspace Supported (C/C++/JAVA) 
V7R1 
• Teraspace Supported (RPGLE/COBOL/C/C++..) 
18
Why most upper limits in iSeries is 16MB? 
Space is a smallest Low level MI 
object maximum size of 16 MB 
Ex: If you see default size of a 
user space object is 16MB , 
although you can expand it at 
will. 
16MB 
16MB 
16MB 
16MB 
16MB 
16MB 
16MB 
16MB 
16MB 
19
What good a mistake is, if there is no 
learning out of it ? 
20

More Related Content

What's hot

An efficient approach for load balancing using dynamic ab algorithm in cloud ...
An efficient approach for load balancing using dynamic ab algorithm in cloud ...An efficient approach for load balancing using dynamic ab algorithm in cloud ...
An efficient approach for load balancing using dynamic ab algorithm in cloud ...bhavikpooja
 
Chap 2 classification of parralel architecture and introduction to parllel p...
Chap 2  classification of parralel architecture and introduction to parllel p...Chap 2  classification of parralel architecture and introduction to parllel p...
Chap 2 classification of parralel architecture and introduction to parllel p...Malobe Lottin Cyrille Marcel
 
Multi objective vm placement using cloudsim
Multi objective vm placement using cloudsimMulti objective vm placement using cloudsim
Multi objective vm placement using cloudsimKhalidAnsari60
 
A Comparative Study between Honeybee Foraging Behaviour Algorithm and Round ...
A Comparative Study between Honeybee Foraging Behaviour Algorithm and  Round ...A Comparative Study between Honeybee Foraging Behaviour Algorithm and  Round ...
A Comparative Study between Honeybee Foraging Behaviour Algorithm and Round ...sondhicse
 
Load Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newpptLoad Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newpptUtshab Saha
 
Research Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel ProgrammingResearch Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel ProgrammingShitalkumar Sukhdeve
 
Hadoop Map Reduce OS
Hadoop Map Reduce OSHadoop Map Reduce OS
Hadoop Map Reduce OSVedant Mane
 
TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6Sravanthi N
 
network ram parallel computing
network ram parallel computingnetwork ram parallel computing
network ram parallel computingNiranjana Ambadi
 
Cloud and distributed computing, advantages
Cloud and distributed computing, advantagesCloud and distributed computing, advantages
Cloud and distributed computing, advantagesknowledgeworld7
 
Introducing MapReduce Programming Framework
Introducing MapReduce Programming FrameworkIntroducing MapReduce Programming Framework
Introducing MapReduce Programming FrameworkSamuel Yee
 
Introduction to Parallel Computing
Introduction to Parallel ComputingIntroduction to Parallel Computing
Introduction to Parallel ComputingAkhila Prabhakaran
 
Cloud computing overview
Cloud computing overviewCloud computing overview
Cloud computing overviewkarthik s
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecturePankaj Kumar Jain
 
Cpu performance matrix
Cpu performance matrixCpu performance matrix
Cpu performance matrixRehman baig
 

What's hot (19)

Computer performance
Computer performanceComputer performance
Computer performance
 
Hpc 1
Hpc 1Hpc 1
Hpc 1
 
Parallel computing
Parallel computingParallel computing
Parallel computing
 
An efficient approach for load balancing using dynamic ab algorithm in cloud ...
An efficient approach for load balancing using dynamic ab algorithm in cloud ...An efficient approach for load balancing using dynamic ab algorithm in cloud ...
An efficient approach for load balancing using dynamic ab algorithm in cloud ...
 
Chap 2 classification of parralel architecture and introduction to parllel p...
Chap 2  classification of parralel architecture and introduction to parllel p...Chap 2  classification of parralel architecture and introduction to parllel p...
Chap 2 classification of parralel architecture and introduction to parllel p...
 
Multi objective vm placement using cloudsim
Multi objective vm placement using cloudsimMulti objective vm placement using cloudsim
Multi objective vm placement using cloudsim
 
A Comparative Study between Honeybee Foraging Behaviour Algorithm and Round ...
A Comparative Study between Honeybee Foraging Behaviour Algorithm and  Round ...A Comparative Study between Honeybee Foraging Behaviour Algorithm and  Round ...
A Comparative Study between Honeybee Foraging Behaviour Algorithm and Round ...
 
Load Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newpptLoad Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newppt
 
Clone cloud
Clone cloudClone cloud
Clone cloud
 
Research Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel ProgrammingResearch Scope in Parallel Computing And Parallel Programming
Research Scope in Parallel Computing And Parallel Programming
 
Hadoop Map Reduce OS
Hadoop Map Reduce OSHadoop Map Reduce OS
Hadoop Map Reduce OS
 
TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6
 
network ram parallel computing
network ram parallel computingnetwork ram parallel computing
network ram parallel computing
 
Cloud and distributed computing, advantages
Cloud and distributed computing, advantagesCloud and distributed computing, advantages
Cloud and distributed computing, advantages
 
Introducing MapReduce Programming Framework
Introducing MapReduce Programming FrameworkIntroducing MapReduce Programming Framework
Introducing MapReduce Programming Framework
 
Introduction to Parallel Computing
Introduction to Parallel ComputingIntroduction to Parallel Computing
Introduction to Parallel Computing
 
Cloud computing overview
Cloud computing overviewCloud computing overview
Cloud computing overview
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
 
Cpu performance matrix
Cpu performance matrixCpu performance matrix
Cpu performance matrix
 

Similar to Low memory footprint programs-iSeries

How to do Memory Optimizations in Android
How to do Memory Optimizations in AndroidHow to do Memory Optimizations in Android
How to do Memory Optimizations in AndroidSingsys Pte Ltd
 
Sap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptxSap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptxsweta prakash sahoo
 
PASS Spanish Recomendaciones para entornos de SQL Server productivos
PASS Spanish   Recomendaciones para entornos de SQL Server productivosPASS Spanish   Recomendaciones para entornos de SQL Server productivos
PASS Spanish Recomendaciones para entornos de SQL Server productivosJavier Villegas
 
Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...
Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...
Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...IndicThreads
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)jaxLondonConference
 
Ppt on embedded system
Ppt on embedded systemPpt on embedded system
Ppt on embedded systemPankaj joshi
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1rohassanie
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingPVS-Studio
 
Overlay Technique | Pebble Developer Retreat 2014
Overlay Technique | Pebble Developer Retreat 2014Overlay Technique | Pebble Developer Retreat 2014
Overlay Technique | Pebble Developer Retreat 2014Pebble Technology
 
Kubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad Assis
Kubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad AssisKubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad Assis
Kubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad AssisAgileSparks
 
Jstorm introduction-0.9.6
Jstorm introduction-0.9.6Jstorm introduction-0.9.6
Jstorm introduction-0.9.6longda feng
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices Amgad Muhammad
 
Cse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solutionCse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solutionShobha Kumar
 
13.Windows Phone Store
13.Windows Phone Store13.Windows Phone Store
13.Windows Phone StoreNguyen Tuan
 
New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...
New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...
New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...Paul Hofmann
 
St22 abap programming
St22 abap programming St22 abap programming
St22 abap programming nanda nanda
 
programming errors
programming errorsprogramming errors
programming errorsnanda nanda
 
Stored-Procedures-Presentation
Stored-Procedures-PresentationStored-Procedures-Presentation
Stored-Procedures-PresentationChuck Walker
 

Similar to Low memory footprint programs-iSeries (20)

How to do Memory Optimizations in Android
How to do Memory Optimizations in AndroidHow to do Memory Optimizations in Android
How to do Memory Optimizations in Android
 
Sap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptxSap memory management ,workload and performance analysis.pptx
Sap memory management ,workload and performance analysis.pptx
 
PASS Spanish Recomendaciones para entornos de SQL Server productivos
PASS Spanish   Recomendaciones para entornos de SQL Server productivosPASS Spanish   Recomendaciones para entornos de SQL Server productivos
PASS Spanish Recomendaciones para entornos de SQL Server productivos
 
Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...
Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...
Performance in Android: Tips and Techniques [IndicThreads Mobile Application ...
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)
 
Ppt on embedded system
Ppt on embedded systemPpt on embedded system
Ppt on embedded system
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code logging
 
SAP Basis Overview
SAP Basis OverviewSAP Basis Overview
SAP Basis Overview
 
Overlay Technique | Pebble Developer Retreat 2014
Overlay Technique | Pebble Developer Retreat 2014Overlay Technique | Pebble Developer Retreat 2014
Overlay Technique | Pebble Developer Retreat 2014
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony apps
 
Kubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad Assis
Kubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad AssisKubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad Assis
Kubernetes is Hard! Lessons Learned Taking Our Apps to Kubernetes by Eldad Assis
 
Jstorm introduction-0.9.6
Jstorm introduction-0.9.6Jstorm introduction-0.9.6
Jstorm introduction-0.9.6
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices
 
Cse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solutionCse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solution
 
13.Windows Phone Store
13.Windows Phone Store13.Windows Phone Store
13.Windows Phone Store
 
New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...
New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...
New Business Applications Powered by In-Memory Technology @MIT Forum for Supp...
 
St22 abap programming
St22 abap programming St22 abap programming
St22 abap programming
 
programming errors
programming errorsprogramming errors
programming errors
 
Stored-Procedures-Presentation
Stored-Procedures-PresentationStored-Procedures-Presentation
Stored-Procedures-Presentation
 

Recently uploaded

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Recently uploaded (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

Low memory footprint programs-iSeries

  • 1. Developing low-memory-footprint iSeries programs Prithiviraj Damodaran
  • 2. Background  We all know programs, to run are brought into memory from disk by a system software called loader, by that we should also agree that programs can take quality chunk of memory although its case by case. iSeries world is no different. Programs are objects which are brought into memory (a.k.a. activated) when invoked in a job.  We are in the era of commodity hardware where in CPU or memory or disk space are made lot cheaper, but…. still they are not unlimited resources  We will focus on memory usage by application programs and how to make it as lean as possible. By doing this we may accomplish the following. o We can take advantage of the available memory for a real memory intensive process to satisfy a business problem. o We can do “more” quicker, because in computing world tasks compete either for CPU time or Memory to accomplish things. 2
  • 3. Agenda 1. Understanding Program Activation better 2. Learning the Memory equation 3. Knowing types of memory allocations 4. Learning to use minimum memory 5. Summary of lesson learnt and key takeaways. 3
  • 5. Memory equation ! T = O(m) + S(m) + R(m) + S(d1…n) + O(d1…n) + A + Misc Where • O(m) – Object size of the Main program • S(m) – Static Storage of the Main Program • R (m) – Run time memory usage ex: IO / Disk into memory • S(d1..n) – Static storage of nth level dependant Service programs • O(d1..n) – Object size of nth level dependant Service programs • A – Automatic Storage 5
  • 6. So what makes up static storage • Bytes taken by all Static variables declared by YOU !! • File Control blocks. • OS Exception handling blocks. • Compiler Internal Variables T = O(m) + S(m) + R(m) + S(d1…n) + O(d1…n) + Misc 6
  • 7. How to know how much static storage your program uses? • DSPPGM DETAIL(*SIZE) • DSPMOD DETAIL(*SIZE) 7
  • 8. What? When Allocated? When De-allocated? Static / Stack All variables declared in the D-spec of the main section of program All variables declared in the D-Spec inside a sub-procedure with a static keyword When Program in Initialized or activated For DFTACTGRP(*YES) *INLR = *On  RCLRSC  Job ended For DFTACTGRP(*NO) *INLR =*On (except for sub-procedure variables with static keyword) RCLACTGRP Activation group ended Job ended Automatic All variables declared inside a sub-procedure without any static keyword When the procedure is invoked When the procedure is ended Dynamic / heap All the variables declared as pointers data types All the variables declared with based keyword And this is true only when these variables are initialized with %ALLOC BIF or ALLOC OPCODE. When %ALLOC BIF or ALLOC RPGLE OPCODE or MALLOC C method is executed When DEALLOC RPGLE OPCODE is executed RCLACTGRP for Non DAG  RCLRSC for DAG Type of memories 8
  • 9. Static Vs Dynamic Please note that unlike static storage, dynamic / heap allocation is not sequential (not to be confused with contiguous), That’s why dynamic allocation leads to memory leaking issues, that’s anyway out of scope for now. 9
  • 10. Work-skeet for calculating Static Storage usage Projected Memory Requirement with assumptions in MB # Process Static Storage of the program(s) in bytes Small Enterprise Medium Enterprise Large Enterprise 1 Architecture Programs 2 Never Ending Jobs/Programs Grand Total Parameter Small Medium Large Number of Concurrent Jobs (B + I ) Number of Concurrent Interactive users 10 Plugin some real world values to see how your applications is fairing. • Try populating the table 2 with data from your application/product inventory. small/medium/large applies only for products and not applications. Feel free combine these 3 columns into one in case of applications. Expand the table if required to add additional line items that may make sense for your case, • In table 1 list all architecture programs or programs whose instances run in more numbers static storage and multiply them with you respective values from table 2. As told before in case of products uses small/medium/large classification, incase of applications combine these columns into one.
  • 11. Sample space of a application Static Storage usage Based on the the candidates taken for this analysis you will be able to foresee where your application is headed to. While we cannot give any benchmarks as the requirements could vary from industry to industry and enterprise to enterprise. 1. But based on your knowledge about what is normal and what is abusive memory usage if your applications seems to be memory intensive product sooner or later, you can implement some of the solutions in the coming slides to fix it. 2. Keeping a tab of the memory usage and having an eye for this every time architectures are amended can prevent your application/product from being a poor performing one. 3. It is always better to know what is the minimum memory requirement of your application/product (version wise if product) to meet the promised SLA’s. 11
  • 12. Second look at the memory equation T = O(m) + S(m) + R(m) + S(d1…n) + O(d1…n) + Misc 1 2 3 12
  • 13. Optimizing Static Storage usage Optimizing static memory S(m) • Be very judicious about declaring variables (both in terms of memory and run time) • Typical candidates to look out for  Variables declared in all programs where *INLR = *Off (typically Architecture code)  Arrays / DS used for caching configurations values  File Structure based DS arrays used for bulk SQL fetches  Large Alphanumeric variables to accommodate descriptions or long strings like dynamic Commands or SQL queries.  Declaring File Structures/DS for enabling LIKE definitions without TEMPLATE keyword or as based variable.  Unreferenced or dead program variables 13
  • 14. Optimizing Static Storage usage contd.. • Try moving variable declarations inside sub-procedures wherever possible as they become Automatic variables. But beware of the limitations of the automatic variables. 16Mb per call stack**. • Trying using heap instead of the stack by using dynamic memory allocation wherever possible. • We will shortly be coming up with a threshold amount of static storage for each program that is getting promoted via Change management tools. • This small monitor added to change management tool will raise an exception for the respective form line items during promotion and flag the developer. *16Mb is the upper limit for Automatic Storage in Single Level Storage STGMDL Alternately 1TB is the upper limit for Automatic Storage in Teraspace supported STGMDL 14
  • 15. Summary of Lessons Learned 1. DEBUG option *NONE , this will affect Automatic Storage 2. Sub-Procedures have a limit to amount of automatic storage it can use 3. A call stack has a limit to the amount of automatic storage it can use 4. Use of TEMPLATE structures using dummy pointer or TEMPLATE keyword where-ever possible can reduce memory usage. 5. Avoid recursive static storages by using *DEFER as opposed to *IMMED in case of bind-by-references (Service Programs) 6. Release memory on exceptions use RCLRSC or RCLACTGRP. 7. Teraspace as opposed to Single level storage model has more automatic storage. Use this on a case by case basis. Full support available only in V7R1 for RPGLE. 15
  • 16. Some handy things to do 1. Change management tool should have the ability to monitor the static storage for every program. 2. In a reactive sense programs for which multiple copies could be activated in your application must be revisited to ensure their static storage usage is not exorbitant. 3. Compile default for DBGVIEW should be changed to *NONE 4. All new service programs getting added should use *DEFER for activation unless until *IMMED is required for a specific requirement. 5. Should we track RNF7031 only for work variables ? 16
  • 18. Single Level Storage Vs Teraspace • Single Level Storage maximum is -16MB • Teraspace Storage maximum is - 1TB • Each activation will have 2 Memory Stack one per storage model. Until V6R1 Two levels of support • Teraspace Enabled (RPGLE/COBOL) • Teraspace Supported (C/C++/JAVA) V7R1 • Teraspace Supported (RPGLE/COBOL/C/C++..) 18
  • 19. Why most upper limits in iSeries is 16MB? Space is a smallest Low level MI object maximum size of 16 MB Ex: If you see default size of a user space object is 16MB , although you can expand it at will. 16MB 16MB 16MB 16MB 16MB 16MB 16MB 16MB 16MB 19
  • 20. What good a mistake is, if there is no learning out of it ? 20