Skip to content

Commit fd322fe

Browse files
committed
Merge remote-tracking branch 'oa/lazy-state-result-#4545'
2 parents c19d377 + 4bf5d8d commit fd322fe

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
@@ -58,7 +58,7 @@ import Language.PureScript.Ide.Externs (convertExterns)
5858
import Language.PureScript.Ide.Reexports (ReexportResult(..), prettyPrintReexportResult, reexportHasFailures, resolveReexports)
5959
import Language.PureScript.Ide.SourceFile (extractAstInformation)
6060
import Language.PureScript.Ide.Types
61-
import Language.PureScript.Ide.Util (discardAnn, displayTimeSpec, logPerf, opNameT, properNameT, runLogger)
61+
import Language.PureScript.Ide.Util (discardAnn, opNameT, properNameT, runLogger)
6262
import System.Directory (getModificationTime)
6363

6464
-- | Resets all State inside psc-ide
@@ -221,10 +221,7 @@ cachedRebuild = vsCachedRebuild <$> getVolatileState
221221
populateVolatileStateSync :: (Ide m, MonadLogger m) => m ()
222222
populateVolatileStateSync = do
223223
st <- ideStateVar <$> ask
224-
let message duration = "Finished populating volatile state in: " <> displayTimeSpec duration
225-
results <- logPerf message $ do
226-
!r <- liftIO (atomically (populateVolatileStateSTM st))
227-
pure r
224+
results <- liftIO (atomically (populateVolatileStateSTM st))
228225
void $ Map.traverseWithKey
229226
(\mn -> logWarnN . prettyPrintReexportResult (const (P.runModuleName mn)))
230227
(Map.filter reexportHasFailures results)
@@ -257,7 +254,7 @@ populateVolatileStateSTM ref = do
257254
& resolveOperators
258255
& resolveReexports reexportRefs
259256
setVolatileStateSTM ref (IdeVolatileState (AstData asts) (map reResolved results) rebuildCache)
260-
pure (force results)
257+
pure results
261258

262259
resolveLocations
263260
:: 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
@@ -32,59 +32,59 @@ data IdeDeclaration
3232
| IdeDeclValueOperator IdeValueOperator
3333
| IdeDeclTypeOperator IdeTypeOperator
3434
| IdeDeclModule P.ModuleName
35-
deriving (Show, Eq, Ord, Generic, NFData)
35+
deriving (Show, Eq, Ord)
3636

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

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

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

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

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

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

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

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

8989
_IdeDeclValue :: Traversal' IdeDeclaration IdeValue
9090
_IdeDeclValue f (IdeDeclValue x) = map IdeDeclValue (f x)
@@ -132,15 +132,15 @@ makeLenses ''IdeTypeOperator
132132
data IdeDeclarationAnn = IdeDeclarationAnn
133133
{ _idaAnnotation :: Annotation
134134
, _idaDeclaration :: IdeDeclaration
135-
} deriving (Show, Eq, Ord, Generic, NFData)
135+
} deriving (Show, Eq, Ord)
136136

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

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

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

327327
-- | Denotes the different namespaces a name in PureScript can reside in.
328328
data IdeNamespace = IdeNSValue | IdeNSType | IdeNSModule
329-
deriving (Show, Eq, Ord, Generic, NFData)
329+
deriving (Show, Eq, Ord)
330330

331331
instance FromJSON IdeNamespace where
332332
parseJSON = Aeson.withText "Namespace" $ \case
@@ -337,4 +337,4 @@ instance FromJSON IdeNamespace where
337337

338338
-- | A name tagged with a namespace
339339
data IdeNamespaced = IdeNamespaced IdeNamespace Text
340-
deriving (Show, Eq, Ord, Generic, NFData)
340+
deriving (Show, Eq, Ord)

0 commit comments

Comments
 (0)