You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Stian Soiland-Reyes (JIRA)" <ji...@apache.org> on 2015/09/13 04:11:45 UTC

[jira] [Updated] (JENA-1026) listIndividuals performance issue

     [ https://issues.apache.org/jira/browse/JENA-1026?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stian Soiland-Reyes updated JENA-1026:
--------------------------------------
    Attachment: OntologiaDeAlimentos.owl

> listIndividuals performance issue
> ---------------------------------
>
>                 Key: JENA-1026
>                 URL: https://issues.apache.org/jira/browse/JENA-1026
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Ontology API
>    Affects Versions: Jena 3.0.0
>         Environment: Verified on Jena 3.0.1-SNAPSHOT (2015-09-13) w/ Ubuntu 14.04/x64, 4 cores i7-3520M, 16G ram, SSD disk, Open JDK 1.8.0_45-internal
>            Reporter: Stian Soiland-Reyes
>            Priority: Minor
>         Attachments: OntologiaDeAlimentos.owl
>
>
> As reported by Maria Clementina Latanzi on dev@jena 2015-09-12:
> {quote}
> I'm working with Jena. I have an ontology with no more than 50 individuals,
> and I use Jena to
> get individuals from Ontology by calling *listIndividual* (
> *com.hp.hpl.jena.ontology.OntModel.listIndividuals*). When I call this
> method, it's taking a lot of time up to 20 seconds. When debugging, it
> takes more than 1 minute to return. Other methods like *listClass *return
> instantly.
> {quote}
> {code}
> package testOnto;
> import java.io.InputStream;
> import java.util.ArrayList;
> import java.util.Iterator;
> import com.hp.hpl.jena.ontology.Individual;
> import com.hp.hpl.jena.ontology.OntClass;
> import com.hp.hpl.jena.ontology.OntModel;
> import com.hp.hpl.jena.rdf.model.ModelFactory;
> import com.hp.hpl.jena.rdf.model.Resource;
> import com.hp.hpl.jena.rdf.model.Property;
> import com.hp.hpl.jena.rdf.model.StmtIterator;
> import com.hp.hpl.jena.rdf.model.impl.StatementImpl;
> import com.hp.hpl.jena.shared.JenaException;
> import com.hp.hpl.jena.util.FileManager;
> import com.hp.hpl.jena.util.iterator.ExtendedIterator;
> public class onto {
> 	static String Ontofile =
> "C:/Users/Sig/Clemen/OntologiasArchivos/OntologiaIngesta.owl";
> 	public static void main(String[] args) {
> 		//crea ontologia
> 		OntModel m = ModelFactory.createOntologyModel();
> 		try {
> 			InputStream in =
> FileManager.get().open("C:/Users/Sig/Clemen/OntologiasArchivos/OntologiaDeAlimentos.owl");
>             if (in ==null) {
>             	System.out.println("ERROR abriendo archivo" + Ontofile);
>             	return;
>             	}
>             else {  m.read(in, "RDF/XML");
>                	System.out.println("archivo" + Ontofile + "leido
> exitosamente" );
>             	}
>         } catch (JenaException je) {
>         	System.out.println("ERROR leyendo archivo" + je.getMessage());
>             je.printStackTrace();
>             System.exit(0);
>         }
> 				long startMilC = System.currentTimeMillis();
>         System.out.println("Start list classes: " + startMilC);
>         ExtendedIterator classes = m.listClasses();
>         long endMilC = System.currentTimeMillis();
>         System.out.println("Duration ListIndividuals: " + (endMilC -
> startMilC));
>             long startMil = System.currentTimeMillis();
>         System.out.println("Start ListIndividuals: " + startMil);
>         ExtendedIterator individuos = m.listIndividuals();
>                  long endMil = System.currentTimeMillis();
>         System.out.println("Duration ListIndividuals: " + (endMil -
> startMil));
> 	}
> }
> {code}
> See attached ontology and test case.
> Verified against current 3.0.1-SNAPSHOT.



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

Re: [jira] [Updated] (JENA-1026) listIndividuals performance issue

Posted by Stian Soiland-Reyes <st...@apache.org>.
When doing any kind of performance testing, there is a difference from
'cold start' and 'warm start'. running like this in a main() will
include initializing lots of Java classes across Jena.

I therefore rewrote the test to repeat your main() 10 times, which
improves a bit over time, (e.g. from 5s to 1.5 s on quiet system, or
from 25s to 20s on busy system)



Still I thought this is a bit excessive, so I checked with JProfiler.


98% of the time is spent inside nested iterators, which ultimately
leads to LPInterpreter.run() (29k calls) and its constituent parts for
the inference rule system (TripleMatchFrame.nextMatch (271k calls),
setupTabledCall (206k calls), setupTripleMatchCall (61k calls) and
Node.sameValueAs (3 million calls)).



LPInterpreter.run() is quite a long method, so it's a bit harder to
figure out which of these bits are contributing:

https://github.com/apache/jena/blob/jena-3.0.0-rc1/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/impl/LPInterpreter.java#L243



I tried disabling your equivalentClasses, but that does not change the
numbers much.


changing the ontology model spec with

    ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM)

or OWL_DL_MEM_RULE_INF
or OWL_MEM_MINI_RULE_INF

pushes the execution from 25 seconds to 20 seconds. I didn't test this
excessively to determine if there truly was a difference.


Adding a AllDifferent statement to make individuals different didn't
affect the runtime. I think this is caused by deep recursion in the
forward-rule system - but I don't know for which rules yet.   (that
would be virtual recursion in a while-loop, not on the Java stack)



On 13 September 2015 at 03:11, Stian Soiland-Reyes (JIRA)
<ji...@apache.org> wrote:
>
>      [ https://issues.apache.org/jira/browse/JENA-1026?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Stian Soiland-Reyes updated JENA-1026:
> --------------------------------------
>     Attachment: OntologiaDeAlimentos.owl
>
>> listIndividuals performance issue
>> ---------------------------------
>>
>>                 Key: JENA-1026
>>                 URL: https://issues.apache.org/jira/browse/JENA-1026
>>             Project: Apache Jena
>>          Issue Type: Bug
>>          Components: Ontology API
>>    Affects Versions: Jena 3.0.0
>>         Environment: Verified on Jena 3.0.1-SNAPSHOT (2015-09-13) w/ Ubuntu 14.04/x64, 4 cores i7-3520M, 16G ram, SSD disk, Open JDK 1.8.0_45-internal
>>            Reporter: Stian Soiland-Reyes
>>            Priority: Minor
>>         Attachments: OntologiaDeAlimentos.owl
>>
>>
>> As reported by Maria Clementina Latanzi on dev@jena 2015-09-12:
>> {quote}
>> I'm working with Jena. I have an ontology with no more than 50 individuals,
>> and I use Jena to
>> get individuals from Ontology by calling *listIndividual* (
>> *com.hp.hpl.jena.ontology.OntModel.listIndividuals*). When I call this
>> method, it's taking a lot of time up to 20 seconds. When debugging, it
>> takes more than 1 minute to return. Other methods like *listClass *return
>> instantly.
>> {quote}
>> {code}
>> package testOnto;
>> import java.io.InputStream;
>> import java.util.ArrayList;
>> import java.util.Iterator;
>> import com.hp.hpl.jena.ontology.Individual;
>> import com.hp.hpl.jena.ontology.OntClass;
>> import com.hp.hpl.jena.ontology.OntModel;
>> import com.hp.hpl.jena.rdf.model.ModelFactory;
>> import com.hp.hpl.jena.rdf.model.Resource;
>> import com.hp.hpl.jena.rdf.model.Property;
>> import com.hp.hpl.jena.rdf.model.StmtIterator;
>> import com.hp.hpl.jena.rdf.model.impl.StatementImpl;
>> import com.hp.hpl.jena.shared.JenaException;
>> import com.hp.hpl.jena.util.FileManager;
>> import com.hp.hpl.jena.util.iterator.ExtendedIterator;
>> public class onto {
>>       static String Ontofile =
>> "C:/Users/Sig/Clemen/OntologiasArchivos/OntologiaIngesta.owl";
>>       public static void main(String[] args) {
>>               //crea ontologia
>>               OntModel m = ModelFactory.createOntologyModel();
>>               try {
>>                       InputStream in =
>> FileManager.get().open("C:/Users/Sig/Clemen/OntologiasArchivos/OntologiaDeAlimentos.owl");
>>             if (in ==null) {
>>               System.out.println("ERROR abriendo archivo" + Ontofile);
>>               return;
>>               }
>>             else {  m.read(in, "RDF/XML");
>>                       System.out.println("archivo" + Ontofile + "leido
>> exitosamente" );
>>               }
>>         } catch (JenaException je) {
>>               System.out.println("ERROR leyendo archivo" + je.getMessage());
>>             je.printStackTrace();
>>             System.exit(0);
>>         }
>>                               long startMilC = System.currentTimeMillis();
>>         System.out.println("Start list classes: " + startMilC);
>>         ExtendedIterator classes = m.listClasses();
>>         long endMilC = System.currentTimeMillis();
>>         System.out.println("Duration ListIndividuals: " + (endMilC -
>> startMilC));
>>             long startMil = System.currentTimeMillis();
>>         System.out.println("Start ListIndividuals: " + startMil);
>>         ExtendedIterator individuos = m.listIndividuals();
>>                  long endMil = System.currentTimeMillis();
>>         System.out.println("Duration ListIndividuals: " + (endMil -
>> startMil));
>>       }
>> }
>> {code}
>> See attached ontology and test case.
>> Verified against current 3.0.1-SNAPSHOT.
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)



-- 
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718