Skip to content

Conversation

@jakobnissen
Copy link
Member

@jakobnissen jakobnissen commented Apr 10, 2025

This is the result of a small hunt I went on to find redundant methodinstances.

The results are disappointing - compared to master (commit 4480f42), it removes ~830 methodinstances (about 1% of those in the sysimg), and saves only 2.6MB in sys.so. Nonetheless, it may as well get merged.

Some more stuff that could be done but I don't know how to

  • Revive something like RFC: set nospecialize on any unused argument #54668
  • Despecialize the methods here which has several hundreds needless specializations, but which are defined before @nospecialize or @nospecializeinfer in the bootstrapping process
  • There are some methods that have huge codeinstances. About 80% of the system image savings in this PR is from a single methodinstance. Other bangers include sroa_pass!(ir::Compiler.IRCode, inlining::Union{Nothing, Compiler.InliningState}). Maybe those could be singled out for refactoring.

These methods compile to the same machine code regardless of input type, and in
the case of firstindex(::Tuple), also infers the same types.
This avoids creating a ton of new methods for in(x, ::NTuple), which generically
is recursively implemented, in order to support inference for heterogenous
tuples.
@jakobnissen
Copy link
Member Author

CI failure is unrelated (OOM on 32-bit Linux).

@jakobnissen
Copy link
Member Author

Closing as probably outdated, and also, @nsajko has done much more work on this so he should continue the effort

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.

1 participant