Skip to content

Many assert_eq calls make compiler panic with too big data section #7612

@ironcev

Description

@ironcev

The behavior of compilation time increasing significantly when assert_eqs got added in tests utilizing generic functions over many test types was first noticed when we wrote tests for references in #5406.

We didn't investigate it at that time. The same effect is now noticeable in the in_language_tests for StorageVec where the compilation time of test projects gets longer as the number of tested types and assert_eq calls increased.

During that noticeable long compilation, one CPU is always on 100%.

In addition to long compilation, in the case of StorageVec tests, we also reach the data section limit:

thread 'main' (3610669) panicked at sway-core/src/asm_lang/allocated_ops.rs:999:19:
Unable to offset into the data section more than 2^12 bits. Unsupported data section length: 4807 words.

Inspection of the data section shows lot of log ids, which makes sense because assert_eq logs both arguments. In the case of these tests utilizing generic functions, those we have >30 different types for those arguments.

Aside form log ids, there are many entries in the data section that are just words.

The current workaround is to:

  • split the test projects into several smaller ones,
  • replace assert_eq with assert.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerGeneral compiler. Should eventually become more specific as the issue is triagedcompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgen

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions