Skip to content

Typechecking memory use #31849

Closed
Closed
@asajeffrey

Description

@asajeffrey

Typechecking the rust library at https://github.com/asajeffrey/wasm/tree/typechecking-blowup uses more than 10G of memory. The program uses a lot of nested generic traits and lifetime polymorphism. The timing details are:

$ multirust run nightly cargo rustc -- -Z time-passes
   Compiling wasm v0.0.1 (file:///home/ajeffrey/github/asajeffrey/wasm)
time: 0.001; rss: 49MB  parsing
time: 0.000; rss: 49MB  configuration 1
time: 0.000; rss: 49MB  recursion limit
time: 0.000; rss: 49MB  gated macro checking
time: 0.000; rss: 49MB  crate injection
time: 0.003; rss: 54MB  macro loading
time: 0.000; rss: 54MB  plugin loading
time: 0.000; rss: 54MB  plugin registration
time: 0.025; rss: 56MB  expansion
time: 0.001; rss: 56MB  complete gated feature checking 1
time: 0.007; rss: 56MB  configuration 2
time: 0.000; rss: 56MB  gated configuration checking
time: 0.003; rss: 56MB  maybe building test harness
time: 0.003; rss: 56MB  prelude injection
time: 0.000; rss: 56MB  checking that all macro invocations are gone
time: 0.000; rss: 56MB  checking for inline asm in case the target doesn't support it
time: 0.000; rss: 56MB  complete gated feature checking 2
time: 0.000; rss: 56MB  const fn bodies and arguments
time: 0.002; rss: 56MB  assigning node ids
time: 0.003; rss: 62MB  lowering ast -> hir
time: 0.001; rss: 62MB  indexing hir
time: 0.000; rss: 62MB  attribute checking
time: 0.002; rss: 62MB  early lint checks
time: 0.001; rss: 60MB  external crate/lib resolution
time: 0.000; rss: 60MB  language item collection
time: 0.005; rss: 68MB  resolution
time: 0.000; rss: 68MB  lifetime resolution
time: 0.000; rss: 68MB  looking for entry point
time: 0.000; rss: 68MB  looking for plugin registrar
time: 0.001; rss: 69MB  region resolution
time: 0.000; rss: 69MB  loop checking
time: 0.000; rss: 69MB  static item recursion checking
time: 0.003; rss: 71MB  type collecting
time: 0.000; rss: 71MB  variance inference
time: 0.027; rss: 89MB  coherence checking
time: 0.014; rss: 89MB  wf checking
time: 0.004; rss: 89MB  item-types checking

at which point the process starts using large amounts of time and memory.

The same behaviour happens with nightly-2015-12-01, so this is not part of the recent rewrite of typechecking.

Discussed on irc with @eddyb, @Manishearth and @aturon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions