Skip to content

Commit

Permalink
Avoid unnecessarily decoding DALFs during dependency installation (#1…
Browse files Browse the repository at this point in the history
…1541)

We only need the package id which only requires decoding the header
which is exactly what decodearchivePackageId exists for.

On a large project this seems like a 10-20s improvement which is
pretty significant.

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Nov 4, 2021
1 parent afd79b6 commit 60dc286
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/damlc/lib/DA/Cli/Damlc/DependencyDb.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Control.Exception.Safe (tryAny)
import Control.Lens (toListOf)
import Control.Monad.Extra
import DA.Daml.Compiler.Dar
import DA.Daml.Compiler.DecodeDar (DecodedDalf(..), decodeDalf)
import DA.Daml.Compiler.ExtractDar (ExtractedDar(..), extractDar)
import DA.Daml.Helper.Ledger
import qualified DA.Daml.LF.Ast as LF
Expand Down Expand Up @@ -239,9 +238,8 @@ dalfFileNameFromEntry entry =

dalfFileName :: BS.ByteString -> FilePath -> IO FilePath
dalfFileName bs fp = do
DecodedDalf {decodedDalfPkg} <- either fail pure $ decodeDalf Set.empty fp bs
let pkgId = T.unpack $ LF.unPackageId $ LF.dalfPackageId decodedDalfPkg
pure $ pkgId </> takeFileName fp
pkgId <- either (fail . DA.Pretty.renderPretty) pure $ Archive.decodeArchivePackageId bs
pure $ T.unpack (LF.unPackageId pkgId) </> takeFileName fp

installDataDepDalf :: Bool -> FilePath -> FilePath -> BS.ByteString -> IO ()
installDataDepDalf isMain = installDalf ([dataDepMarker] ++ [mainMarker | isMain])
Expand Down

0 comments on commit 60dc286

Please sign in to comment.