Skip to content

Compiler: refactor codegen#14760

Merged
straight-shoota merged 4 commits intocrystal-lang:masterfrom
ysbaddaden:refactor/compiler-parallel-codegen
Aug 6, 2024
Merged

Compiler: refactor codegen#14760
straight-shoota merged 4 commits intocrystal-lang:masterfrom
ysbaddaden:refactor/compiler-parallel-codegen

Conversation

@ysbaddaden
Copy link
Collaborator

@ysbaddaden ysbaddaden commented Jun 27, 2024

Refactors Crystal::Compiler:

  1. extracts #sequential_codegen, #parallel_codegen and #fork_codegen methods;
  2. merges #codegen_many_units into #codegen directly;
  3. stops collecting reused units: #fork_codegen now updates CompilationUnit#reused_compilation_unit? state as reported by the forked processes, and #print_codegen_stats now counts & filters the reused units.

Prerequisite for #14748 that will introduce #mt_codegen.

@ysbaddaden
Copy link
Collaborator Author

ysbaddaden commented Jun 27, 2024

AArch64 CI is failing with "fork not implemented" 🤨

EDIT: the issue is the legacy crystal compiler in the images (1.0.0 by default 😱) that doesn't support the has_method? macro outside of methods, so we can't generate different method implementations 😮‍💨

@straight-shoota
Copy link
Member

Actually, I prefer the version with a single def and different bodies, instead of different defs.

@ysbaddaden ysbaddaden changed the title Compiler codegen: small refactor Compiler codegen: small refactor with progress fix Jun 27, 2024
@ysbaddaden ysbaddaden marked this pull request as draft June 27, 2024 12:42
We only need to update unit.reused_compilation_unit? from forked process
then have print_codegen_stats count & filter the units.
@ysbaddaden ysbaddaden force-pushed the refactor/compiler-parallel-codegen branch from 162c8b0 to b17db55 Compare July 2, 2024 10:01
@ysbaddaden ysbaddaden changed the title Compiler codegen: small refactor with progress fix Compiler: refactor codegen Jul 2, 2024
@ysbaddaden
Copy link
Collaborator Author

Re-created from master to fix merge conflicts with #14762 and #14763.
Added a patch to stop collecting reused units.

@ysbaddaden ysbaddaden marked this pull request as ready for review July 2, 2024 10:11
@straight-shoota straight-shoota added this to the 1.14.0 milestone Jul 2, 2024
@straight-shoota straight-shoota merged commit b954dd7 into crystal-lang:master Aug 6, 2024
@ysbaddaden ysbaddaden deleted the refactor/compiler-parallel-codegen branch August 7, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants