Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Running 60+ Remote Ubuntu From Unity

Discussion in 'Scripting' started by gdosu, Jan 21, 2021.

  1. gdosu

    gdosu

    Joined:
    Aug 24, 2020
    Posts:
    13
    Hi all, I'm not expert so my expression could be ambiguous.

    I'm trying to running 60+ Ubuntu machine connected by 10Gbps ethernet in Unity with 28 cores.
    So I made a task using SSH.NET like this. (Each task takes 5+ min)

    Code (CSharp):
    1. class UbuntuWorker
    2. {
    3.    async Task Work()
    4.    {
    5.        client.Connect();
    6.        cmd = GetNextJob();
    7.        cmd.BeginExcute();
    8.        while(!cmd.IsCompleted)
    9.            await Task.Delay(3000);
    10.        result = cmd.EndExecute(cmd);
    11.        SaveResult(result);
    12.        client.Disconnect();
    13.    }
    14.    public void GoWork()
    15.    {
    16.        task = Task.Run(() => Work());
    17.    }
    18. }
    19. List<UbuntuWorker> workers = new List<UbuntuWorker>();
    20. List<string> jobs = new List<string>();
    21. LoadWorkers(workers);
    22. LoadJobs(jobs);
    23. foreach (var worker in workers)
    24.    worker.GoWork();
    25. while (jobs.Count() != 0)
    26. {
    27.    foreach (var worker in workers)
    28.        if (worker.hasCompleted)
    29.            worker.GoWork();
    30.        else
    31.            await Task.Delay(300);
    32. }  // These are not exact code but simplified.
    Then I made 60+ tasks during runtime and of course, I'm suffering from massive fps drop and freezing.
    I learned that it's bad design that using task more than cores, but I have to run machines as much as possible at the same time...

    Q1. I'm actually new to TPL. In this case, How should I design my code?

    Q2. Keeping 60+ connection using SSH.NET is also costly a bit. Is there an alternative approach, for example keeping process after disconnect and check it after 5 min?
     
    Last edited: Jan 23, 2021
  2. gdosu

    gdosu

    Joined:
    Aug 24, 2020
    Posts:
    13