Skip to content

[Wasm][AOT] Methods containing a try/catch block are 30x slower because of the interpreter #56309

@jeromelaban

Description

@jeromelaban

Description

Methods containing a try/catch/finally are 30x slower in recent builds because they are now run through the interpreter.

For example:

private static void TestTryCatch()
{
	int InvokeMethod(int a)
	{
		try
		{
			return a++;
		}
		catch
		{
			Console.WriteLine("catch");
			return 0;
		}
	}

	var sw = Stopwatch.StartNew();
	for (int i = 0; i < 10000000; i++)
	{
		InvokeMethod(i);
	}
	sw.Stop();
	Console.WriteLine($"TestTryCatch: {sw.ElapsedMilliseconds}");
}

Runs in 45ms with df6e956, and 1140ms with e983168

Here's a profiler trace screenshot:

image

Configuration

Working commit: df6e956
Failing commit: e983168 (it probably started doing this before this commit)

Regression?

Yes

Other information

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions