Don't limit ExternalName::TestName length #4764
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following up on discussion in #4667, here's a way to avoid making sweeping changes while still using reasonable names in filetests. @afonso360, how does this look to you? @cfallin, do the numbers here sound okay to you?
In order to keep the
ExternalName
enum small, theTestcaseName
struct was limited to 17 bytes: a 1 byte length and a 16 byte buffer. Due to alignment, that madeExternalName
20 bytes.That fixed-size buffer means that the names of functions in Cranelift filetests are truncated to fit, which limits our ability to give tests meaningful names. And I think meaningful names are important in tests.
This patch replaces the inline
TestcaseName
buffer with a heap-allocated slice. We don't care about performance for test names, so an indirection out to the heap is fine in that case. But we do care somewhat about the size ofExternalName
when it's used during compiles.On 64-bit systems,
Box<[u8]>
is 16 bytes, soTestcaseName
gets one byte smaller. Unfortunately, its alignment is 8 bytes, soExternalName
grows from 20 to 24 bytes.According to
valgrind --tool=dhat
, this change has very little effect on compiler performance. Building wasmtime with--no-default-features --release
, and compiling the pulldown-cmark benchmark from Sightglass, I measured these differences betweenmain
and this patch:ExternalName::TestCase
is not used in normal compiles)