ghcide-2.9.0.0: The core of an IDE
Safe HaskellSafe-Inferred
LanguageGHC2021

Development.IDE.Types.KnownTargets

Synopsis

Documentation

data KnownTargets Source #

A mapping of module name to known files

Constructors

KnownTargets 

Fields

  • targetMap :: !(HashMap Target (HashSet NormalizedFilePath))
     
  • normalisingMap :: !(HashMap Target Target)

    normalisingMap is a cached copy of `HMap.mapKey const targetMap`

    At startup GetLocatedImports is called on all known files. Say you have 10000 modules in your project then this leads to 10000 calls to GetLocatedImports running concurrently.

    In GetLocatedImports the known targets are consulted and the targetsMap is created by mapping the known targets. This map is used for introducing sharing amongst filepaths. This operation copies a local copy of the target map which is local to the rule.

    let targetsMap = HMap.mapWithKey const targets
    

    So now each rule has a HashMap of size 10000 held locally to it and depending on how the threads are scheduled there will be 10000^2 elements in total allocated in HashMaps. This used a lot of memory.

    Solution: Return the normalisingMap in the result of the GetKnownTargets rule so it is shared across threads.

data Target Source #

Instances

Instances details
Generic Target Source # 
Instance details

Defined in Development.IDE.Types.KnownTargets

Associated Types

type Rep Target :: Type -> Type #

Methods

from :: Target -> Rep Target x #

to :: Rep Target x -> Target #

Show Target Source # 
Instance details

Defined in Development.IDE.Types.KnownTargets

NFData Target Source # 
Instance details

Defined in Development.IDE.Types.KnownTargets

Methods

rnf :: Target -> () #

Eq Target Source # 
Instance details

Defined in Development.IDE.Types.KnownTargets

Methods

(==) :: Target -> Target -> Bool #

(/=) :: Target -> Target -> Bool #

Ord Target Source # 
Instance details

Defined in Development.IDE.Types.KnownTargets

Hashable Target Source # 
Instance details

Defined in Development.IDE.Types.KnownTargets

Methods

hashWithSalt :: Int -> Target -> Int #

hash :: Target -> Int #

type Rep Target Source # 
Instance details

Defined in Development.IDE.Types.KnownTargets

type Rep Target = D1 ('MetaData "Target" "Development.IDE.Types.KnownTargets" "ghcide-2.9.0.0-5fVLSF6BuTDBEO5GZ0xNyi" 'False) (C1 ('MetaCons "TargetModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleName)) :+: C1 ('MetaCons "TargetFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NormalizedFilePath)))