-
-
Notifications
You must be signed in to change notification settings - Fork 401
Decouple the session loader into reader and writer over the cache #4445
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
base: master
Are you sure you want to change the base?
Conversation
… them to improve performance fix haskell#4381
…p error loading and cradle files
ba7379b
to
79a43a0
Compare
Renames getOptions to getOptionsWorker for clarity Removes redundant getOptionsLoop function Ensures session loading is called under the same `Action` context
…ration of concerns
The session initialisation has too many implicit dependencies. To break these apart, we extract local functions and turn them into top-level definition with all parameters explicitly given. This commit only makes sure session initialisation functions are promoted to top-level definitions and tries to simplify them. The top-level definitions are lacking type signatures to make it easier to change them, but we plan to add them back.
import StmContainers.Set (Set) | ||
|
||
|
||
type OrderedSet a = (TQueue a, Set a) |
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.
Lets make this a proper datatype, e.g.
data TOrderedSet = TOrderedSet
{ insertionOrder :: TQueue a
, elements :: Set a
}
at the very least, this should be a newtype
.
insert :: Hashable a => a -> OrderedSet a -> STM () | ||
insert a (que, s) = do |
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.
Docs please!
The behaviour feels non-standard and non-trivial.
Expected complexity is also appreciated.
s <- S.newIO | ||
return (que, s) | ||
|
||
readQueue :: Hashable a => OrderedSet a -> STM a |
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.
Docs please, what is the purpose and behaviour?
delete :: Hashable a => a -> OrderedSet a -> STM () | ||
delete a (_, s) = S.delete a 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.
Docs please explaining why we don't have to delete the element from the TQueue
as well.
Follow up of and already include the changes in #4439
Refactored session loader to use architecture that having multiple readers and writer over the cache .
In bigger project, HLS usually loading up slow. One of the main obstacle is that we are loading ghc options for files in strict sequential order.
I have made an attemp to improve the situation by refactoring this loading into reader and writer over cache. This way, the long laoding file won't be blocking already loaded files, making hls more responsive and smooth.
Also it eliminates session loading for the same file from being multiply requested, by lining up in an ordered set in stead of a list.