diff --git a/profile-admin.txt b/profile-admin.txt index 814732e30f..d7bf975181 100644 --- a/profile-admin.txt +++ b/profile-admin.txt @@ -1,27 +1,27 @@ 'purs' 'compile' '--source-globs-file' '.spago/sources.txt' +RTS '-N' '-A256m' '-n16m' '-sprofile.txt' - 615,026,369,264 bytes allocated in the heap - 62,526,339,128 bytes copied during GC - 4,808,133,160 bytes maximum residency (7 sample(s)) - 30,469,184 bytes maximum slop - 16158 MiB total memory in use (0 MiB lost due to fragmentation) + 615,099,828,952 bytes allocated in the heap + 62,000,055,448 bytes copied during GC + 4,802,961,112 bytes maximum residency (7 sample(s)) + 29,304,824 bytes maximum slop + 16280 MiB total memory in use (0 MiB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause - Gen 0 239 colls, 239 par 59.390s 7.687s 0.0322s 0.1657s - Gen 1 7 colls, 6 par 17.637s 4.178s 0.5969s 1.2704s + Gen 0 239 colls, 239 par 59.582s 8.158s 0.0341s 0.2123s + Gen 1 7 colls, 6 par 18.855s 4.852s 0.6932s 1.6310s - Parallel GC work balance: 91.91% (serial 0%, perfect 100%) + Parallel GC work balance: 92.47% (serial 0%, perfect 100%) - TASKS: 67 (1 bound, 65 peak workers (66 total), using -N10) + TASKS: 63 (1 bound, 62 peak workers (62 total), using -N10) SPARKS: 7516 (7516 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled) - INIT time 0.151s ( 0.151s elapsed) - MUT time 304.986s ( 90.340s elapsed) - GC time 77.027s ( 11.865s elapsed) - EXIT time 0.249s ( 0.009s elapsed) - Total time 382.413s (102.365s elapsed) + INIT time 0.154s ( 0.154s elapsed) + MUT time 302.979s ( 92.707s elapsed) + GC time 78.437s ( 13.011s elapsed) + EXIT time 0.249s ( 0.013s elapsed) + Total time 381.820s (105.885s elapsed) - Alloc rate 2,016,569,461 bytes per MUT second + Alloc rate 2,030,174,162 bytes per MUT second - Productivity 79.8% of total user, 88.3% of total elapsed + Productivity 79.4% of total user, 87.6% of total elapsed diff --git a/profile.txt b/profile.txt index d46e022a49..b696e1f5f3 100644 --- a/profile.txt +++ b/profile.txt @@ -1,27 +1,27 @@ 'purs' 'compile' '--source-globs-file' '.spago/sources.txt' +RTS '-N' '-A256m' '-n16m' '-sprofile.txt' -1,239,641,572,944 bytes allocated in the heap - 92,117,540,648 bytes copied during GC - 2,525,848,440 bytes maximum residency (16 sample(s)) - 41,515,920 bytes maximum slop - 9680 MiB total memory in use (0 MiB lost due to fragmentation) +1,239,412,052,704 bytes allocated in the heap + 92,015,777,936 bytes copied during GC + 2,538,965,264 bytes maximum residency (16 sample(s)) + 41,492,672 bytes maximum slop + 9607 MiB total memory in use (0 MiB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause - Gen 0 462 colls, 462 par 98.367s 12.592s 0.0273s 0.1880s - Gen 1 16 colls, 15 par 26.135s 3.701s 0.2313s 0.3772s + Gen 0 464 colls, 464 par 98.639s 12.205s 0.0263s 0.1521s + Gen 1 16 colls, 15 par 27.189s 3.696s 0.2310s 0.4026s - Parallel GC work balance: 90.30% (serial 0%, perfect 100%) + Parallel GC work balance: 91.06% (serial 0%, perfect 100%) - TASKS: 70 (1 bound, 69 peak workers (69 total), using -N10) + TASKS: 68 (1 bound, 66 peak workers (67 total), using -N10) SPARKS: 7516 (7516 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled) - INIT time 0.174s ( 0.173s elapsed) - MUT time 612.239s (126.344s elapsed) - GC time 124.502s ( 16.293s elapsed) - EXIT time 0.107s ( 0.009s elapsed) - Total time 737.021s (142.819s elapsed) + INIT time 0.169s ( 0.168s elapsed) + MUT time 606.333s (127.778s elapsed) + GC time 125.828s ( 15.902s elapsed) + EXIT time 0.093s ( 0.001s elapsed) + Total time 732.422s (143.849s elapsed) - Alloc rate 2,024,767,533 bytes per MUT second + Alloc rate 2,044,112,631 bytes per MUT second - Productivity 83.1% of total user, 88.5% of total elapsed + Productivity 82.8% of total user, 88.8% of total elapsed diff --git a/purescript.cabal b/purescript.cabal index 401775a5e2..a367e8229b 100644 --- a/purescript.cabal +++ b/purescript.cabal @@ -174,8 +174,8 @@ common defaults cheapskate >=0.1.1.2 && <0.2, clock >=0.8.3 && <0.9, containers >=0.6.5.1 && <0.7, - -- unordered-containers, - -- hashable, + unordered-containers, + hashable, cryptonite ==0.30.*, data-ordlist >=0.4.7.0 && <0.5, deepseq >=1.4.6.1 && <1.5, diff --git a/src/Language/PureScript/Names.hs b/src/Language/PureScript/Names.hs index 094ae5773d..c75c0990d2 100644 --- a/src/Language/PureScript/Names.hs +++ b/src/Language/PureScript/Names.hs @@ -1,4 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} +{-# language DeriveAnyClass #-} +{-# LANGUAGE DerivingStrategies #-} -- | -- Data types for names @@ -20,6 +22,7 @@ import Data.Aeson.TH (deriveJSON) import Data.Text (Text) import Data.Text qualified as T import Data.Int (Int64) +import Data.Hashable (Hashable) import Language.PureScript.AST.SourcePos (SourcePos, pattern SourcePos) @@ -158,6 +161,7 @@ coerceOpName = OpName . runOpName -- newtype ProperName (a :: ProperNameType) = ProperName { runProperName :: Text } deriving (Show, Eq, Ord, Generic) + deriving anyclass Hashable instance NFData (ProperName a) instance Serialise (ProperName a) @@ -176,6 +180,7 @@ data ProperNameType | ConstructorName | ClassName | Namespace + deriving (Show, Eq, Ord, Generic, Hashable) -- | -- Coerces a ProperName from one ProperNameType to another. This should be used diff --git a/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs b/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs index 3b4c019521..d940cebc06 100755 --- a/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs +++ b/src/Language/PureScript/Sugar/TypeClasses/Deriving.hs @@ -17,6 +17,9 @@ import Language.PureScript.Names (pattern ByNullSourcePos, Ident(..), ModuleName import Language.PureScript.PSString (mkString) import Language.PureScript.Types (SourceType, Type(..), WildcardData(..), replaceAllTypeVars, srcTypeApp, srcTypeConstructor, srcTypeLevelString) import Language.PureScript.TypeChecker (checkNewtype) +import Data.HashMap.Strict qualified as HM +import Data.Map qualified as M +import Data.Map (Map) -- | Elaborates deriving instance declarations by code generation. deriveInstances @@ -25,7 +28,14 @@ deriveInstances => Module -> m Module deriveInstances (Module ss coms mn ds exts) = - Module ss coms mn <$> mapM (deriveInstance mn ds) ds <*> pure exts + Module ss coms mn <$> mapM (deriveInstance mn dsMap) ds <*> pure exts + where + dsMap :: DeclarationMap + dsMap = foldl' (\m d -> case d of + (DataDeclaration _ _ nm _ _) -> HM.insert nm d m + _ -> m) HM.empty ds + +type DeclarationMap = HM.HashMap (ProperName 'TypeName) Declaration -- | Takes a declaration, and if the declaration is a deriving TypeInstanceDeclaration, -- elaborates that into an instance declaration via code generation. @@ -40,7 +50,7 @@ deriveInstance :: forall m . (MonadError MultipleErrors m, MonadSupply m) => ModuleName - -> [Declaration] + -> DeclarationMap -> Declaration -> m Declaration deriveInstance mn ds decl = @@ -198,10 +208,6 @@ findTypeDecl :: (MonadError MultipleErrors m) => SourceSpan -> ProperName 'TypeName - -> [Declaration] + -> DeclarationMap -> m Declaration -findTypeDecl ss tyConNm = note (errorMessage' ss $ CannotFindDerivingType tyConNm) . find isTypeDecl - where - isTypeDecl :: Declaration -> Bool - isTypeDecl (DataDeclaration _ _ nm _ _) = nm == tyConNm - isTypeDecl _ = False +findTypeDecl ss tyConNm = note (errorMessage' ss $ CannotFindDerivingType tyConNm) . HM.lookup tyConNm