-
Notifications
You must be signed in to change notification settings - Fork 36
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
getSolidDataset is blocking #1158
Comments
Hi @mrkvon, thanks for reaching out ! I'm not entierly sure, and I'm still investigating the issue, but what you are describing may be the symptom of a performance issue : it looks like the event loop gets stuck when processing the fetched data, which blocks other async calls from happening. I can reproduce the behaviour in NodeJS as well with the following snippet:
This shows that |
Indeed that's consistent: First, the turtle document gets fetched, async. So the event loop is still available for other stuff, like Then the parsed data gets further processed, synchronously. As you mentioned, the event loop gets stuck here. Specifically:
I figured that out by putting a couple Even more specifically, the culprit seems to be To fix thisIt would be useful to understand:
There seem to be O(|V| + |E|) algorithms for detecting cycles. I suspect the algorithm used by Here my knowledge of the issue ends. I hope the above analysis may help... Alternatives?Are there other, less powerful and less heavy methods in this library to fetch and process Otherwise one can always use Or do you have other ideas? |
Thanks for the very detailed analysis @mrkvon! It even helped me find and fix a related bug :) In #1173 I have submitted a PR that simply skips the chain detection algorithm if there are more than 20 Blank Nodes, since it's non-essential. That should solve/work around the 60-second block. You can give it a try today by installing the preview release using
If you could let us know whether it improves the situation for you, that would be great :) Parsing a Resource with many statements is unfortunately still expensive, and likely will be for a bit. For future reference, here's some ideas of things we could do:
|
@Vinnl Indeed with the fix, the blocking (of the
🎉 so I suppose this is as good as it gets. (also the size of the document at https://ruben.verborgh.org/profile/#me seems to be an exception rather than a regularity, so hopefully people won't bump into this issue very often)
Further thoughtsMaybe for some use cases the developer could make their own |
The change has now been shipped in 1.10.1. I'll keep this issue open for posterity in case someone wants to look into making parsing non-blocking too. |
Try upgrading all other packages, too Because there is a fix of the parsers getting stuck on big files They'll still get stuck, but not that long. inrupt/solid-client-js#1158
Search terms you've used
Bug description
Overview
When executing
getSolidDataset
with a particularly largeturtle
file, a javascript app freezes for a whileThe
async
nature ofgetSolidDataset
would suggest that the code is non-blocking, but the actual behaviour suggests otherwise.Example
An app would freeze for 71 seconds when running
getSolidDataset('https://ruben.verborgh.org/profile/#me')
Detail
On a closer look, it seems that the blocking code is the following:
Blocks for 60 seconds:
https://github.com/inrupt/solid-client-js/blob/main/src/rdfjs.internal.ts#L317-L319
Blocks for 11 seconds:
https://github.com/inrupt/solid-client-js/blob/main/src/rdfjs.internal.ts#L326-L347
Maybe these pieces of code could be more efficient? Maybe they run with high time complexity? (
Didn't study it in detailseems like a long-running cycle detecting algorithm)The time is just an example. Of course it will take different times in different context.
To Reproduce
import { getSolidDataset } from '@inrupt/solid-client'
await getSolidDataset('https://ruben.verborgh.org/profile/#me')
Minimal reproduction
Used a custom code sandbox, not the one provided here.
code sandbox: https://codesandbox.io/s/gracious-buck-7xyvj?file=/src/index.ts
resulting app: https://7xyvj.csb.app/
Expected result
When
await getSolidDataset('https://ruben.verborgh.org/profile/#me')
is executed within an app, the app keeps running.The
getSolidDataset
either runs faster, or runs asynchronously or both.Actual result
The app freezes for a long time.
Environment
Additional
If you want to see a production app running into this issue, you can open a solid friends crawler, stay logged out and watch for a while, until the app reaches the profile
https://ruben.verborgh.org/profile/#me
and freezesThe text was updated successfully, but these errors were encountered: