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

pre-building indexes & Safari iOS #330

Open
LorenzoSerino opened this issue Feb 16, 2018 · 2 comments
Open

pre-building indexes & Safari iOS #330

LorenzoSerino opened this issue Feb 16, 2018 · 2 comments

Comments

@LorenzoSerino
Copy link

Hello olivernn, i report there is a problem using pre-building indexes on Safari iOS

iOS Resource Limits

  • JavaScript execution time
    limited to 10 seconds for each top-level entry point. If your script executes for more than 10 seconds, Safari on iOS stops executing the script at a random place in your code, so unintended consequences may result.

using the pre-building indexes with data dimension >= 1M : Safari stop the executing script and crashes.

The offending code line seems to be:

var idx = lunr.Index.load(JSON.parse(data))

in detail : JSON.parse(data)
i try to verify the CPU time :

var t0 = performance.now();
JSON.parse(data)
var t1 = performance.now();
console.log("Call to JSON.parse(data) took " + (t1 - t0) + " milliseconds.")

and the CPU time is very higth in comparison to a simple object vector/map strings. The relationship is ten to one.

I think the problem is in floating point conversion but i'm not sure.

So i gave up of pre-building indexes.

@olivernn
Copy link
Owner

Thanks for reporting this, out of interest, how large is the serialised index that you are trying to load?

I've been thinking of providing a non JSON serialisation of the index, the original reason was to reduce the size of the index, but having some format that could be parsed in a way that is less expensive than JSON (or at least could pause to avoid these long executions) would be another benefit.

@andrejpavlovic
Copy link

andrejpavlovic commented Dec 20, 2018

Using something like Oboe.js helps prevent iOS from crashing, but then it takes 10 times longer to parse the index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants