IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL Performance Tuning


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 137
Location: brisbane

PostPosted: Wed Dec 02, 2020 12:12 pm
Reply with quote

I have a requirement to write a security module for which I need to optimise for performance as far as possible.

some considerations:
- this will only ever run on Z/OS with COBOL 6.2 or higher
- compiler options will include ARCH(12)
- module will execute 10,000+ times per day
- within one transaction unit, module may be executed anywhere from 1 to 100 times

problem 1. How best to initialise a large array of primes.

I need to store the first 10,000 primes (>2) in an array structure (with binary usage). The following example demonstrates one way of doing this (cut down to the first four primes > 2)

Code:
01 PRIME-NOS PIC X(32) VALUE X'0000000300000005000000070000000B'.
01 FILLER REDEFINES PRIME-NOS OCCURS 4 TIMES.
   05 PRIME-NO PIC 99999 USAGE BINARY.


which seems to work fine, but it suffers somewhat from readability.

is there a better way to present this without compromising performance ? Any compiler directive that might do some of the heavy lifting ?



problem 2. fastest way to unpack a numeric.

I need a fast way to unpack a numeric, for it to be used in a dot product such as :

eg : 7234567 ==> (7,2,3,4,5,6,7) . (n1, n2, n3 .. n7) = 7n1 + 2n2 + ... + 7n7

I could either do something like :

Code:
   05 ws-input-digits pic 9(16).
   05 ws-input-digit  redefines ws-input-digits occurs 16 times pic 9.



... or copy to BCD, and then unpack. Which would be more efficient ?

input could be up to PIC 9(16), and could be within an array structure.
as in problem 1, I want the individual digits to have binary usage.


any other tips that can help appreciated. Also, do i need to do anything to exploit ZIIP processing ?
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1312
Location: Vilnius, Lithuania

PostPosted: Wed Dec 02, 2020 7:20 pm
Reply with quote

You don't write security modules, you use commercial ones that have been thoroughly tested and use approved security standards.

Period. Full stop. End of story!
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Wed Dec 02, 2020 10:22 pm
Reply with quote

prino is 100% correct. Security is awfully difficult.

As for primes. Prepare your list and read them in as required rather than prepare a new list every time. It might not be "faster" in elapsed time, but it will certainly be "faster" in CPU time.

As for preparing a list. A technique called the Sieve of Eratosthenes is the best known, though probably not the fastest. Heck, I did that in the 1960s.

Good luck.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 03, 2020 10:36 pm
Reply with quote

Quote:
Also, do i need to do anything to exploit ZIIP processing ?
zIIP processors are for DB2 and Java work, primarily. Certain other workloads will also run on a zIIP, but you generally cannot do anything specifically to exploit the zIIP engine. Nothing you've posted indicates that you're doing anything that could run on a zIIP engine. The work that can run on a zIIP engine will usually run there automatically (even in DB2, not all work is zIIP-eligible).
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10879
Location: italy

PostPosted: Fri Dec 04, 2020 12:10 am
Reply with quote

Quote:
As for preparing a list. A technique called the Sieve of Eratosthenes is the best known, though probably not the fastest. Heck, I did that in the 1960s.


no reason to waste time coding,
lists for special numbers are available and can be downloaded

just the first link returned googling with "list of primes"

https://primes.utm.edu/lists/small/10000.txt
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10879
Location: italy

PostPosted: Fri Dec 04, 2020 12:15 am
Reply with quote

as usual people just focus on the lowly technical details

cryptography, security and friends is/are not just code,

there are implications for the organisation, auditing, training, ... ...
but above all legal and certification considerations

and I would never trust an algorithm developed using free forum consultancy icon_cool.gif
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 137
Location: brisbane

PostPosted: Fri Dec 04, 2020 10:10 am
Reply with quote

agree with what's been posted above.

for the record, I've finished coding what I was asked to code, and have suggested to the business sponsor that they consider this piece of work as a POC (proof of concept), rather than something that should be moved into production.

By no means a wasted exercise : It's not often I get to combine my passion for number theory with programming.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts Compile Sp Cobol base COBOL Programming 1
No new posts SQLCODE=-311 in Cobol SP-DB2. COBOL Programming 2
No new posts Two where-criteria with GT - Performa... DB2 4
No new posts COBOL 6.4 - User Defined Function nee... COBOL Programming 6
Search our Forums:

Back to Top