Tweak adapter cost of lists (#4853)
I noticed an oss-fuzz-based timeout that was reported for the `component_api` fuzzer where the adapter module generated takes 1.5 seconds to compile the singular function in release mode (no fuzzing enabled). The test case in question was a deeply recursive list-of-list-of-etc and only one function was generated instead of multiple. I updated the cost of strings/lists to cost more in the approximate cost calculation which now forces the one giant function to get split up and the large function is now split up into multiple smaller function that take milliseconds to compile.
This commit is contained in:
@@ -514,12 +514,12 @@ impl Compiler<'_, '_> {
|
|||||||
InterfaceType::Char => 1,
|
InterfaceType::Char => 1,
|
||||||
|
|
||||||
// This has a fair bit of code behind it depending on the
|
// This has a fair bit of code behind it depending on the
|
||||||
// strings/encodings in play, so arbitrarily assign it a cost a 5.
|
// strings/encodings in play, so arbitrarily assign it this cost.
|
||||||
InterfaceType::String => 5,
|
InterfaceType::String => 40,
|
||||||
|
|
||||||
// Iteration of a loop is along the lines of the cost of a string
|
// Iteration of a loop is along the lines of the cost of a string
|
||||||
// so give it the same cost
|
// so give it the same cost
|
||||||
InterfaceType::List(_) => 5,
|
InterfaceType::List(_) => 40,
|
||||||
|
|
||||||
InterfaceType::Flags(i) => {
|
InterfaceType::Flags(i) => {
|
||||||
let count = self.module.types[*i].names.len();
|
let count = self.module.types[*i].names.len();
|
||||||
|
|||||||
Reference in New Issue
Block a user