commercialhaskell / commercialhaskell/stack

Avoid determining the location of the global package db multiple times

Open
#2,344 3 comments 0 reactions 0 assignees View on GitHub
type: performance
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

While executing the following script, `stack` reports twice that it's `Getting global package database location`.

```
#!/usr/bin/env stack
-- stack --resolver lts-6.6 --install-ghc runghc -v --package turtle

{-# LANGUAGE OverloadedStrings #-}

import Turtle

main = echo "Hello World!"
```

```
2016-07-06 17:14:18.899948: [debug] Getting global package database location @(stack-1.1.3-IC0DPHtEqkpJskQxlgUot4:Stack.GhcPkg src/Stack/GhcPkg.hs:48:5)
2016-07-06 17:14:18.900084: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-1.1.3-IC0DPHtEqkpJskQxlgUot4:System.Process.Read src/System/Process/Read.hs:292:3)
....
2016-07-06 17:14:19.531831: [debug] Getting global package database location @(stack-1.1.3-IC0DPHtEqkpJskQxlgUot4:Stack.GhcPkg src/Stack/GhcPkg.hs:48:5)
2016-07-06 17:14:19.531999: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-1.1.3-IC0DPHtEqkpJskQxlgUot4:System.Process.Read src/System/Process/Read.hs:292:3)
```

Is that location constant for a single stack run?

If yes, the result should be cached, possibly in the `EnvConfig`. On my machine, such a call to `ghc-pkg` costs about 10 - 20 ms.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.