# Minimal-racket is very slow before installing compiler-lib

**URL:** <https://racket.discourse.group/t/minimal-racket-is-very-slow-before-installing-compiler-lib/967>\
**Category:** Questions & Answers\
**Tags:** homebrew\
**Created:** [May 4, 2022, 7:05pm UTC](https://racket.discourse.group/t/minimal-racket-is-very-slow-before-installing-compiler-lib/967 "2022-05-04T19:05:04Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [May 7, 2022, 5:19pm UTC](https://racket.discourse.group/t/minimal-racket-is-very-slow-before-installing-compiler-lib/967/20 "2022-05-07T17:19:08Z")

</div>

> [@mk12](#):
>
> Ok, back on my M1 Mac. Right after installing from the bottle (before `raco setup` ), there is indeed a file
> 
> > /opt/homebrew/Cellar/minimal-racket/8.5/lib/racket/compiled/opt/homebrew/Cellar/minimal-racket/8.5/share/racket/collects/compiler/private/compiled/cm-minimal\_rkt.zo
> 
> and denoting the inner opt/homebrew/.../private as `$X` , that's:
> 
> > /opt/homebrew/Cellar/minimal-racket/8.5/lib/racket/compiled/$X/compiled/cm-minimal\_rkt.zo
> 
> The absolute path `/$X/cm-minimal.rkt` does exist. Not `/$X/compiled/cm-minimal.rkt` .

This is what I was expecting (just another lesson in the dangers of writing enormous paths by hand.

> [@mk12](#):
>
> Here is the output of `racket -e "(find-compiled-file-roots)"` :
> 
> ```scheme
> '(same #<path:/opt/homebrew/Cellar/minimal-racket/8.5/lib/racket/compiled>)
> 
> ```

This is also right.

> [@mk12](#):
>
> However, I just realized I can't reproduce the 15s delay anymore. It's fast right after installing the bottle, without running `raco setup` . And after running `raco setup` there is no diff in the set of .zo files. This is puzzling since it looks like the bottle hasn't changed and I was able to reproduce it consistently yesterday.

> [@mk12](#):
>
> I've created a PR here: [minimal-racket: run raco setup post install by mk12 · Pull Request #100990 · Homebrew/homebrew-core · GitHub](https://github.com/Homebrew/homebrew-core/pull/100990)
> 
> Even if using Homebrew isn't the officially recommended way of getting Racket, or minimal-racket is only recommended for deployment scenarios, I think it's inevitable people will do what's most convenient. In my case I wasn't really trying to learn Racket or use it directly, it's just a dependency I need in order to do something else. Typing `brew install x y z` is a lot easier than looking up the recommended installation procedure for x, y, and z. And minimal-racket appeals to me because I don't want or need the GUI apps.
> 
> Of course, I'm more likely to want to explore Racket further if my first impression is a 200ms startup time rather than 15s. So I hope this PR helps provide a smoother on-ramp for macOS users.

I definitely agree that making this work is important to giving a good first impression! I used Homebrew's minimal Racket myself for several Racket release cycles when I was relatively new to Racket.

Adding an explicit `raco setup` step will definitely avoid the immediate problem, but I think it may be doing so by producing a duplicate set of `.zo` files.

I'll try to describe more of what seems to be happening from the Racket side, in the hope that someone else can figure out, if this is right, how Homebrew might be getting into this state.

Since the [Racket commit I mentioned above](https://github.com/racket/racket/commit/51b86068616f823a758a4e284dbe0ce0c0cfaec1) (February 2021, included in Racket since 8.1), running Racket's `./configure` with `--enable-origtree=no` and `--enable-macprefix`, as Homebrew does, installs Racket with source files under `${PREFIX}/share/racket` and the corresponding `.zo` files (which are architecture-specific) under `${PREFIX}/lib/racket/compiled/` (plus path elements for the absolute path to the source file). It then arranges for the result of `(find-compiled-file-roots)` to be something like the one you got:

```scheme
'(same #<path:/opt/homebrew/Cellar/minimal-racket/8.5/lib/racket/compiled>)

```

where `'same` means a relative path, e.g. `foo/info.rkt` compiled to `foo/compiled/info_rkt.zo`.

Racket will look for compiled files in both locations, but, if the compiled files are missing or outdated, it will write compiled files in the first location.

From the diffs you posted, it looks like `raco setup` is not using the existing compiled files under `lib/racket/compiled`, very possibly due to mtimes, and is instead generating additional compiled files in `compiled` directories relative to the source files.

Adding the `./configure` flag `--enable-sharezo` would have Racket install compiled files relative to the source files, so `(find-compiled-file-roots)` would just produce `'(same)`. That at least would mean that `raco setup` would use or update the existing `.zo` files, rather than generating a second set. The downside is architecture-specific files under `share/`, for those who care about that sort of thing.

Of course, it would be even better to figure out what's going wrong (very possibly with mtimes) that's making Racket not use the compiled files that already exist.

From the Racket side, I wonder if we should use mtimes only as a shortcut to hashing the source file, as Zuo does.

---

_[View the full topic](https://racket.discourse.group/t/minimal-racket-is-very-slow-before-installing-compiler-lib/967)._
