dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

ScriptRouter should cache CompiledScript

Open likebean opened this issue 9 years ago • 1 comments

看到每次route都去compilable.compile,是否应该在构造函数里compile,每次route直接用CompiledScript,这样性能应该有提升。

public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
    try {
        List<Invoker<T>> invokersCopy = new ArrayList<Invoker<T>>(invokers);
        Compilable compilable = (Compilable) engine;
        Bindings bindings = engine.createBindings();
        bindings.put("invokers", invokersCopy);
        bindings.put("invocation", invocation);
        bindings.put("context", RpcContext.getContext());
        CompiledScript function = compilable.compile(rule);

likebean avatar Mar 07 '17 12:03 likebean

This issue is fixed from 2.7.1 onwards.

ralf0131 avatar Feb 21 '19 08:02 ralf0131