CFSET - Strange Performance Issue


#1

I was noticing in doing my performance testing on a site using a debugging template that I was getting really slow performance on a page that does nothing but set default variables.

So I have a test page I setup and am seeing something really strange.

I have an include file that has 247 default variables for a site. That include takes about 50ms-70ms which seems really high to me. So I moved the values to a page instead of the include and wrapped them in a cftimer and the results remained the exact same.

I did a test and if I just do a

<cfset _site.blah = "">

I get the bad performance

doing a find and replace and change _site to variables._site

<cfset variables._site.blah = "">

and all the performance issues go away.

What my question is HOW IS THIS POSSIBLE? If the default for un-scoped variables is the variables scope how can they perform different? I am not accessing the variables so scope cascading does not come in to play here.

http://www.iqwdev.com/testing


#2

which version of lucee are you running? please always include the version when asking questions

could you create a reproducible code sample on http://trycf.com and save a gist (ctrl-s) and post it here?


#3

I see this on the very first run of the above code, subsequent runs I show no difference.

See below
First Run

Subsequent Runs


#4

The UnScoped version appears to be faster… :thinking: https://trycf.com/scratch-pad/gist/29be52fa287f379fe4e0e8ae6b7c6813


#5

i added some extra variables and runs, because it was too simple and comparing 1ms vs 0ms doesn’t tell us much

Ralio 4.2
image

Lucee 4.5 times out after 50s

Lucee.latest 5.2.7.62
image

Lucee 5.3 (running on my i7 desktop)
image

Which confirms what @Ivan says, unscoped variables performing 30% faster? @isapir ?

Which version of Lucee are you running @Lyle_Karstensen?


#6

The trycf results are a puzzler, but it looks like the 5.3 results on your laptop are more as-expected. I can’t tell much without some deep testing of my own.


#7

p.s. I modified your script slightly for a better optimized loop (cfloop from-to vs. for loop):


#8

If you change the scope from “variables” to “local” the scoped version is faster.


#9

#10

Good observation.

It looks to me like the snippets in trycf.com are executed inside a function, and not as a standalone script.

That would explain the Local over Variables preference, as well as the discrepancy with @Zac_Spitzer’s results on his local machine, which I expect that he ran as a standalone script.