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

Improved global deadcode elimination #1681

Merged
merged 13 commits into from
Sep 25, 2024
Merged

Conversation

vouillon
Copy link
Member

@vouillon vouillon commented Sep 23, 2024

We now take into account of whether an instruction is in a live function or not when generating constraints, so that dead code can no longer result in making a variable live.

We also keep track of nested module.

The performance of the algorithm has been greatly improved as well.

On the basic_website example of Tyxml, compiled with --opt 3, I get the following reduction in code size:

before after
uncompressed 139304 125168 -10%
gzip 47980 41367 -14%
bzip2 45298 38885 -14%

Here are the numbers regarding #1612, when compiling with_bedrock2_fiat_crypto.byte. For comparison, I have included an intermediate step which just optimizes the current algorithm.

before optimized after
duration (s) 48 4.9 9.8
peak memory (GiB) 4 2.8 2.8

@vouillon vouillon force-pushed the improved-deadcode-elimination branch from bb2da77 to ed8e401 Compare September 23, 2024 20:23
@hhugo
Copy link
Member

hhugo commented Sep 23, 2024

You need to check the effect on #1612 (if not already done)

@vouillon vouillon force-pushed the improved-deadcode-elimination branch 2 times, most recently from b4776ee to b314e35 Compare September 24, 2024 09:45
@vouillon vouillon force-pushed the improved-deadcode-elimination branch from c8d7a75 to 1d8e0b6 Compare September 24, 2024 10:20
@vouillon vouillon changed the title Improved deadcode elimination Improved global deadcode elimination Sep 24, 2024
@vouillon vouillon force-pushed the improved-deadcode-elimination branch from 1d8e0b6 to b06b0e4 Compare September 24, 2024 11:24
@vouillon vouillon marked this pull request as ready for review September 24, 2024 11:24
@hhugo
Copy link
Member

hhugo commented Sep 24, 2024

Regarding #1612, when compiling with_bedrock2_fiat_crypto.byte the analysis takes 40s with this PR. It takes 48s with master. But there is an intermediate step in this PR with an improved solver which reduces the duration of the initial analysis to 15s.

What about memory peak ?

@vouillon vouillon force-pushed the improved-deadcode-elimination branch from b06b0e4 to 3a52bb1 Compare September 24, 2024 11:31
@vouillon vouillon force-pushed the improved-deadcode-elimination branch 3 times, most recently from fbfd7f8 to 6e10aee Compare September 24, 2024 14:20
@vouillon
Copy link
Member Author

I fixed a memory / speed issue. The numbers are pretty good now.

@hhugo
Copy link
Member

hhugo commented Sep 24, 2024

Cc @JasonGross

compiler/lib/generate.ml Outdated Show resolved Hide resolved
@hhugo
Copy link
Member

hhugo commented Sep 24, 2024

I didn't really reviewed df60582 . The rest looks good. Happy to merge.

And remove the `Undefined` expression from `Code.expr`.
Functions can have a large number of returned variables (typically, the
body is a match with lot of cases), which resulted on an overly large of
number of generated dependencies.
We were considering all instructions, even those which were inside dead
functions. Refine the analysis to only take into account constraints
corresponding to live code.
@vouillon vouillon force-pushed the improved-deadcode-elimination branch from 6e10aee to 0982199 Compare September 25, 2024 07:48
@hhugo hhugo merged commit 39ee469 into master Sep 25, 2024
18 checks passed
@hhugo hhugo deleted the improved-deadcode-elimination branch September 25, 2024 08:19
@OlivierNicole
Copy link
Contributor

cc @micahcantor FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants