mamift / CSharpTest.Net.Collections

Forked from https://github.com/csharptest/CSharpTest.Net.Collections to port to .NET Standard (Framework + Core). Nothing should've functionally changed.
5 stars 3 forks source link

Populating BPlusTree is considerably slower on Linux #2

Open p-m-j opened 2 years ago

p-m-j commented 2 years ago

To demonstrate I have created a small application which inserts a few paragraphs of lorem ipsum repeatedly into a BPlusTree<int,string> which can be found here https://gist.github.com/p-m-j/606a27877c26725b6058442f39a8fb64

Example output from my PC

Windows

Wrote 5000 entries to C:\Users\Paul Johnson\AppData\Local\Temp\tmp8DF0.tmp in 8.4379227

Linux

Wrote 5000 entries to /tmp/tmpd6FNXg.tmp in 95.3526502

nikcio commented 1 year ago

@p-m-j I looked at this a bit and found that is you don't use the /tmp/ folder in Linux you'll get much better results.

In my fork I've updated the test projects to see if they gave any clue to the mysterious behavior but I couldn't find anything there. I've also added a benchmark/test project CSharpText.Net.Benchmark where I've tested a bit if you'd like to validate the results 😄

My fork: https://github.com/nikcio/CSharpTest.Net.Collections

Using your gist example I found that when running the performance profiler in VS studio the Filename in the options matter.

On Linux using(Path.GetTempFileName) took: 1:24 min

image

On Linux using(Path.Combine(Environment.CurrentDirectory, "tmpfile.tmp") took: 20.642 seconds

image

On Windows using(Path.GetTempFileName) took: 11.728 seconds

image

On Windows using(Path.Combine(Environment.CurrentDirectory, "tmpfile.tmp") took: 9.814 seconds

image

The files here are from the results I've gathered: https://github.com/nikcio/CSharpTest.Net.Collections/commit/de9425f0180d00008ce5d09d57b732b467c36a5d

Maybe changing the path of the file will be an easy workaround to start with.

Note: This project could really need a hand. When I multitargeted the tests I found that a bunch of them fail in newer dotnet version