Skip to content

Commit fc3fa88

Browse files
authored
IDE: don't force state results (purescript#4546)
1 parent e06b9cc commit fc3fa88

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

CHANGELOG.d/fix_issue-4545.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Speed up IDE performance on large projects

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ If you would prefer to use different terms, please use the section below instead
167167
| [@woody88](https://github.com/woody88) | Woodson Delhia | [MIT license] |
168168
| [@xgrommx](https://github.com/xgrommx) | Denis Stoyanov | [MIT license] |
169169
| [@zudov](https://github.com/zudov) | Konstantin Zudov | [MIT license] |
170+
| [@roryc89](https://github.com/roryc89) | Rory Campbell | [MIT license] |
170171

171172

172173
### Contributors using Modified Terms

src/Language/PureScript/Ide/Reexports.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ data ReexportResult a
3535
= ReexportResult
3636
{ reResolved :: a
3737
, reFailed :: [(P.ModuleName, P.DeclarationRef)]
38-
} deriving (Show, Eq, Functor, Generic)
38+
} deriving (Show, Eq, Functor)
3939

40-
instance NFData a => NFData (ReexportResult a)
4140

4241
-- | Uses the passed formatter to format the resolved module, and adds possible
4342
-- failures

src/Language/PureScript/Ide/State.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import Language.PureScript.Ide.Externs (convertExterns)
5454
import Language.PureScript.Ide.Reexports (ReexportResult(..), prettyPrintReexportResult, reexportHasFailures, resolveReexports)
5555
import Language.PureScript.Ide.SourceFile (extractAstInformation)
5656
import Language.PureScript.Ide.Types
57-
import Language.PureScript.Ide.Util (discardAnn, displayTimeSpec, logPerf, opNameT, properNameT, runLogger)
57+
import Language.PureScript.Ide.Util (discardAnn, opNameT, properNameT, runLogger)
5858
import System.Directory (getModificationTime)
5959

6060
-- | Resets all State inside psc-ide
@@ -199,10 +199,7 @@ cachedRebuild = vsCachedRebuild <$> getVolatileState
199199
populateVolatileStateSync :: (Ide m, MonadLogger m) => m ()
200200
populateVolatileStateSync = do
201201
st <- ideStateVar <$> ask
202-
let message duration = "Finished populating volatile state in: " <> displayTimeSpec duration
203-
results <- logPerf message $ do
204-
!r <- liftIO (atomically (populateVolatileStateSTM st))
205-
pure r
202+
results <- liftIO (atomically (populateVolatileStateSTM st))
206203
void $ Map.traverseWithKey
207204
(\mn -> logWarnN . prettyPrintReexportResult (const (P.runModuleName mn)))
208205
(Map.filter reexportHasFailures results)
@@ -235,7 +232,7 @@ populateVolatileStateSTM ref = do
235232
& resolveOperators
236233
& resolveReexports reexportRefs
237234
setVolatileStateSTM ref (IdeVolatileState (AstData asts) (map reResolved results) rebuildCache)
238-
pure (force results)
235+
pure results
239236

240237
resolveLocations
241238
:: ModuleMap (DefinitionSites P.SourceSpan, TypeAnnotations)

src/Language/PureScript/Ide/Types.hs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,59 +31,59 @@ data IdeDeclaration
3131
| IdeDeclValueOperator IdeValueOperator
3232
| IdeDeclTypeOperator IdeTypeOperator
3333
| IdeDeclModule P.ModuleName
34-
deriving (Show, Eq, Ord, Generic, NFData)
34+
deriving (Show, Eq, Ord)
3535

3636
data IdeValue = IdeValue
3737
{ _ideValueIdent :: P.Ident
3838
, _ideValueType :: P.SourceType
39-
} deriving (Show, Eq, Ord, Generic, NFData)
39+
} deriving (Show, Eq, Ord)
4040

4141
data IdeType = IdeType
4242
{ _ideTypeName :: P.ProperName 'P.TypeName
4343
, _ideTypeKind :: P.SourceType
4444
, _ideTypeDtors :: [(P.ProperName 'P.ConstructorName, P.SourceType)]
45-
} deriving (Show, Eq, Ord, Generic, NFData)
45+
} deriving (Show, Eq, Ord)
4646

4747
data IdeTypeSynonym = IdeTypeSynonym
4848
{ _ideSynonymName :: P.ProperName 'P.TypeName
4949
, _ideSynonymType :: P.SourceType
5050
, _ideSynonymKind :: P.SourceType
51-
} deriving (Show, Eq, Ord, Generic, NFData)
51+
} deriving (Show, Eq, Ord)
5252

5353
data IdeDataConstructor = IdeDataConstructor
5454
{ _ideDtorName :: P.ProperName 'P.ConstructorName
5555
, _ideDtorTypeName :: P.ProperName 'P.TypeName
5656
, _ideDtorType :: P.SourceType
57-
} deriving (Show, Eq, Ord, Generic, NFData)
57+
} deriving (Show, Eq, Ord)
5858

5959
data IdeTypeClass = IdeTypeClass
6060
{ _ideTCName :: P.ProperName 'P.ClassName
6161
, _ideTCKind :: P.SourceType
6262
, _ideTCInstances :: [IdeInstance]
63-
} deriving (Show, Eq, Ord, Generic, NFData)
63+
} deriving (Show, Eq, Ord)
6464

6565
data IdeInstance = IdeInstance
6666
{ _ideInstanceModule :: P.ModuleName
6767
, _ideInstanceName :: P.Ident
6868
, _ideInstanceTypes :: [P.SourceType]
6969
, _ideInstanceConstraints :: Maybe [P.SourceConstraint]
70-
} deriving (Show, Eq, Ord, Generic, NFData)
70+
} deriving (Show, Eq, Ord)
7171

7272
data IdeValueOperator = IdeValueOperator
7373
{ _ideValueOpName :: P.OpName 'P.ValueOpName
7474
, _ideValueOpAlias :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName))
7575
, _ideValueOpPrecedence :: P.Precedence
7676
, _ideValueOpAssociativity :: P.Associativity
7777
, _ideValueOpType :: Maybe P.SourceType
78-
} deriving (Show, Eq, Ord, Generic, NFData)
78+
} deriving (Show, Eq, Ord)
7979

8080
data IdeTypeOperator = IdeTypeOperator
8181
{ _ideTypeOpName :: P.OpName 'P.TypeOpName
8282
, _ideTypeOpAlias :: P.Qualified (P.ProperName 'P.TypeName)
8383
, _ideTypeOpPrecedence :: P.Precedence
8484
, _ideTypeOpAssociativity :: P.Associativity
8585
, _ideTypeOpKind :: Maybe P.SourceType
86-
} deriving (Show, Eq, Ord, Generic, NFData)
86+
} deriving (Show, Eq, Ord)
8787

8888
_IdeDeclValue :: Traversal' IdeDeclaration IdeValue
8989
_IdeDeclValue f (IdeDeclValue x) = map IdeDeclValue (f x)
@@ -131,15 +131,15 @@ makeLenses ''IdeTypeOperator
131131
data IdeDeclarationAnn = IdeDeclarationAnn
132132
{ _idaAnnotation :: Annotation
133133
, _idaDeclaration :: IdeDeclaration
134-
} deriving (Show, Eq, Ord, Generic, NFData)
134+
} deriving (Show, Eq, Ord)
135135

136136
data Annotation
137137
= Annotation
138138
{ _annLocation :: Maybe P.SourceSpan
139139
, _annExportedFrom :: Maybe P.ModuleName
140140
, _annTypeAnnotation :: Maybe P.SourceType
141141
, _annDocumentation :: Maybe Text
142-
} deriving (Show, Eq, Ord, Generic, NFData)
142+
} deriving (Show, Eq, Ord)
143143

144144
makeLenses ''Annotation
145145
makeLenses ''IdeDeclarationAnn
@@ -152,7 +152,7 @@ type TypeAnnotations = Map P.Ident P.SourceType
152152
newtype AstData a = AstData (ModuleMap (DefinitionSites a, TypeAnnotations))
153153
-- ^ SourceSpans for the definition sites of values and types as well as type
154154
-- annotations found in a module
155-
deriving (Show, Eq, Ord, Generic, NFData, Functor, Foldable)
155+
deriving (Show, Eq, Ord, Functor, Foldable)
156156

157157
data IdeLogLevel = LogDebug | LogPerf | LogAll | LogDefault | LogNone
158158
deriving (Show, Eq)
@@ -313,7 +313,7 @@ encodeImport (P.runModuleName -> mn, importType, map P.runModuleName -> qualifie
313313

314314
-- | Denotes the different namespaces a name in PureScript can reside in.
315315
data IdeNamespace = IdeNSValue | IdeNSType | IdeNSModule
316-
deriving (Show, Eq, Ord, Generic, NFData)
316+
deriving (Show, Eq, Ord)
317317

318318
instance FromJSON IdeNamespace where
319319
parseJSON = Aeson.withText "Namespace" $ \case
@@ -324,4 +324,4 @@ instance FromJSON IdeNamespace where
324324

325325
-- | A name tagged with a namespace
326326
data IdeNamespaced = IdeNamespaced IdeNamespace Text
327-
deriving (Show, Eq, Ord, Generic, NFData)
327+
deriving (Show, Eq, Ord)

0 commit comments

Comments
 (0)