unscoped access to arguments scope is very slow

Description

Over and over again, I've found that via the implicit access debugging shows that the arguments scope is a real bottleneck for Lucee applications. I guess this is partly due to the local scope taking precedence over arguments.

But I just ported an old cf8 application across and I could only achieve the same CF8 performance after scoping all the arguments.

A lot of the PRs I have made for Lucee all involved just var scoping arguments, often inside tiny functions, which produced huge performance increases.

I know there is some overhead with debugging, the unscoped variable debugging bypasses certain scopes like UDF this, super and static.
https://github.com/lucee/Lucee/blob/5.3/core/src/main/java/lucee/runtime/type/scope/UndefinedImpl.java#L242

Environment

None

Activity

Show:
Michael Offner
May 20, 2020, 6:47 AM

a static approach like shown in the link above, is not very performant, but for sure faster than any dynamic approach.

Michael Offner
May 20, 2020, 7:16 AM

i created a test

https://trycf.com/gist/c3e97f8c79c4ede209582cb00b354860/lucee5?theme=monokai

and it shows a difference of around 12% on a more or less empty function with one read and write access. When i only do a read access the difference goes down to 4%, so write access seems worse than read access.

We also see that no scope access when the requested variables is in the local scope is nearly identical to define a scope.

Michael Offner
May 20, 2020, 7:22 AM

Possible solutions on this.

  • Improve the current solution without any changes in logic (unlikely to have success)

  • add the possibility to set the argument scope to read only (little success)

  • integrate the argument scope into the local scope as ACF does (ugly but will improve performance)

  • add a flag to merge the scope, so “arguments” will simply be an alias for “local“ (big success but will affect the logic of current applications)

Assignee

Unassigned

Reporter

Zac Spitzer

Priority

New

Labels

Fix versions

None

Affects versions