Skip to content

[WASM] Perf_Utf8Encoding and XmlConfigurationProvider benchmarks fail with DirectoryNotFoundException #5129

@ilonatommy

Description

@ilonatommy

WASM benchmarks that read test data files from disk fail with DirectoryNotFoundException because the files are not bundled into the WASM virtual filesystem. On WASM, Environment.CurrentDirectory returns /, so paths resolve to /libraries/... which don't exist in the VFS. 19 failures across all 11 partitions. Affected tests got disabled in #5114.

Error — Perf_Utf8Encoding

System.Reflection.TargetInvocationException: Arg_TargetInvocationException
 ---> System.IO.DirectoryNotFoundException: IO_PathNotFound_Path, /libraries/Common/EnglishAllAscii.txt
   at System.IO.File.ReadAllText(String path)
   at System.Text.Perf_Utf8Encoding.Setup()
   at BenchmarkDotNet.Engines.Engine.Run()
// Benchmark Process 707781 has exited with code 255.

full_log.txt

Error — XmlConfigurationProviderBenchmarks

System.Reflection.TargetInvocationException: Arg_TargetInvocationException
 ---> System.IO.DirectoryNotFoundException: IO_PathNotFound_Path,
    /libraries/Microsoft.Extensions.Configuration.Xml/TestFiles/simple.xml
   at System.IO.File.OpenRead(String path)
   at Microsoft.Extensions.Configuration.Xml.XmlConfigurationProviderBenchmarks.GlobalSetup()
   at BenchmarkDotNet.Engines.Engine.Run()
// Benchmark Process 709659 has exited with code 255.

full_log.txt

Missing Files (9 total)

Perf_Utf8Encoding.Setup()File.ReadAllText:

  • /libraries/Common/EnglishAllAscii.txt
  • /libraries/Common/EnglishMostlyAscii.txt
  • /libraries/Common/Chinese.txt
  • /libraries/Common/Cyrillic.txt
  • /libraries/Common/Greek.txt

XmlConfigurationProviderBenchmarks.GlobalSetup()File.OpenRead:

  • /libraries/Microsoft.Extensions.Configuration.Xml/TestFiles/simple.xml
  • /libraries/Microsoft.Extensions.Configuration.Xml/TestFiles/deep.xml
  • /libraries/Microsoft.Extensions.Configuration.Xml/TestFiles/names.xml
  • /libraries/Microsoft.Extensions.Configuration.Xml/TestFiles/repeated.xml

Affected Benchmarks (19 failures)

  • System.Text.Perf_Utf8Encoding.{GetBytes,GetByteCount,GetString} — 15 failures across inputs {EnglishAllAscii, EnglishMostlyAscii, Chinese, Cyrillic, Greek}
  • Microsoft.Extensions.Configuration.Xml.XmlConfigurationProviderBenchmarks.Load — 4 failures across {simple.xml, deep.xml, names.xml, repeated.xml}

All 11 partitions are affected (1–4 failures each).

Environment

BenchmarkDotNet v0.16.0-custom.20260225.100, Linux Ubuntu 22.04.5 LTS
AMD EPYC 9124 3.00GHz
  Wasm : .NET Core (Mono) 11.0.0-ci, Wasm AOT VectorSize=128
  Engine: v8-14.3.127 (--expose_wasm --module)
  • Job: Performance micro wasm wasm v8 linux x64 perfviper net11.0
  • Job ID: 925a1b8d-4fed-466f-9da4-8815e3953218

Root Cause

The test data files are not bundled into the WASM publish output. The benchmark [GlobalSetup] methods use Path.Combine(Environment.CurrentDirectory, "libraries", ...) which resolves to /libraries/... on WASM (where CWD is /), and those paths don't exist in the VFS.

Fix Options

  1. Use AppContext.BaseDirectory instead of Environment.CurrentDirectory for path resolution
  2. Bundle the test data files into the WASM virtual filesystem during build
  3. Embed the test data as resources and extract at runtime

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmreenableIssue that specifies something that was disabled and should eventually be reenabled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions