-
-
Notifications
You must be signed in to change notification settings - Fork 389
Migrate indexHieFile progress notification to ProgressReporting API #4205
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
Migrate indexHieFile progress notification to ProgressReporting API #4205
Conversation
1440f35
to
d70acdb
Compare
Could we refactor this to actually use the helpers from |
This code manages its progress token in a somewhat unique way which is not easy to statically scope with the lsp progress functions. |
_ <- LSP.sendRequest LSP.SMethod_WindowWorkDoneProgressCreate (LSP.WorkDoneProgressCreateParams u) (const $ pure ()) | ||
b <- liftIO newBarrier | ||
void $ LSP.sendRequest LSP.SMethod_WindowWorkDoneProgressCreate (LSP.WorkDoneProgressCreateParams u) $ liftIO . signalBarrier b | ||
ready <- liftIO $ waitBarrier b |
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.
I don't know if its a good idea to delay indexing by an unbounded amount of time waiting for the client to respond with a progress token. Perhaps the progress reporting should be on another thread which doesn't block indexing.
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.
yes, but indexHieFile would return without reportProgress actually report done🤔. I am not sure how does it do to our test, I'll see how it goes.
Instead of a long runner task, it is more like tunes of small tasks dynamically created only finished when the all the pendding tasks are done. Hard to fit this in helpers from lsp. |
I've spawn a new thread to run the indexing progress update, send through TQueue. 🤔 Is it a good idea to do so? |
I think we can probably do something like #4218 now |
It seems, here we are using a push update model. Also, I am wondering if we can make |
Yes, I think there's almost something there. It's something like a standalone counter that also has some triggers for killing and restarting it? |
56f43e6
to
54fdce3
Compare
54fdce3
to
8981601
Compare
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.
Looks plausible, I wonder if we can simplify ProgressReporting
and just have one way to do it.
|
||
data ProgressEvent | ||
= KickStarted | ||
| KickCompleted | ||
= ProgressStarted |
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.
👍
Nothing -> do | ||
tt <- progressReportingOutsideState | ||
(liftM2 (+) (HashMap.size <$> readTVar indexPending) (readTVar indexCompleted)) | ||
(readTVar indexCompleted) |
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.
This seems a bit backwards to me? Can we not use the usual ProgressReporting
and then call progressUpdate
etc. instead of touching these TVars in the indexing code?
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.
Okay, I think I get it. Now I wonder if it would be simpler to make the other progress tracker work this way?
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.
As along as they are already tracking the progress status external at some T*** varaibles.
But I take a look at the use case at kick
, the state(todo count,done count) tracking is at defineEarlyCutoff'
and independent for each file. No easy way to switch the Kick
progress tracker work this way.
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.
Right, but when we create the progress tracker we could set that stuff up externally, so that the ProgressReporting
doesn't see it. Let me see if I can just write it down.
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.
Here: 2ad92a0
If we did this then I think indexHieFile
could just use progressCounter
directly?
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.
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.
then I think if you export it you can just use it in indexHieFile
If using it barely in indexHieFile
, we still need some kind of wrapping around progressCounter
. async
and cancel
the progressCounter
.
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.
Yeah, we do need that. But we could just do it locally. Or maybe you want to have a standalone concept of a "resumable/cancellable progress counter" and then just put the file-tracking on top for the compilation progress tracker?
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.
May be the latter, I am moving up the indexHieFile
reporting initialization to shakeOpen
as that of the Kick
reporting. Should be much cleaner than the preivous version.
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.
"resumable/cancellable progress counter" need an additional start Event that won't replace the existing progress reporting.
= KickStarted | ||
| KickCompleted | ||
= ProgressStarted | ||
| ProgressCompleted |
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 we just get rid of progressStop
, given that it just does the same thing as progressUpdate ProgressCompleted
?
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.
Kick
progress tracking working differently than indexHIeFile
.
HLS begins: Progress tracking started
- loop:
- Kick start ProgressStarted
- Kick end ProgressCompleted
HLS shutdown: Progress tracking Stop
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.
Oh yes, I missed that the state update is different, ProgressCompleted
goes back to NotStarted
. It's not clear that that gets us much, though 🤔
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.
NotStarted
and Stopped
are the same state, except you can't start again from Stopped
. But why does that even matter? In both cases you stop the session, it's not like Stopped
cleans up any more resources!
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.
So the way it is structured we get a restartable progress tracker, which is a reasonable thing to have when you keep a single reference to it alive for a long time.. But I think it could be simpler.
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.
So the way it is structured we get a restartable progress tracker
Yes, I think it is intended for multiple Kick
's.
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.
or we need to initialize progress tracker at each kick.
So basically:
restartable wrapped progress tracker versus
progress tracker used only once.
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.
I guess, Stopped
state is intended to forbit us to start the progress tracker again after the we shutdown hls
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.
That doesn't seem actually useful, though. I'd be inclined to remove it.
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Now it becomes We might want to renamed that
|
After introducing new event capturing more progress reporting logic, we are able to change the |
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.
Looks good, maybe just write down some of what we've learned!
= KickStarted | ||
| KickCompleted | ||
= ProgressStarted | ||
| ProgressCompleted |
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.
That doesn't seem actually useful, though. I'd be inclined to remove it.
doneVar :: TVar Int, | ||
currentVar :: STM.Map NormalizedFilePath Int | ||
} | ||
| InProgressStateOutSide |
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.
I still find this split a bit weird, but we've spent enough time on this!
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.
yes, especially we have inProgress
that is useless InProgressStateOutSide
.
Maybe in some following ups, we can come up with alternative design such as using GADTs to eliminate this discrepancy
, _percentage = Nothing | ||
} | ||
|
||
pre = progressUpdate indexProgressReporting ProgressStarted |
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.
I had actually thought we could just initialize a progressCounter
here and use it just in the scope of this function, but this works too!
Needs conflicts fixed then good to go |
* master: (36 commits) Migrate indexHieFile progress notification to ProgressReporting API (haskell#4205) Remove final allow-newer for 9.10 (haskell#4329) Remove unused exactprint dep More stylish Use newer cabal-fmt, partially lift ghc version restriction stylish Cleanup CI configs and cabal files More no-op code cleanup Remove no-longer-needed compat code, remove unused stuff Remove pre-multi component junk for GHC <= 9.2 Fix stylish Fix a few things Remove from CI Update docs Fix loss of 9.2 GHC version More CPP WIP evaluate CPP Prepare release 2.9.0.0 (haskell#4319) Add completion for import fields in cabal files (haskell#4305) Refine GHC deprecation policy (haskell#3438) ...
What's done
indexHieFile
progress to ProgressReporting API