LinkedDataFragments / Client.js

[DEPRECATED] A JavaScript client for Triple Pattern Fragments interfaces.
http://linkeddatafragments.org/
Other
92 stars 35 forks source link

Possible performance difference between ldf-client and ldf-client-http #48

Closed joachimvh closed 4 years ago

joachimvh commented 6 years ago

The following query was executed both on ldf-client and ldf-client-http:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT ?movie ?title ?name
WHERE {
   ?movie dbpedia-owl:starring [ rdfs:label \"Brad Pitt\"@en ];
   rdfs:label ?title;
   dbpedia-owl:director [ rdfs:label ?name ].
}

Using ldf-client, for me this gets executed in +- 1200ms. On the other hand, with ldf-client-http and the following code to send the query, it takes +- 1700ms before the stream is terminated (same machine).


const fs = require('fs');
const http = require('http');

let query = fs.readFileSync('sparql/bradpitt.sparql', 'utf8');

const options = {
  hostname: 'localhost',
  port: 3000,
  path: '/sparql',
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
  }
};

console.time('TIMER');
const req = http.request(options, res => {
  res.on('data', data => { });
  res.on('end', () => { console.timeEnd('TIMER');});
});

req.write('query=' + query);
req.end();

I tried one other query (select 10000 triples) but there I had slowdown due to printing all the results (although ldf-client was also faster, 3s vs 4s, when disabling the output, but that might be biased). Most interesting would be a query that doesn't have many results but takes a longer time to see if this is a constant extra time or if it scales.

joachimvh commented 6 years ago

Also tested this with curl:

curl http://localhost:3000/sparql -X POST -g -d "query=PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>  SELECT ?movie ?title ?name WHERE {   ?movie dbpedia-owl:starring [ rdfs:label \"Brad Pitt\"@en ];          rdfs:label ?title;          dbpedia-owl:director [ rdfs:label ?name ]. }" -w %{time_total}

Which has pretty much the same result. Also didn't realize this but I still had the timer in ldf-client so I also got the result from that (since ldf-client-http spawns a process of ldf-client) and the result there corresponded to the original ldf-client result. So the delay is probably somewhere in the spawning the or http communication.

RubenVerborgh commented 6 years ago

Makes me wonder about https://github.com/LinkedDataFragments/Client.js/blob/v2.0.5/bin/ldf-client-http#L99 again too.

rubensworks commented 4 years ago

This project has now been deprecated in favor of Comunica, where this should not be a problem anymore. If it is, feel free to open a new issue there.