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

Use all bus data #84

Closed
Katsute opened this issue Sep 19, 2022 · 10 comments · Fixed by #111
Closed

Use all bus data #84

Katsute opened this issue Sep 19, 2022 · 10 comments · Fixed by #111
Assignees
Labels
mta-bus Bus related issues and features optimization
Milestone

Comments

@Katsute
Copy link
Member

Katsute commented Sep 19, 2022

Feature

Anytime a bus is requested:

  1. Check the cache
  2. Pull data for all busses
  3. Parse
  4. Fulfill the request

Reason

Current implementation runs a new request for every bus which is not efficient for enterprise. Requesting all busses then parsing is more efficient when submitting multiple requests.

@Katsute Katsute added optimization mta-bus Bus related issues and features labels Sep 19, 2022
@Katsute
Copy link
Member Author

Katsute commented Sep 22, 2022

Use similar binary search implemented in #90 against bus line not possible

Store raw data in cache, DO NOT STORE OBJECTS; will cause memory issues.

< 10,000 busses

https://bt.mta.info/wiki/Developers/SIRIVehicleMonitoring

Please note that the calls made without either a VehicleRef or LineRef produces quite a load on the system, so use them sparingly. Any developers found to be making repeated calls (e.g. at less than 30 second intervals) for all vehicles in the system may find their key revoked.

@Katsute
Copy link
Member Author

Katsute commented Oct 3, 2022

Only this subclass needs to be modified

Stop monitoring should derive values from vehicle request if possible.

@Katsute
Copy link
Member Author

Katsute commented Oct 3, 2022

JSON parser needs to be massively optimized to avoid memory issues; use JIT (just-in-time) parsing, where we load immediate keys into memory, then parse the subsequent object when requested.


This count needs to be optimized to only run once: not possible due to split logic

final long count = Regex9.count(quotes.reset(after));

https://sites.google.com/site/gson/streaming

https://stackoverflow.com/a/11876086

Regex may actually be more inefficient since we are rescanning the string multiple times. Use character loop stream instead.


Return a method to parse for:

else if(arrayMatcher.group("array") != null) // open new array
list.add(openArray(reader, json));
else if(arrayMatcher.group("map") != null) // open new map
list.add(openMap(reader, json));

and

else if(mapMatcher.group("array") != null) // open new array
obj.set(key, openArray(reader, json));
else if(mapMatcher.group("map") != null) // open new map
obj.set(key, openMap(reader, json));

@Katsute Katsute self-assigned this Oct 4, 2022
@Katsute
Copy link
Member Author

Katsute commented Oct 4, 2022

@mashiro-san create a branch upgrade-json

@ghost
Copy link

ghost commented Oct 4, 2022

@Katsute I have created a new branch upgrade-json@f3dfe30

@Katsute Katsute mentioned this issue Oct 7, 2022
5 tasks
@Katsute Katsute linked a pull request Oct 11, 2022 that will close this issue
5 tasks
@Katsute Katsute removed a link to a pull request Oct 11, 2022
5 tasks
@Katsute
Copy link
Member Author

Katsute commented Oct 11, 2022

  • get methods need to be optimized so synchronized isn't blocking threads
  • pull bus stop alert info from gtfs feed
  • derive stop vehicles from all vehicles

@Katsute
Copy link
Member Author

Katsute commented Oct 13, 2022

Use CopyOnWriteArrayList to allow concurrent reads and locked writes.

ConcurrentMap?

In order to make write thread safe, have synchronized write block also check if its expired before fetching (any current active writes will make the result not expired, any queued writes will see that the resource is no longer expired and will return the new one instead).

Get first then check if expired to prevent concurrency issues.

@Katsute
Copy link
Member Author

Katsute commented Oct 14, 2022

@mashiro-san create a new branch upgrade cache

@ghost
Copy link

ghost commented Oct 14, 2022

@Katsute I have created a new branch upgrade-cache@ebf9c8e

@Katsute
Copy link
Member Author

Katsute commented Oct 25, 2022

Possibly use #100 to implement this.

@Katsute Katsute linked a pull request Oct 27, 2022 that will close this issue
5 tasks
@Katsute Katsute linked a pull request Jan 2, 2023 that will close this issue
5 tasks
@Katsute Katsute added this to the 2.0.0 milestone Jan 2, 2023
@ghost ghost locked and limited conversation to collaborators Jan 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
mta-bus Bus related issues and features optimization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant