-
Notifications
You must be signed in to change notification settings - Fork 645
Ensure completion to respond faster #1209
Ensure completion to respond faster #1209
Conversation
@ramya-rao-a please check |
src/goSuggest.ts
Outdated
importablePkgsPromise = Promise.race([timeout(1000).then(() => this.pkgsList), importablePkgsPromise]); | ||
} | ||
|
||
let setPkgsList = importablePkgsPromise.then(pkgMap => { | ||
this.pkgsList = pkgMap; |
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.
How about this?
let importablePkgsPromise = getImportablePackages(vscode.window.activeTextEditor.document.fileName).then(pkgMap => this.pkgList = pkgMap);
let setpkgslist = Promise.race([timeout(1000).then(() => this.pkgsList), importablePkgsPromise]);
Case when gopkgs runs under a second:
Completion will always use the latest result
Case when gopkgs runs over a second:
Completion will use cache. If its the first completion call, then no pkgs will be available which is fine, we can attribute this to cold start
When gopkgs eventually finishes, it will update the result, so that the next completion gets to use a more recent cache
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.
The reason I am suggesting the above is that with your current design
- a user can still get stuck waiting for the very first call to completion
- a user can get stale data if gopkgs always takes over 1 second, and the next call from completion happens after 5 sec (the cache expiry time)
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.
Ahh... I see
@uudashr The I dont have Go tip, you have any ideas about this? |
@ramya-rao-a Tip version on Mac looks good on my machine. Re-run the travis build and all good. |
I put some guard for 1sec timeout for
getImportablePackages()