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

feat: asynchronous code generation #6770

Merged
merged 4 commits into from
Feb 3, 2025
Merged

Conversation

Kha
Copy link
Member

@Kha Kha commented Jan 24, 2025

This PR enables code generation to proceed in parallel to further elaboration.

It does not aim to make further refinements such as generating code for different declarations in parallel or removing the dependency on kernel checking.

@Kha
Copy link
Member Author

Kha commented Jan 24, 2025

!bench

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jan 24, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Jan 24, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 757899a7d179b3fd845d3e03031bbe360c80ef51 --onto c70f4064b4041dee70925bddbef095ebb2b36d7d. (2025-01-24 19:04:29)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 757899a7d179b3fd845d3e03031bbe360c80ef51 --onto 62788395345c7f145714157c138acd0e137ab716. (2025-01-26 20:08:50)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 757899a7d179b3fd845d3e03031bbe360c80ef51 --onto 20c616503abe5ce4253c56dbcd7766a91c675ba0. (2025-01-29 13:08:18)
  • ✅ Mathlib branch lean-pr-testing-6770 has successfully built against this PR. (2025-01-31 17:34:52) View Log
  • ❗ Batteries CI can not be attempted yet, as the nightly-testing-2025-02-02 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Batteries CI should run now. (2025-02-03 10:40:38)

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 63ac64b.
There were significant changes against commit 757899a:

  Benchmark                   Metric                  Change
  ====================================================================
- Init.Prelude async          branches                  2.3% (275.1 σ)
- Init.Prelude async          instructions              1.8% (253.4 σ)
- bv_decide_inequality.lean   task-clock                1.9%  (10.2 σ)
- ilean roundtrip             parse                     3.0%  (24.3 σ)
- parser                      task-clock                4.0%  (17.9 σ)
- parser                      wall-clock                4.0%  (18.3 σ)
- stdlib                      attribute application     1.9%  (18.2 σ)
- stdlib                      type checking             2.0% (210.4 σ)

@Kha Kha force-pushed the push-wxvvorszpxsw branch 2 times, most recently from e625ead to bc19fbf Compare January 26, 2025 19:45
@Kha Kha changed the title feat: asynchronous code generation feat: asynchronous code generation Jan 29, 2025
@Kha Kha force-pushed the push-wxvvorszpxsw branch from bc19fbf to b08b7ef Compare January 29, 2025 12:34
@Kha
Copy link
Member Author

Kha commented Jan 29, 2025

@zwarich FYI, you might want to take a look even though this interacts with the code generator only superficially, in compileDecls. The unification of that and compileDecl is desirable, I hope :) .

@Kha Kha force-pushed the push-wxvvorszpxsw branch 2 times, most recently from 9716893 to 3ace745 Compare January 31, 2025 16:04
@Kha
Copy link
Member Author

Kha commented Jan 31, 2025

!bench

@Kha Kha force-pushed the push-wxvvorszpxsw branch from 3ace745 to d985e84 Compare January 31, 2025 16:19
@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 3ace745.
There were significant changes against commit ad48761:

  Benchmark                      Metric       Change
  ============================================================
- Init.Data.List.Sublist async   task-clock     1.6%  (10.4 σ)
+ Init.Data.List.Sublist async   wall-clock    -3.1% (-14.6 σ)
- Init.Prelude async             branches       1.0% (107.1 σ)
+ big_omega.lean MT              task-clock    -2.9% (-11.6 σ)
+ big_omega.lean MT              wall-clock    -2.9% (-13.5 σ)
- stdlib                         dsimp          4.5%  (62.3 σ)

| [] => false
| (a::as) => a > 0 && f as

#print f._cstage2
Copy link
Member Author

@Kha Kha Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leodemoura @zwarich FYI, because of how the old codegen adds these stage declarations to the environment via C++, ident elaboration will not be able to find them anymore after this PR. The old codegen itself is unaffected. I assume this is acceptable as the new codegen does not use the environment in this way anyway, thus I've removed the single test that accesses them.

@Kha Kha force-pushed the push-wxvvorszpxsw branch from d985e84 to 1556ae4 Compare January 31, 2025 16:28
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jan 31, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 31, 2025
@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Jan 31, 2025
@Kha Kha force-pushed the push-wxvvorszpxsw branch from 1556ae4 to c47e9a9 Compare February 3, 2025 10:16
@Kha
Copy link
Member Author

Kha commented Feb 3, 2025

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 0ce68b1.
There were significant changes against commit d68c2ce:

  Benchmark                      Metric                    Change
  ==========================================================================
+ Init.Data.List.Sublist async   branches                   -1.8%  (-99.1 σ)
+ Init.Data.List.Sublist async   instructions               -1.5%  (-74.6 σ)
+ Init.Prelude async             branches                   -2.1%  (-33.8 σ)
+ Init.Prelude async             instructions               -1.7%  (-24.0 σ)
+ big_do                         task-clock                 -5.6%  (-61.5 σ)
+ big_do                         wall-clock                 -5.6%  (-64.0 σ)
- big_omega.lean MT              task-clock                  4.6%   (10.3 σ)
- big_omega.lean MT              wall-clock                  4.6%   (10.5 σ)
- binarytrees.st                 task-clock                  5.9%   (25.6 σ)
- binarytrees.st                 wall-clock                  5.9%   (25.3 σ)
- bv_decide_inequality.lean      task-clock                  4.1%   (64.3 σ)
- bv_decide_inequality.lean      wall-clock                  4.1%   (60.6 σ)
- parser                         task-clock                  5.7%   (32.4 σ)
- parser                         wall-clock                  5.7%   (31.1 σ)
- rbmap                          task-clock                  8.4%   (15.9 σ)
- rbmap                          wall-clock                  8.3%   (16.9 σ)
+ stdlib                         attribute application      -1.4%  (-20.2 σ)
+ stdlib                         process pre-definitions    -2.9%  (-17.8 σ)
+ stdlib                         tactic execution           -3.4% (-104.9 σ)
- unionfind                      task-clock                  8.5%   (12.0 σ)
- unionfind                      wall-clock                  8.5%   (12.1 σ)

@Kha
Copy link
Member Author

Kha commented Feb 3, 2025

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit c288ae4.
There were significant changes against commit d68c2ce:

  Benchmark                      Metric                 Change
  =======================================================================
+ Init.Data.List.Sublist async   branches                -1.9% (-191.1 σ)
+ Init.Data.List.Sublist async   instructions            -1.5% (-125.0 σ)
+ Init.Data.List.Sublist async   task-clock              -1.7%  (-11.4 σ)
+ Init.Data.List.Sublist async   wall-clock              -7.0%  (-77.1 σ)
+ Init.Prelude async             branches                -2.2% (-257.9 σ)
+ Init.Prelude async             instructions            -1.7% (-185.9 σ)
+ Init.Prelude async             wall-clock             -16.8%  (-25.3 σ)
- ilean roundtrip                compress                 6.1%   (34.0 σ)
+ ilean roundtrip                parse                   -3.8%  (-10.7 σ)
- ilean roundtrip                task-clock               3.4%   (19.8 σ)
- ilean roundtrip                wall-clock               3.4%   (19.1 σ)
- stdlib                         instantiate metavars     2.3%   (20.9 σ)

@Kha Kha marked this pull request as ready for review February 3, 2025 17:15
@Kha Kha requested a review from leodemoura as a code owner February 3, 2025 17:15
@Kha Kha enabled auto-merge February 3, 2025 17:16
@Kha Kha added the changelog-language Language features, tactics, and metaprograms label Feb 3, 2025
@Kha Kha added this pull request to the merge queue Feb 3, 2025
Merged via the queue into leanprover:master with commit d01e038 Feb 3, 2025
17 of 18 checks passed
@Kha Kha deleted the push-wxvvorszpxsw branch February 3, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features, tactics, and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants