Skip to content

Commit

Permalink
try using larger args scope of 8 depending on args length
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Nov 11, 2024
1 parent e3ed5d2 commit 362acfa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
6 changes: 5 additions & 1 deletion core/src/main/java/lucee/runtime/type/UDFImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ else if (cacheHandler != null) { // TODO this else block can be removed when all
private Object _call(PageContext pc, Collection.Key calledName, Object[] args, Struct values, boolean doIncludePath, Argument newArgs) throws PageException {
PageContextImpl pci = (PageContextImpl) pc;
boolean existingNewArgs = newArgs != null;
if (!existingNewArgs) newArgs = pci.getScopeFactory().getArgumentInstance();

if (!existingNewArgs){
if (args == null) newArgs = pci.getScopeFactory().getArgumentInstance();
else newArgs = pci.getScopeFactory().getArgumentInstance(args.length);
}
newArgs.setFunctionArgumentNames(properties.getArgumentsSet());
LocalImpl newLocal = pci.getScopeFactory().getLocalInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ public final class ArgumentImpl extends ScopeSupport implements Argument, ArrayP
*/
public ArgumentImpl() {
// super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED, 4);
super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED_NOT_SYNC, 8);
super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED_NOT_SYNC, 4);
}

public ArgumentImpl(int size) {
// super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED, 4);
super("arguments", SCOPE_ARGUMENTS, StructImpl.TYPE_LINKED_NOT_SYNC, size);
}

@Override
Expand Down
28 changes: 18 additions & 10 deletions core/src/main/java/lucee/runtime/type/scope/ScopeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.concurrent.ConcurrentLinkedQueue;

import lucee.runtime.PageContext;
//import lucee.aprint;

/**
* creates Local and Argument scopes and recyle it
Expand All @@ -38,49 +39,56 @@ public final class ScopeFactory {
* @return returns an Argument scope
*/
public Argument getArgumentInstance() {
/*
Argument arg = arguments.poll();
if (arg != null) {
return arg;
}
*/
//aprint.o("arguments new! " + arguments.size());
return new ArgumentImpl();
}

/**
* @return returns an Argument scope
*/
public Argument getArgumentInstance(int size) {
Argument arg = arguments.poll();
if (arg != null) {
return arg;
}
//aprint.o("arguments new! " + arguments.size());
return size > 3 ? new ArgumentImpl(8) : new ArgumentImpl();
}

/**
* @return retruns a Local Instance
*/
public LocalImpl getLocalInstance() {
/* LocalImpl lcl = locals.poll();
LocalImpl lcl = locals.poll();
if (lcl != null) {
return lcl;
}
*/
//aprint.o("local new! " + locals.size());
return new LocalImpl();
}

/**
* @param argument recycle an Argument scope for reuse
*/
public void recycle(PageContext pc, Argument argument) {
return;
/*
if (arguments.size() >= MAX_SIZE || argument.isBind()) return;
//if (argument.size() > 0) aprint.o("arg: " + argument.size());
argument.release(pc);
arguments.add(argument);
*/
}

/**
* @param local recycle a Local scope for reuse
*/
public void recycle(PageContext pc, LocalImpl local) {
return;
/*
if (locals.size() >= MAX_SIZE || local.isBind()) return;
//if (local.size() > 0) aprint.o("local: " + local.size());
local.release(pc);
locals.add(local);
*/
}

/**
Expand Down

0 comments on commit 362acfa

Please sign in to comment.