CFSET - Strange Performance Issue

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

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?

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

See below
First Run

Subsequent Runs

The UnScoped version appears to be faster… :thinking: TryCF.com

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?

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.

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

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

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 @Zackster’s results on his local machine, which I expect that he ran as a standalone script.