Location, Location, Location

  “Location, Location, Location”.  That old real estate mantra has a significant application to certain assembler programs.  If you’re writing programs that are I/O-intensive – programs that read hundreds of thousands of records, particularly those with large record sizes, then this old chestnut can help you cut your running times dramatically.  If you are fortunate, you may slash your running time in half, simply by making some small changes in your code.

   For years I never gave much thought to the difference between Move Mode I/O and Locate Mode I/O.  (If you’re not familiar with these two techniques you can check out an article that explains it here.)  Oh, I knew how to code both, but Move Mode was easier to teach, and delivered the goods right where you wanted them.  I knew that Move Mode records were being moved from a system buffer to my own storage, but I figured:  What’s an extra move or two among friends?  But I was wrong.  Working with companies that routinely process millions of records taught me otherwise.

   In Locate Mode, you can leave an input record in a system buffer and work with it directly.  On output, you locate an empty buffer and build your record there.  This simple technique works wonders if you are processing hundreds of thousands of large records.  The cool part is that it doesn’t take much refactoring of your code to switch over.  So if you are faced with processing hundreds of thousands of records, just remember:  Location, Location, Location.

Leave a Reply