-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fire Performance improvement; Async/await APIs #380
Conversation
@mallexxx I tested this by using the fire button in a few different scenarios and observing the contents of
Sites still load correctly in the second-to-last step, but perhaps the disk cache isn't being used in that case? Also, I think this is a preexisting issue, but the cache directory has a set of 3 files (Cache.*) that don't get cleared by the fire button. I looked through the contents of those files, and I'm seeing URLs and pieces of requests for autocomplete requests (containing the terms I typed in the searchbar) and favicon URLs for the domains I visited. |
Made a new task for the last part: https://app.asana.com/0/1199178362774117/1201549708930601/f Also, this was all tested on Monterey. |
I tried to replicate the performance improvement, but after visiting a hundred or so pages, the original version still completes within a few seconds. Is there a good way to replicate the conditions in which it's slow, or do I just need a larger history set? |
@bstandaert-ddg, nice catches!
|
Updating my Xcode, probably won't review this evening but definitely tomorrow. |
@mallexxx Thanks! The behavior of the webkit directory seems correct now. After I use the fire button, the Cache.* files aren't recreated when I type something in the address bar - I have to restart the browser first, and then search for something to get them to show up again. Address bar autocomplete still works correctly after using the fire button, but are the requests not being cached at that point? |
Ben, thanks for your testing, it is such a huge help! 🥇Aaddress bar suggestions are completely independent and not related to WebKit framework. We fetch our own DDG service, local history and bookmarks. |
@tomasstrba Right, sorry, should clarify more - the autocomplete API responses are cached in the Cache.db file, which Alexey added deletion of in this PR (but which I agree isn't from Webkit). For example, if I open the browser with an empty data directory and search for "coffee", and then inspect the Cache.db file:
And the response bodies are in another table of the same file:
|
Ben, thanks for the clarification. Good catch! I have noticed these logs after usage of fire button that are probably related. Requests may not be cached because file descriptors to cache files are invalidated. And only the restart of the browser opens cache files correctly again. 2021-12-25 13:43:19.829845+0100 DuckDuckGo[63233:630905] [logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode renamed while in use: /private/var/folders/8b/9kzczvb10rb7_4phdsctqrd00000gn/T/TemporaryItems/86F48992-4C96-4553-8BAD-59172DC6ADD2/Cache.db-shm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Code looks great! So simplified with the new API 🥇
The only blocker is the issue Ben found. I hope we don't need to restart the browser after usage of fire button. Which processes are writing to those files? Can we restart just them specifically if it is not the main process?
func clear(completion: @escaping () -> Void) { | ||
func clear(domains: Set<String>? = nil) async { | ||
// first cleanup ~/Library/Caches | ||
await self.clearFileCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, how clean are these lines 💯 thans for introducing the usage of async await. 🥇
@@ -57,9 +57,10 @@ final class Fire { | |||
let burningDomains = domains.union(wwwDomains) | |||
|
|||
group.enter() | |||
burnWebCache(domains: burningDomains, completion: { | |||
Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 can't wait to use this too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
private static var defaultCallbackQueue: OperationQueue = { | ||
let queue = OperationQueue() | ||
queue.name = "APIRequest default callback queue" | ||
queue.qualityOfService = .utility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, do you think we could raise QoS to .userInitiated? Utility is performing work which the user is unlikely to be immediately waiting for the results, for example periodic content updates or bulk file operations. Not sure if we feel the difference, but let's ask for better resources if we can
The behavior of clearing cache.db looks good to me now, at least once the favicon service get updated as well. I'm not sure if this is worth holding this PR up for, but I just noticed that if a tab is writing to the cache directory at the same time as you press the fire button, it's possible for the cache directory to not be empty afterwards. You can reproduce by going to twitter.com and pressing the fire button within a few seconds of when the page loads: Screen.Recording.2022-01-11.at.12.51.06.PM.mov |
Task/Issue URL: https://app.asana.com/0/1201037661562251/1204717237528130/f BSK PR: duckduckgo/BrowserServicesKit#380 Description: Moves storing the password salt to a background queue on creation. (This is a BSK fix)
* develop: (246 commits) Bump version to 1.44.0 (31) Update embedded files Updates the way we store the secure vault encryption keys. (#1256) ask fireproofing off by default (#1269) Set version to 1.43.1. fix(duck-player): capture the correct url before a click occurs (#1268) Remove Rogue "Passwords" button that appears when clicking the password field in the Save Creds popover (#1250) Reattach orphaned bookmarks to root folder when reordering (#1260) Update API usage and trigger sync when interacting with bookmarks (#1255) Move the exti event to first engagement (#1244) Drop support for regexes in url parameter stripping (#1220) bump bsk (#1261) Add Re-enable .superceded Notification action (#1240) Fix pop up window button issues and hide NetP in pop up windows (#1257) resolve export bookmarks warning (#1254) History Integration Tests fixed (#1253) Add item to keychain in the background #380 (#1251) fix sysex reinstall codesign issue (#1236) macOS in-context signup updates (#1209) Fixes the format in a log call (#1249) ...
Task/Issue URL: https://app.asana.com/0/1199237043630360/1201439804724065
Tech Design URL: https://app.asana.com/0/1199237043630360/1201473146283276
CC: @tomasstrba
Description:
The PR fixes Fire performance by removing Web Cache Files in background
Steps to test this PR:
Testing checklist:
Internal references:
Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM