Skip to content

Commit d5c5874

Browse files
authored
Decrease Wingman timeout from 3.3 minutes to 2 seconds (configurable) (#1688)
* Decrease timeout from 3.3 minutes to 2 seconds * Name the magic number * Restrict more class methods to speed up search * Make timeout configurable * Fix tests after the new hypothesis shrink
1 parent 28c9f0e commit d5c5874

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed

plugins/hls-tactics-plugin/src/Wingman/Judgements/Theta.hs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,23 @@ excludeForbiddenMethods = filter (not . flip S.member forbiddenMethods . hi_name
127127
[ -- monadfail
128128
"fail"
129129
-- show
130-
, "showsPrec"
131-
, "showList"
130+
, "showsPrec", "showList"
131+
-- functor
132+
, "<$"
133+
-- applicative
134+
, "liftA2", "<*", "*>"
132135
-- monad
133-
, "return"
136+
, "return", ">>"
137+
-- alternative
138+
, "some", "many"
139+
-- foldable
140+
, "foldr1", "foldl1", "elem", "maximum", "minimum", "sum", "product"
141+
-- traversable
142+
, "sequenceA", "mapM", "sequence"
143+
-- semigroup
144+
, "sconcat", "stimes"
145+
-- monoid
146+
, "mconcat"
134147
]
135148

136149

plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@ unsafeRunStaleIde state nfp a = do
109109
------------------------------------------------------------------------------
110110

111111
properties :: Properties
112-
'[ 'PropertyKey "max_use_ctor_actions" 'TInteger,
113-
'PropertyKey "features" 'TString]
112+
'[ 'PropertyKey "max_use_ctor_actions" 'TInteger
113+
, 'PropertyKey "features" 'TString
114+
, 'PropertyKey "timeout_duration" 'TInteger
115+
]
114116
properties = emptyProperties
117+
& defineIntegerProperty #timeout_duration
118+
"The timeout for Wingman actions, in seconds" 2
115119
& defineStringProperty #features
116120
"Feature set used by Wingman" ""
117121
& defineIntegerProperty #max_use_ctor_actions
@@ -124,6 +128,7 @@ getTacticConfig pId =
124128
Config
125129
<$> (parseFeatureSet <$> usePropertyLsp #features pId properties)
126130
<*> usePropertyLsp #max_use_ctor_actions pId properties
131+
<*> usePropertyLsp #timeout_duration pId properties
127132

128133
------------------------------------------------------------------------------
129134
-- | Get the current feature set from the plugin config.

plugins/hls-tactics-plugin/src/Wingman/Plugin.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,14 @@ tacticCmd tac pId state (TacticParams uri range var_name)
8888
| Just nfp <- uriToNormalizedFilePath $ toNormalizedUri uri = do
8989
features <- getFeatureSet pId
9090
ccs <- getClientCapabilities
91+
cfg <- getTacticConfig pId
9192
res <- liftIO $ runMaybeT $ do
9293
(range', jdg, ctx, dflags) <- judgementForHole state nfp range features
9394
let span = fmap (rangeToRealSrcSpan (fromNormalizedFilePath nfp)) range'
9495
TrackedStale pm pmmap <- runStaleIde state nfp GetAnnotatedParsedSource
9596
pm_span <- liftMaybe $ mapAgeFrom pmmap span
9697

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

120121

122+
------------------------------------------------------------------------------
123+
-- | The number of microseconds in a second
124+
seconds :: Num a => a
125+
seconds = 1e6
126+
127+
121128
timingOut
122129
:: Int -- ^ Time in microseconds
123130
-> a -- ^ Computation to run

plugins/hls-tactics-plugin/src/Wingman/Types.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ tacticTitle = (mappend "Wingman: " .) . go
7777
data Config = Config
7878
{ cfg_feature_set :: FeatureSet
7979
, cfg_max_use_ctor_actions :: Int
80+
, cfg_timeout_seconds :: Int
8081
}
8182

8283
------------------------------------------------------------------------------

plugins/hls-tactics-plugin/test/golden/KnownCounterfactualSemigroup.hs.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
data Semi = Semi [String] Int
44

55
instance Semigroup Int => Semigroup Semi where
6-
(<>) (Semi l_l_c7 i8) (Semi l_l_c i)
7-
= Semi ((<>) l_l_c7 l_l_c) ((<>) i8 i)
6+
(<>) (Semi l_l_c5 i6) (Semi l_l_c i)
7+
= Semi ((<>) l_l_c5 l_l_c) ((<>) i6 i)
88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
data Semi a = Semi a
22

33
instance Semigroup a => Semigroup (Semi a) where
4-
(<>) (Semi a6) (Semi a) = Semi ((<>) a6 a)
4+
(<>) (Semi a4) (Semi a) = Semi ((<>) a4 a)
55

0 commit comments

Comments
 (0)