commercialhaskell / commercialhaskell/stack

`stack script --optimize` adds 380~460ms to the execution time of compiled executable.

Open
#3,336 1 comment 0 reactions 0 assignees View on GitHub
component: script interpreter
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### Steps to reproduce

Execute `test_echo.hs`

```haskell
#!/usr/bin/env stack
-- stack --resolver lts-9.0 script --package turtle --optimize
{-# LANGUAGE OverloadedStrings #-}
import Turtle

main :: IO ()
main = echo "Turtle is fast"
```

Execute `time test_echo.hs`
Execute `time test_echo`

### Expected

The execution time of `time test_echo.hs` should be similar to that of `time test_echo`.

### Actual

```
$ time test_echo.hs
Turtle is fast

real 0m0.377s
user 0m0.360s
sys 0m0.083s
```

```
$ time test_echo
Turtle is fast

real 0m0.002s
user 0m0.001s
sys 0m0.001s
```

For slightly larger programs, the gap is as large as ~460ms.

### Stack version

```
$ stack-bin --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) x86_64 hpack-0.17.1
```

### Method of installation

On gentoo, I executed

```
emerge -q dev-haskell/stack-bin
```

to install stack-bin executable.

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.