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

Decrease Wingman timeout from 3.3 minutes to 2 seconds (configurable) #1688

Merged
merged 7 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 16 additions & 3 deletions plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,23 @@ excludeForbiddenMethods = filter (not . flip S.member forbiddenMethods . hi_name
[ -- monadfail
"fail"
-- show
, "showsPrec"
, "showList"
, "showsPrec", "showList"
-- functor
, "<$"
-- applicative
, "liftA2", "<*", "*>"
-- monad
, "return"
, "return", ">>"
-- alternative
, "some", "many"
-- foldable
, "foldr1", "foldl1", "elem", "maximum", "minimum", "sum", "product"
-- traversable
, "sequenceA", "mapM", "sequence"
-- semigroup
, "sconcat", "stimes"
-- monoid
, "mconcat"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changes bundled together?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm an absolute madman

]


Expand Down
9 changes: 7 additions & 2 deletions plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ unsafeRunStaleIde state nfp a = do
------------------------------------------------------------------------------

properties :: Properties
'[ 'PropertyKey "max_use_ctor_actions" 'TInteger,
'PropertyKey "features" 'TString]
'[ 'PropertyKey "max_use_ctor_actions" 'TInteger
, 'PropertyKey "features" 'TString
, 'PropertyKey "timeout_duration" 'TInteger
]
properties = emptyProperties
& defineIntegerProperty #timeout_duration
"The timeout for Wingman actions, in seconds" 2
& defineStringProperty #features
"Feature set used by Wingman" ""
& defineIntegerProperty #max_use_ctor_actions
Expand All @@ -124,6 +128,7 @@ getTacticConfig pId =
Config
<$> (parseFeatureSet <$> usePropertyLsp #features pId properties)
<*> usePropertyLsp #max_use_ctor_actions pId properties
<*> usePropertyLsp #timeout_duration pId properties

------------------------------------------------------------------------------
-- | Get the current feature set from the plugin config.
Expand Down
9 changes: 8 additions & 1 deletion plugins/hls-tactics-plugin/src/Wingman/Plugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ tacticCmd tac pId state (TacticParams uri range var_name)
| Just nfp <- uriToNormalizedFilePath $ toNormalizedUri uri = do
features <- getFeatureSet pId
ccs <- getClientCapabilities
cfg <- getTacticConfig pId
res <- liftIO $ runMaybeT $ do
(range', jdg, ctx, dflags) <- judgementForHole state nfp range features
let span = fmap (rangeToRealSrcSpan (fromNormalizedFilePath nfp)) range'
TrackedStale pm pmmap <- runStaleIde state nfp GetAnnotatedParsedSource
pm_span <- liftMaybe $ mapAgeFrom pmmap span

timingOut 2e8 $ join $
timingOut (cfg_timeout_seconds cfg * seconds) $ join $
case runTactic ctx jdg $ tac $ mkVarOcc $ T.unpack var_name of
Left _ -> Left TacticErrors
Right rtr ->
Expand All @@ -118,6 +119,12 @@ tacticCmd _ _ _ _ =
pure $ Left $ mkErr InvalidRequest "Bad URI"


------------------------------------------------------------------------------
-- | The number of microseconds in a second
seconds :: Num a => a
seconds = 1e6


timingOut
:: Int -- ^ Time in microseconds
-> a -- ^ Computation to run
Expand Down
1 change: 1 addition & 0 deletions plugins/hls-tactics-plugin/src/Wingman/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ tacticTitle = (mappend "Wingman: " .) . go
data Config = Config
{ cfg_feature_set :: FeatureSet
, cfg_max_use_ctor_actions :: Int
, cfg_timeout_seconds :: Int
}

------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
data Semi = Semi [String] Int

instance Semigroup Int => Semigroup Semi where
(<>) (Semi l_l_c7 i8) (Semi l_l_c i)
= Semi ((<>) l_l_c7 l_l_c) ((<>) i8 i)
(<>) (Semi l_l_c5 i6) (Semi l_l_c i)
= Semi ((<>) l_l_c5 l_l_c) ((<>) i6 i)

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data Semi a = Semi a

instance Semigroup a => Semigroup (Semi a) where
(<>) (Semi a6) (Semi a) = Semi ((<>) a6 a)
(<>) (Semi a4) (Semi a) = Semi ((<>) a4 a)