Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some randomly failing Perf.File tests on wasm/aot #2601

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

radical
Copy link
Member

@radical radical commented Sep 7, 2022

On wasm/aot, System.IO.FileSystem/Perf.File's CopyTo, CopyToOverride, and ReadAllBytes benchmarks fail randomly with:

---> System.IO.IOException: The file '/tmp/' already exists.
  at BenchmarkDotNet.Autogenerated.Runnable_48.Run(IHost host, String benchmarkName)
  at System.Reflection.MethodInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
  --- End of inner exception stack trace ---
  at BenchmarkDotNet.Autogenerated.UniqueProgramName.AfterAssemblyLoadingAttached(String[] args)

.. due to Path.GetTempFileName() being buggy - dotnet/runtime#73721.

In SetupReadAllBytes, we are building the test file path as:

_testFilePath = Path.Combine(baseDir, Path.GetTempFileName())

.. but the Path.GetTempFileName() is not appropriate here, as it will return a full path, and it will create the file. Instead we can use Path.GetRandomFileName() which should avoid the underlying issue completely.

Fixes dotnet/runtime#74104 .

On wasm/aot, `System.IO.FileSystem/Perf.File`'s `CopyTo`, `CopyToOverride`, and `ReadAllBytes` benchmarks fail randomly with:
```
---> System.IO.IOException: The file '/tmp/' already exists.
  at BenchmarkDotNet.Autogenerated.Runnable_48.Run(IHost host, String benchmarkName)
  at System.Reflection.MethodInvoker.InterpretedInvoke(Object , Span`1 , BindingFlags )
  --- End of inner exception stack trace ---
  at BenchmarkDotNet.Autogenerated.UniqueProgramName.AfterAssemblyLoadingAttached(String[] args)
```

.. due to `Path.GetTempFileName()` being buggy - dotnet/runtime#73721.

In `SetupReadAllBytes`, we are building the test file path as:
```csharp
_testFilePath = Path.Combine(baseDir, Path.GetTempFileName())
```

.. but the `Path.GetTempFileName()` is not appropriate here, as it will
return a full path, and it will create the file. Instead we can use
`Path.GetRandomFileName()` which should avoid the underlying issue
completely.

Fixes dotnet/runtime#74104 .
Copy link
Member

@LoopedBard3 LoopedBard3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, assuming tests pass (outside Maui desktop

@radical
Copy link
Member Author

radical commented Sep 7, 2022

The ubuntu errors aren't related, AFAICS:

[2022/09/07 19:57:57][INFO] ***Iteration Cleanup***
[2022/09/07 19:57:57][INFO] 
[2022/09/07 19:57:57][INFO] [2022/09/07 19:57:57][INFO] ----------------------------------------------
[2022/09/07 19:57:57][INFO] [2022/09/07 19:57:57][INFO] Initializing logger 2022-09-07 19:57:57.344415
[2022/09/07 19:57:57][INFO] [2022/09/07 19:57:57][INFO] ----------------------------------------------
[2022/09/07 19:57:57][INFO] [2022/09/07 19:57:57][INFO] Removing project directory...
[2022/09/07 19:57:57][INFO] 
[2022/09/07 19:57:57][INFO] modinfo: ERROR: Module lttng_probe_writeback not found.
[2022/09/07 19:57:57][INFO] Installing perf_event packages.
[2022/09/07 19:57:57][INFO] Installing LTTng packages.
[2022/09/07 19:57:57][INFO] 
[2022/09/07 19:57:57][INFO] tput: unknown terminal "unknown"
[2022/09/07 19:57:57][INFO] tput: unknown terminal "unknown"
[2022/09/07 19:57:57][INFO] E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
[2022/09/07 19:57:57][INFO] tput: unknown terminal "unknown"
[2022/09/07 19:57:57][INFO] tput: unknown terminal "unknown"
[2022/09/07 19:57:57][INFO] E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
[2022/09/07 19:57:57][INFO] 
...

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the fix @radical !

BTW I've checked and it seems that we are not using this method in other benchmarks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants