performance improvement tip coldbox

Hi Coldbox Developers,

Ive noticed that functions calls like f(argumentCollection=arguments)
use a lot more cpu time then when the arguments are mentioned
explicitly. Its in the range of some 10's of ms per page call,
depending on how much functions with this construct are called.

The one from coldbox that gives me the most lag is
frameworksypertype.getPlugin.

The arguments could easily be added explicitly to the function as they
all have default values (so not if elseif etc. needed).

greets,
klaas-jan

interesting, so you are saying instead of using argumentCollection, type out all the arguments?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

I’d be curious to see some benchmarks around this.

Yea me too as I am. All about increasing performance with a few
changes but I they are worth it

I dont see any big difference on Railo 8,0,0,1 final 3.1.2.001 Barry:
http://coldbox3.platform.ch/pubtests/argtest.cfm

Daniel
lists@platform.ch

That test is not comparing fairly. The first example is not creating /
populating the struct inside the loop.

I tweaked the test a bit to make it a fairer comparison and wrapped it
in cfsilent so you're not timing whitespace generation(!) etc (see
below) and consistently saw:

Railo: argumentCollection passing is 10-20% slower. CF9:
argumentCollection passing is 30-50% slower.

Updated test:

<cfsilent>
<cfset n = 100000 />

<cffunction name="returnValue" access="public" returntype="String"
output="false">
  <---************************************************************** --->
  <cfargument name="sString" type="string" required="true" />
  <cfargument name="iInteger" type="numeric" required="true" />
  <cfargument name="stStruct" type="struct" required="true" />
  <---************************************************************** --->
  <--- Local call to get the user object from the session --->
  <cfset var _l = structNew() />
  <cfset var result = arguments.sString & ': [' & arguments.iInteger &
']<br />' />
  <cfreturn result />
</cffunction>

<cfset s = getTickCount() />
<cfloop from="1" to="#n#" index="i">
  <cfset stStruct = structNew() />
  <cfset stStruct['sString'] = 'This is String No' />
  <cfset stStruct['iInteger'] = i />
  <cfset stStruct['stStruct'] = StructNew() />
  <cfset x = returnValue(argumentCollection=stStruct) />
</cfloop>
</cfsilent>
<cfoutput>
argumentCollection took #getTickCount()-s#ms.
</cfoutput>
<cfsilent>
<cfset s = getTickCount() />
<cfloop from="1" to="#n#" index="i">
  <cfset stStruct = structNew() />
  <cfset stStruct['sString'] = 'This is String No' />
  <cfset stStruct['iInteger'] = i />
  <cfset stStruct['stStruct'] = StructNew() />
  <cfset x = returnValue(stStruct.sString,stStruct.iInteger,stStruct.stStruct) />
</cfloop>
</cfsilent>
<cfoutput>
pass args ##1 took #getTickCount()-s#ms.
</cfoutput>
<cfsilent>
<cfset s = getTickCount() />
<cfloop from="1" to="#n#" index="i">
  <cfset stStruct = structNew() />
  <cfset stStruct['sString'] = 'This is String No' />
  <cfset stStruct['iInteger'] = i />
  <cfset stStruct['stStruct'] = StructNew() />
  <cfset x = returnValue('This is String No',i,structNew()) />
</cfloop>
</cfsilent>
<cfoutput>
pass args ##2 took #getTickCount()-s#ms.
</cfoutput>

@luis: yes, id suggest to type them out,

I forgot to mention that i found this by using Oracle JRockit mission
control. I did a JRA recording for 1 minute while refreshing a page of
the site im developing. Then i had a look at hot methods, where i
found that getPlugin is spending a relative large percentage on the
argumentCollection thing.

It seems that Sean's tests confirm this right?

greets,
klaas

Btw, luis, Oracle Jrockit mission control would be a great tool to
have a look at where you can improve the performance of coldbox.
I had a page on my site that first took 3 seconds, using mission
control i made improvements to make that 80ms per page call.

greets,
klaas

Just be aware that you can't write them out explicitly if they're
optional - as in Andrew Scott's thread about renderView() - when
dealing with optional arguments, you pretty much have to use
argumentCollection to pass them through...

You could use if / elseif /elseif.. right? Though its a bit tedious

Thanks Klass, I will keep this in mind not for M6 since that is almost done, but for our release candidate.

Also, I will download JRockit

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

I just did some tests here locally, as I wanted to look directly at the most common use case, which is directly passing ‘arguments’ to another CFC as as argumentCollection.

The test I wrote was the following:

Test.cfc