You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2015/10/06 11:50:27 UTC

[jira] [Commented] (JENA-1044) Significant performance improvement in E_Bound

    [ https://issues.apache.org/jira/browse/JENA-1044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944809#comment-14944809 ] 

Andy Seaborne commented on JENA-1044:
-------------------------------------

Makes sense.

Some clarification points: 

* what do the two images show? The two stacks look very different.
* Just to check - which version of Jena? - although this area has not changed much any time recently.
* Which JVM and version are you using?

The "NodeValue" case can occur via prebinding but also in streamed execution.  We should keep the general expression case even though it can't be written in SPARQL; it might conceivably arise via direct algebra construction or manipulation. Keeping the case is no extra cost.

(For the record - an exception that overrides {{fillInStackTrace}} is apparently quite fast.  It is collecting the stack trace that is most of the cost of an exception but such special exceptions make maintenance harder.)

{noformat}
    @Override
    public NodeValue evalSpecial(Binding binding, FunctionEnv env)
    { 
        if ( expr.isConstant() )
            // The case of the variable already being substituted for a constant.
            return NodeValue.FALSE ;
        
        if ( expr.isVariable() )
            // The case of the expr being a single variable. 
            return NodeValue.booleanReturn(binding.contains(expr.asVar())) ; 
        
        // General expression.
		try {
			expr.eval(binding, env) ;
            return NodeValue.TRUE ;
		} catch (VariableNotBoundException ex) {
			return NodeValue.FALSE ;
		}
    }
{noformat}

> Significant performance improvement in E_Bound
> ----------------------------------------------
>
>                 Key: JENA-1044
>                 URL: https://issues.apache.org/jira/browse/JENA-1044
>             Project: Apache Jena
>          Issue Type: Improvement
>            Reporter: Robert Mercer
>            Priority: Minor
>         Attachments: PercentTime_clean.png, RuntimeException_clean.png
>
>
> I would like to suggest a significant performance improvement that I've seen occurring in various setups. Basically the issue occurs if you do a bound(?somethingthatsnotbound) this causes an "internal" runtime exception to be thrown down in the code which in turn is caught and handled by returning a false from E_Bound. This only occurs in the case of a bound(?x) returning false. This is an issue as runtimeexceptions are very costly and if you do this quite a lot in your query or attempt to do many queries that have lots of bound() functions in them you can end up with significant performance degradation. 
> Suggested fix in E_Bound.java
> {noformat}
> @Override
> 	public NodeValue evalSpecial(Binding binding, FunctionEnv env)
> 	{ 
> 		if (expr instanceof NodeValue){
> 			return NodeValue.TRUE; // probably just our code has this case as we do some prebindings.
> 		} else {
> 			return binding.contains(expr.asVar()) ? NodeValue.TRUE : NodeValue.FALSE; 
> 		}
> 	} 
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)