Git Product home page Git Product logo

Comments (4)

chitsaw avatar chitsaw commented on May 25, 2024 1

Thanks for the test code. We've identified a buffer allocation issue in BufferWriter. The fix in #293 should resolve this issue.

from psi.

sandrist avatar sandrist commented on May 25, 2024

Hi, sorry for missing this until now. One quick question: is the behavior reproducible outside of UWP and without StereoKit? Can you construct a more minimal test example that exhibits the behavior?

from psi.

austinbhale avatar austinbhale commented on May 25, 2024

No worries! Yes, I've modified the script to a DotNet console app where you can comment out the specific portion in the Vertex struct to use either 1) common float array or 2) MathNet types. The tests at the bottom also exhibit the runtime differences when TrackMessageSize is enabled or not.

using Microsoft.Psi;
using Microsoft.Psi.Data;
using System.Diagnostics;
using MathNet.Spatial.Euclidean;

int[] sizes = { 1000, 10000, 20000, 30000 };

foreach (int size in sizes)
{
    using var pipeline = Pipeline.Create(
        "TestHang",
        enableDiagnostics: true,
        diagnosticsConfiguration: new Microsoft.Psi.Diagnostics.DiagnosticsConfiguration
        {
            TrackMessageSize = true,
            AveragingTimeSpan = TimeSpan.FromSeconds(2),
            SamplingInterval = TimeSpan.FromSeconds(10),
            IncludeStoppedPipelines = true,
            IncludeStoppedPipelineElements = true,
        });

    PsiExporter store = PsiStore.Create(pipeline, pipeline.Name, Directory.GetCurrentDirectory());
    pipeline.Diagnostics.Write("Diagnostics", store);

    Generators.Range(pipeline, 0, 5, TimeSpan.FromMilliseconds(1))
              .PipeTo(new TstProducer(pipeline, size))
              .PipeTo(new TstReceiver(pipeline));

    Stopwatch? sw = null;
    pipeline.PipelineRun += (_, _) => { Console.WriteLine("Started!"); sw = Stopwatch.StartNew(); };
    pipeline.PipelineCompleted += (_, _) => { Console.WriteLine($"Completed in {sw?.ElapsedMilliseconds}"); };

    pipeline.Run();
}

public struct Vertex
{
    public Vertex() {}

    // TEST 1: common types
    public double[] pos = {0, 0, 0};
    public double[] norm = {0, 0, 0};
    public double[] uv = {0, 0, 0};

    // TEST 2: MathNet types
    // public Vector3D pos;
    // public Vector3D norm;
    // public Vector3D uv;
}

class TstProducer : IConsumer<int>, IProducer<Shared<Vertex[]>>
{
    public Receiver<int> In { get; }
    public Emitter<Shared<Vertex[]>> Out { get; }
    public TstProducer(Pipeline pipeline, int size)
    {
        Out = pipeline.CreateEmitter<Shared<Vertex[]>>(this, nameof(Out));
        In = pipeline.CreateReceiver<int>(this, (_, env) =>
        {
            using var verts = Shared.Create(new Vertex[size]);
            Out.Post(verts, env.OriginatingTime);
        }, nameof(In));
    }
}

class TstReceiver : IConsumer<Shared<Vertex[]>>
{
    public Receiver<Shared<Vertex[]>> In { get; }
    public TstReceiver(Pipeline pipeline)
    {
        In = pipeline.CreateReceiver<Shared<Vertex[]>>(this, (msg, env) =>
        {
            Console.WriteLine($"msg length: {msg.Resource.Length}");
        }, nameof(In));
    }
}

TEST 1: Common Types TrackMessageSize=TRUE

>dotnet run
Started!
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
Completed in 42
Started!
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
Completed in 148
Started!
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
Completed in 1619
Started!
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
Completed in 4974

TEST 2: MathNet Types TrackMessageSize=TRUE

>dotnet run
Started!
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
Completed in 45
Started!
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
Completed in 2989
Started!
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
Completed in 6232
Started!
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
Completed in 12080

TEST 1: Common Types TrackMessageSize=FALSE

>dotnet run
Started!
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
Completed in 40
Started!
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
Completed in 4
Started!
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
Completed in 5
Started!
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
Completed in 5

TEST 2: MathNet Types TrackMessageSize=FALSE

>dotnet run
Started!
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
msg length: 1000
Completed in 40
Started!
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
msg length: 10000
Completed in 4
Started!
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
msg length: 20000
Completed in 4
Started!
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
msg length: 30000
Completed in 4

from psi.

austinbhale avatar austinbhale commented on May 25, 2024

That makes a huge difference, thank you all so much!

from psi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.