Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make make gen faster #8392

Closed
magik6k opened this issue Mar 29, 2022 · 4 comments · Fixed by #12493
Closed

Make make gen faster #8392

magik6k opened this issue Mar 29, 2022 · 4 comments · Fixed by #12493
Assignees
Labels
area/build Discussions about build and compilation issues dif/easy An existing lotus user should be able to pick this up effort/hours Effort: Hours good first issue Good for newcomers help wanted Extra attention is needed theme/dx
Milestone

Comments

@magik6k
Copy link
Contributor

magik6k commented Mar 29, 2022

Mostly make it actually work in parallel

@TippyFlitsUK TippyFlitsUK added need/team-input Hint: Needs Team Input area/build Discussions about build and compilation issues labels Mar 30, 2022
@magik6k magik6k removed their assignment Jun 14, 2022
@magik6k magik6k added help wanted Extra attention is needed good first issue Good for newcomers dif/easy An existing lotus user should be able to pick this up effort/hours Effort: Hours and removed need/team-input Hint: Needs Team Input labels Jun 14, 2022
@rjan90 rjan90 added this to FilOz Jul 11, 2024
@rjan90 rjan90 moved this to 📌 Triage in FilOz Jul 11, 2024
@rvagg
Copy link
Member

rvagg commented Jul 18, 2024

$ make gen
...
real    1m40.957s

Linux, nvme, plenty of power and resources.

If I go and time prefix every step in the makefile then I can break it down into the various stages:

make gen

go run ./gen/inline-gen . gen/inlinegen-data.json
# 0m0.176s
go run ./chain/actors/agen
# 0m0.296s
go fmt ./...
# 0m0.594s
go run ./gen/api
# 0m0.255s
goimports -w api
# 0m0.132s
goimports -w api
# 0m0.127s
go run ./gen/main.go
# 0m5.147s
go generate -x ./...
# 1m1.699s
goimports -w api/
# 0m0.122s
go run ./node/config/cfgdocgen > ./node/config/doc_gen.go
# 0m0.149s
go run ./scripts/fiximports
# 0m5.130s
go build -ldflags="-X=github.com/filecoin-project/lotus/build.CurrentCommit=+git.3daff2ed8.dirty" -o docgen-md ./api/docgen/cmd
# 0m0.307s
./docgen-md "api/api_full.go" "FullNode" "api" "./api" > documentation/en/api-v1-unstable-methods.md
# 0m0.060s
./docgen-md "api/v0api/full.go" "FullNode" "v0api" "./api/v0api" > documentation/en/api-v0-methods.md
# 0m0.048s
./docgen-md "api/api_storage.go" "StorageMiner" "api" "./api" > documentation/en/api-v0-methods-miner.md
# 0m0.052s
./docgen-md "api/api_worker.go" "Worker" "api" "./api" > documentation/en/api-v0-methods-worker.md
# 0m0.055s
go build -ldflags="-X=github.com/filecoin-project/lotus/build.CurrentCommit=+git.3daff2ed8.dirty" -o docgen-openrpc ./api/docgen-openrpc/cmd
# 0m0.304s
./docgen-openrpc "api/api_full.go" "FullNode" "api" "./api" > build/openrpc/full.json
# 0m1.958s
./docgen-openrpc "api/api_storage.go" "StorageMiner" "api" "./api" > build/openrpc/miner.json
# 0m0.792s
./docgen-openrpc "api/api_worker.go" "Worker" "api" "./api" > build/openrpc/worker.json
# 0m0.365s
./docgen-openrpc "api/api_gateway.go" "Gateway" "api" "./api" > build/openrpc/gateway.json
# 0m0.890s
go run ./scripts/fiximports
# 0m5.019s
go run ./scripts/fiximports
# 0m4.953s
  • We already sped up fiximports a bit, but we also need to dedupe it in here
  • go generate takes the bulk of the time and it's parallelisable, perhaps we should replace it with a new parent tool that does the same thing but forks out a go generate child for each thing it finds that needs generating (seems like something up @masih's alley)

@rvagg
Copy link
Member

rvagg commented Jul 18, 2024

Thread on parallel go generate being rejected from core (also appearance from the ever-present Daniel): golang/go#20520

@rjan90
Copy link
Contributor

rjan90 commented Jul 18, 2024

Gathering some metrics/benchmarks on make gen.

real	2m13.809s
user	2m9.710s
sys	0m30.339s
  • My machine must be cursed, or in dire need of some cleanup/: time make gen on a bit older CPU Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz with plenty of RAM:
real	5m46,295s
user	14m12,453s
sys	2m9,963s

@rjan90 rjan90 added this to the DX-Streamline milestone Jul 23, 2024
@rjan90 rjan90 moved this from 📌 Triage to 🐱Todo in FilOz Jul 23, 2024
@BigLep
Copy link
Member

BigLep commented Sep 18, 2024

Note: during #12467 the slowness of make gen was a bit painful in the pre-PR work and CI checks of attempting to rush out patches.

@masih masih self-assigned this Sep 19, 2024
@masih masih moved this from 🐱 Todo to ⌨️ In Progress in FilOz Sep 19, 2024
masih added a commit that referenced this issue Sep 19, 2024
The changes here simplify the string of targets executed as part of
`make gen`. The simplifications include:
* parallelised code generation whenever possible
* re-implementation of documentation generation for a significant
  simplification and improved readability.
* unified mocks generation to avoid multiple slow calls to `go run` per
  package.

Note, the changes introduced here are purely mechanical and do not alter
the Lotus node functionality.

Fixes #8392
@masih masih moved this from ⌨️ In Progress to 🔎 Awaiting review in FilOz Sep 19, 2024
@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to 🎉 Done in FilOz Sep 20, 2024
@rjan90 rjan90 removed the status in FilOz Sep 24, 2024
@rjan90 rjan90 moved this to ☑️ Done (Archive) in FilOz Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Discussions about build and compilation issues dif/easy An existing lotus user should be able to pick this up effort/hours Effort: Hours good first issue Good for newcomers help wanted Extra attention is needed theme/dx
Projects
Status: ☑️ Done (Archive)
Development

Successfully merging a pull request may close this issue.

6 participants