Skip to content

Large performance penalty with `include`s

Compiling this contract uses many GB of RAM, 100% of a CPU core and takes 15~20 seconds on my machine:

module A1 = struct
  type t = int
end

module A2 = struct
  include A1
end

module A3 = struct
  include A2
end

module A4 = struct
  include A3
end

module A5 = struct
  include A4
end

module A6 = struct
  include A5
end

module A7 = struct
  include A6
end

module A8 = struct
  include A7
end

module A9 = struct
  include A8
end

module A10 = struct
  include A9
end

module A11 = struct
  include A10

  [@entry]
  let main () () : operation list * unit = [], ()
end

With ligo compile contract many_inclusions.mligo -m A11.

The more modules with inclusions you add, the slower it will go.

Edited by Heitor Toledo Lassarote de Paula