(lucee scope).keyExists( someKey ) performs very differently from StructKeyExists( (lucee scope), someKey )

Description

I have been spending time optimizing the memory usage of our application and found that something like request.keyExists( someKey ) is not only slower than StructKeyExists( request, someKey ), but it also uses considerably more memory in my testing using FusionReactor.

Is there anything fundamental here that can't be changed/helped? I'm presuming this applies to other BIFs vs object methods also.

Worth noting, that if we do something regularCfmlStruct.keyExists( someKey ), the memory usage is much less than when performing it on a CFML scope, but still more than StructKeyExists().

Environment

None

Attachments

1
  • 07 May 2023, 04:29 pm

Activity

Show:

Zac Spitzer 26 July 2024 at 11:52

<cfscript> request.keyExists("zac"); // paramPageContext.getFunction(paramPageContext.requestScope(), KeyConstants._keyExists, new Object[] { "zac" }); structkeyExists(request, "zac"); // StructKeyExists.call(paramPageContext, Caster.toStruct(paramPageContext.requestScope()), keys[0]); st ={}; //((PageContextImpl)paramPageContext).us(KeyConstants._ST, LiteralStruct.call(paramPageContext, new Object[0])); st.keyExists("zac"); //paramPageContext.getFunction(paramPageContext.us().getCollection(KeyConstants._ST), KeyConstants._keyExists, new Object[] { "zac" }); structkeyExists(st, "zac"); //StructKeyExists.call(paramPageContext, Caster.toStruct(((PageContextImpl)paramPageContext).us(KeyConstants._ST)), keys[0]); </cfscript>

would using keys[0] rather than “zac” make any difference here?

Dominic Watson 7 May 2023 at 16:58

no, both

Zac Spitzer 7 May 2023 at 16:29
Edited

so only a memory issue rather than performance?

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

public final Object call(PageContext paramPageContext) throws Throwable { if (true) { char c1; byte b1; for (c1 = ', b1 = 1; b1 <= c1; ) { paramPageContext.getFunction(paramPageContext.requestScope(), this.keys[0], new Object[] { "zac" }); b1++; } char c2; byte b2; for (c2 = ', b2 = 1; b2 <= c2; ) { StructKeyExists.call(paramPageContext, Caster.toStruct(paramPageContext.requestScope()), this.keys[1]); b2++; } paramPageContext.us().set(this.keys[2], LiteralStruct.call(paramPageContext, new Object[0])); char c3; byte b3; for (c3 = ', b3 = 1; b3 <= c3; ) { paramPageContext.getFunction(paramPageContext.us().getCollection(this.keys[2]), this.keys[0], new Object[] { "zac" }); b3++; } char c4; byte b4; for (c4 = ', b4 = 1; b4 <= c4; ) { StructKeyExists.call(paramPageContext, Caster.toStruct(paramPageContext.us().get(this.keys[2])), this.keys[1]); b4++; } } return null; }

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Created 25 June 2019 at 20:52
Updated 26 July 2024 at 11:52

Flag notifications