facebook / facebook/buck2

Unnecessary rebuilds with dynamic actions

Open
#852 1 comment 0 reactions 0 assignees View on GitHub
bug haskell
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

In our project we utilize dynamic actions to compile Haskell modules.

When adding another source file to e.g. a `haskell_library` rule, we notice that each module gets recompiled although these did not change.

```bzl
load("//haskell:defs.bzl", "default_ghc_flags")

haskell_library(
name = "lib",
srcs = glob(["src/**/*.hs"]),
deps = [ ... ]
)
```

After adding an empty module to `src/Temp/Temp.hs`:
```hs
module Temp.Temp where
```
we first see a run of the `haskell_metadata` action -- this action gathers dependency information about each module, writes it to a JSON file. This JSON file is processed in a dynamic action in order to create `haskell_compile` actions per each module.

Note, we have enabled deferred materialization and the in-memory cache. There is no external cache / RE configured.

But still, even though the command line invocations did not change, and the digests of the inputs did not change (verified by printing the action metadata json) we still see that all modules of the current package are rebuild.

However, if an existing module is modified, e.g. just adding a comment, we see that the `haskell_metadata` action is run in order to update the dependency JSON, and it will not rebuild all modules.

It seems that changing the inputs to the rule itself will invalidate all (dynamically created) actions that are related to it. Is this what happens here or is there another thing at play?

(we use buck2 2024-11-01 currently)

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.