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

Claus Stadler commented on JENA-1862:
-------------------------------------

Hi, 1230 test cases are now working; 4 excluded (see below)
For the query string SELECT * { ?s ?p ?o } the clone per second performances on 
my machine are roughly:
PrintParse: 42.729 cps
Transform: 1.869.158 cps
So roughly 50K vs 2M which is a speedup factor of ~40

There are two issues which I think are not related to my code:

- Query.valueDataBlock is not copied by QueryTransformOps - probably this 
should be done; maybe wrapping it as an ElementData passing it through the 
given ElementTransformer?
- QueryTransformOps has a statement that says that the top level element is 
always a ElementGroup - however the 4 excluded test case files parse into a 
Query with a ElementSubQuery as the top level object. What behavior is 
preferred in this case?


> Query.cloneQuery is slow
> ------------------------
>
>                 Key: JENA-1862
>                 URL: https://issues.apache.org/jira/browse/JENA-1862
>             Project: Apache Jena
>          Issue Type: Improvement
>          Components: ARQ
>    Affects Versions: Jena 3.14.0
>            Reporter: Claus Stadler
>            Priority: Major
>
> This is a follow up to JENA-1861 which is about the thread safety of Query 
> objects. As sharing a Query object across threads may introduce race 
> conditions, the obvious workaround would be to just clone it. However, the 
> current implementation serializes the query to string and then re-parses it 
> which causes a very high overhead (for my use case it became the top entry in 
> the VisualVM profiler).
> Proposal:
>  * Extend ElementTransformCopyBase with a 'alwaysCopy' flag analogous to 
> ExprTransformCopy
>  * Add a new constructor to 
> ExprTransformApplyElementTransform(ElementTransform transform, boolean 
> alwaysCopy) so that the alwayCopy flag of the underlying ExprTransformCopy 
> can be set to true
>  * Implement clone using syntatic transforms as below
> {code:java}
> public static Query fastClone(Query query) {
>     ElementTransform eltXform = new ElementTransformCopyBase2(true);
>     ExprTransform exprXform = new 
> ExprTransformApplyElementTransform2(eltXform, true);
>     Query result = QueryTransformOps.transform(query, eltXform, exprXform);
>     return result;
> }
> {code}
> This approach 'works-for-me' and I can create a pull request for this, but 
> maybe there are more subtleties to the outlined approach that need to be 
> considered?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to