remulasce / metroapp

Realtime arrival notification utility for LA Metro
2 stars 0 forks source link

Improve autocomplete lookup speed #228

Closed remulasce closed 9 years ago

remulasce commented 9 years ago

We're doing things super naively. Half our time is taken up removing secondary entrances- we can do that offline and preload it in a table. Or we can just remove all the extra entrances, which we never actually use.

This would mean taking out Nighelles's script, which he helpfully made.

remulasce commented 9 years ago

Actually, using the script-generated database would eliminate these types of stops completely.

I wonder how the scripted database would end up handling multiple platforms to single stopids, though. All rail on LA Metro have double platforms with identical stopids and names, but different stoptags.

remulasce commented 9 years ago

Ok. so the script checks for duplicate stopids and throws them out.

That works.

remulasce commented 9 years ago

Actually no it doesn't. It compares stopid to the stoptag to check duplicates, which doesn't work with the _1 suffix for additional platforms.

remulasce commented 9 years ago

See #229

remulasce commented 9 years ago

Ok, that issue is closed. So we can do this now.

nighelles commented 9 years ago

Only issue is that the databases for lametro and lametrorail aren't the same in my scraped databases.

Maybe I can just use sqlite3 to merge those two.

nighelles commented 9 years ago

Ok, fixed that. Is the only extra loop the one in SQLPreloadedStopsReader?

remulasce commented 9 years ago

And, it's on the burner.

remulasce commented 9 years ago

Also, what does "extra loop" mean?

remulasce commented 9 years ago

So, now that we've put in multi-agency support, we go back to not actually knowing how fast we are.

So, I'm testing any speed difference.

remulasce commented 9 years ago

Speed tests:

Setup:

4 groups: Commit 128ae6 (dev_4) Launch from AS with debugging Commit 128ae6 (dev_4) Launch from homescreen after force closing debugged app Commit 792b29 (dev_5) Launch from AS with debugging Commit 792b29 (dev_5) Launch from homescreen after force closing debugged app

Text "sta" was set as the default text in the input text field in AS. App was then opened, causing autocomplete to immediately calculate on "sta", as the app loaded. Time spent in MetroStaticsProvider:autocompleteStopName(...) was tracked.

Results:

Summary

A performance improvement between 2x to 5x was observed.

So, that's pretty damn good.

Data:

Times are in ms

dev_4 Debug dev_5 Debug
3044 2434
1949 863
2004 921
2003 438
1884 924
dev_4 Homescreen dev_5 Homescreen
405 122
442 90
469 78
444 113
619 92
nighelles commented 9 years ago

Nice