Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow in Models.matchModels #1441

Closed
ArkanEmre opened this issue Jun 5, 2019 · 8 comments
Closed

Stack overflow in Models.matchModels #1441

ArkanEmre opened this issue Jun 5, 2019 · 8 comments
Labels
🐞 bug issue is a bug M2 Fixed in milestone 2
Milestone

Comments

@ArkanEmre
Copy link

Hi everyone,

I wanted to compare two RDF Datasets with Models.isomorphic function. They both have around 50000 Statements, unfortunately this triggers a stack overflow due to a recursive call in the Models class. Here is the link to the line where the recursive call happens.

It is also commented by the developer that it should be fixed. Do you know of any solutions?

Best regards,
Emre

@barthanssens barthanssens added the 🐞 bug issue is a bug label Jun 6, 2019
@abrokenjester
Copy link
Contributor

I haven't looked in detail but generally speaking the solution would be to rewrite as an iterative algorithm. A common way to do that is to introduce an explicit stack (instead of relying on the programming stack).

@hmottestad
Copy link
Contributor

I've had huge issues with Models.isomorphic in RDF4J. In my previous project we used RDF4J everywhere except for isomorphic. Here we converted our model to a JSON-LD string and parsed it into Jena and ran isomorphic there. This was considerably faster.

@abrokenjester
Copy link
Contributor

I don't think a performance refactor would be particularly difficult. I'll try and take a stab at it over the weekend.

@abrokenjester
Copy link
Contributor

I'll try and take a stab at it over the weekend.

Ok so that didn't happen. If anyone else wants to have a go be my guest :)

hmottestad added a commit that referenced this issue Jul 5, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 5, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
@hmottestad
Copy link
Contributor

I've created some benchmarks for us for reference: #1476

All based on files I made or found in other places. The spin-full-forwardchained.ttl file actually triggers the stack overflow, so that's good.

hmottestad added a commit that referenced this issue Jul 5, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
@hmottestad
Copy link
Contributor

I found another case of stack overflow. A lot of properties seems to be the trigger. So now we have two stack overflow cases and a bunch of other benchmarks. Here are the results on my ageing macbook pro.

# Run complete. Total time: 00:05:02

Benchmark                                 Mode  Cnt    Score    Error  Units
IsomorphicBenchmark.blankNodes            avgt   10    0.614 ±  0.007  ms/op
IsomorphicBenchmark.bsbm                  avgt   10  810.974 ± 60.225  ms/op
IsomorphicBenchmark.empty                 avgt   10    0.132 ±  0.002  ms/op
IsomorphicBenchmark.internallyIsomorphic  avgt   10   43.071 ±  0.833  ms/op
IsomorphicBenchmark.list                  avgt   10    8.167 ±  0.096  ms/op
IsomorphicBenchmark.longChain             avgt   10    3.097 ±  0.066  ms/op
IsomorphicBenchmark.manyProperties2       avgt   10  248.785 ± 59.606  ms/op
IsomorphicBenchmark.shacl                 avgt   10    7.022 ±  0.141  ms/op
IsomorphicBenchmark.sparqlTestCase        avgt   10    0.915 ±  0.026  ms/op

hmottestad added a commit that referenced this issue Jul 12, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 12, 2019
…odel

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 12, 2019
…ts SET if possible

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 12, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…odel

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…ts SET if possible

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…odel

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…ts SET if possible

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…odel

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…ts SET if possible

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…odel

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…ts SET if possible

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…odel

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
…ts SET if possible

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit that referenced this issue Jul 14, 2019
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
@hmottestad hmottestad modified the milestones: 2.5.4, 3.0 Jul 14, 2019
@hmottestad
Copy link
Contributor

@ArkanEmre this is now fixed and will be released as part of either the next minor or major release (whichever comes first). You can likely try it tomorrow by using 3.0-SNAPSHOT as your version.

@ArkanEmre
Copy link
Author

@hmottestad Thank you!

@hmottestad hmottestad added the M2 Fixed in milestone 2 label Jul 23, 2019
@hmottestad hmottestad modified the milestones: 2.5.4, 3.0 Jul 23, 2019
@abrokenjester abrokenjester modified the milestones: 3.0.0, 2.5.4 Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug M2 Fixed in milestone 2
Projects
None yet
Development

No branches or pull requests

4 participants