Live Webinar: The Pareto Principle & How the 80/20 Rule Applies to Windows Servicing - August 27, 2019 Register Now

Native System Calls v.s. SCALE

Feb 05, 2019 | | Free Tools
tachyon scale language

The winner by a mile is…SCALE, of course.

Recently, I took on a project to create a Tachyon instruction that would extract the uninstall string data that is required for an AppClarity administrator to create custom uninstall strings if required.  Being relatively new to SCALE, I did what any good developer would do. I checked out the University of Google to find out how to query registry strings.  Turns out, there is a Windows command line tool named reg.exe that will do just that when you use the “query” option.

It was clear that the easiest way to manage the process of collecting the data I needed was to find all keys in the uninstall registry locations. I needed this for both the Windows 32 and Windows 64 bit install areas – namely:

             HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall

               And

               HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

Once I had all the keys, I then used a Do loop to cycle through each key.  Then I could pull back the Values for the relevant registry Names.  The Registry names I needed were:

   DisplayName

              DisplayVerion

              UninstallString

              QuietUninstallString

For completeness, I also included the registry key being queried and if the application was a 32 or 64-bit application.

Writing the Instruction Using the Native RunCommand

All straight-forward so far.  I used the NativeServices.RunCommand to query the registry for each of the above entries (once to get all the uninstall keys, then 4 times per registry key to capture the values of each registry name).  This meant setting up a command environment (4*number of uninstalling keys +1) – that’s a large processing infrastructure to set up and tear down each time.

I did a review of the work with the Tachyon Product Manager. During,  he asked why I had not used the native registry commands that were available in SCALE.  A snappy answer I should have given was – they didn’t show up in Google, but all I could say was, I didn’t know SCALE had native commands for that – let me have a look.

Writing the Instruction Using SCALE

It was extremely simple to change the code to use the native SCALE commands.  In fact, because SCALE returns specific components of the data I needed to work with, the code was even more straight-forward because I didn’t need to use string manipulation to extract the values I needed from the reg query command.  This meant that the instruction with nice formatting went from 174 lines to 98 lines  (note, this includes the fact that the instruction is written to play nice in a cross-platform environment and to return “Not Implemented” when executed on any non-Windows platform).

I figured that the SCALE only implementation would be faster, but I didn’t realize how much faster.  On a reasonably loaded expert services notebook – here’s the breakdown:

Command with reg query Native Scale
Processing time~3 minutes (179098 ms)~½ second (509 ms)
CPU Utilization20-40% extra load for durationNot measurable

 

Using the native SCALE commands was about 350 times faster. It also changed the CPU impact from being a concern to not even being noticeable.

The speed and size of the development effort, as well as the significant performance benefits you get from using Tachyon’s SCALE language, provide a very clear advantage over any other product that’s relying on command line scripting!

In fact, the SCALE instruction is so much faster, that it made sense to include an additional command that returns only the uninstall command line for a specified software title.

Definitely check out what is available in SCALE before you even think about the antiquated approach of using operating system level scripting or commands.  Doing the work in native SCALE will be faster. As a result, it will significantly lower resource impact on the devices under management!

Share this post

Share this post on your favorite social media platform.

Find this article useful?

If so please click here