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

Minor Performance Improvement #1046

Closed
bitmold opened this issue Dec 21, 2023 · 1 comment
Closed

Minor Performance Improvement #1046

bitmold opened this issue Dec 21, 2023 · 1 comment
Labels

Comments

@bitmold
Copy link
Collaborator

bitmold commented Dec 21, 2023

Everytime OrbotService is created, the files geoip and geoip6 from libs/geoip.jar are copied from Android's abstract Asset management system (jar files live as assets too) into Orbot's internal directory... Even if those files already exist they get rewritten over every single time. If Orbot is starting in the background and the operating system is deprioritizing disk IO on apps that aren't open maybe this operation adds a few seconds to starting Orbot. For those who are unaware, the assets need to be written as a file with a path such that it can be passed into the tor native code, Android assets can not be referenced that way so what happens is they are copied 1024bytes at a time to disk... Possibly there's another way around this, but I haven't found it yet. Maybe by not compressing the geoip files into a jar (which is just a zip...) It's a bit silly too because then the files exist twice, once it orbot's internal directory and a second time in the unspecified abstracted way that they exist as "assets" in the APK.

Unfortunately it's a bit trickier than just seeing if the files exist, since if you update those goeip files (which we just did) then checking if they exist will result in the newer versions not being written to the file system. One proposal is on app updates deleting those files so they are re-installed...

Not sure if this even amounts to much, but it makes OrbotService do one less thing whenever it starts up, which to me is a win. The files aren't enormous (I think they add up to a bit over 10MB, but copying both of them in 1KB chunks in a blocking way seems a bit silly if they already exist).

Someone with better perspective on this, please enlighten me (and my gratitude for humoring me too) - is this actually an "optimization" like I suspecft it may be? Or am I fooling myself into writing code that amounts to nothing.

@bitmold bitmold added the bug label Dec 21, 2023
@bitmold
Copy link
Collaborator Author

bitmold commented Dec 21, 2023

This should help with ##994 though I don't think it gets at the root of that issue

bitmold added a commit that referenced this issue Dec 21, 2023
…e files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Dec 21, 2023
…rom zip

if those files dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Dec 22, 2023
…rom zip

if those files dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Dec 22, 2023
…rom zip if those files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Jan 18, 2024
…rom zip

if those files dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Jan 24, 2024
…rom zip if those files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Jan 24, 2024
…rom zip if those files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Jan 25, 2024
…rom zip if those files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Jan 26, 2024
…rom zip if those files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
syphyr pushed a commit to syphyr/orbot that referenced this issue Jan 27, 2024
…rom zip if those files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
@bitmold bitmold changed the title Minor Possible Performance Improvement Minor Performance Improvement Jan 28, 2024
bitmold added a commit that referenced this issue Jan 29, 2024
…e files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
@bitmold bitmold closed this as completed Jan 29, 2024
n8fr8 pushed a commit that referenced this issue Feb 9, 2024
…e files

dont already exist or if the app has been updated

added very lightweight logic in Application subclass to set flags for geoip
and other events if and only if an app update has occured
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant