Performance issue for dot-net-5.0 on docker running on centos server

Marc Dibeh 1 Reputation point
2021-04-20T05:30:28.537+00:00

I am encountering a performance problem while executing a bash command from dot-net-core 5.0.

  1. I have n files (.csv) in a specific directory
  2. based on some business rules I write n file_name into a (.txt) file
  3. After finishing I execute a shell command from dot-net-core that reads from the file and execute [mv] command which moves the files that their full names are written in the txt file from a location to another.
  4. The action is performing normally! but!
  5. The issue is that I execute the same process with the same resources (file_name.txt) from dot-net-core it took about 2 minutes to finish while the same code is executed from the shell took 11 seconds!
       string source_location = new FileInfo(files.FirstOrDefault()).DirectoryName;  
        string tmp_file_name = Guid.NewGuid().ToString().ToUpper();  
        string tmp_full_name = Path.Combine(source_location, tmp_file_name) + ".txt";  
        File.WriteAllLines(tmp_full_name, files);  
        string cmd = $"cat {tmp_full_name} | xargs mv -t  {targetFolder}";  
        string time_now = DateTime.Now.ToString();  
        Tuple<string, string> result = ShellHelper.Bash(cmd);  
        string time_finish = DateTime.Now.ToString();  
        string number_of_files = files.Count.ToString();  
        log.Info(String.Format("\n [START]: {0} \n [END]: {1} \n [RESULT_BASH]: {2} \n [STATE_BASH]: {3}   
                         \n [NUMBER_OF_FILES]: {4} --------------  \n", time_now, time_finish, result.Item1,   
                              result.Item2, number_of_files));  
    
    private static class ShellHelper
    {
    public static Tuple<string, string> Bash(string cmd)
    {
    var escapedArgs = cmd.Replace("\"", "\\"");
                var process = new Process()  
                {  
                    StartInfo = new ProcessStartInfo  
                    {  
                        FileName = "/bin/bash",  
                        Arguments = $"-c \"{escapedArgs}\"",  
                        RedirectStandardOutput = true,  
                        UseShellExecute = false,  
                        CreateNoWindow = true  
                    }  
                };  
    
                process.Start();  
                string result = process.StandardOutput.ReadToEnd();  
                process.WaitForExit();  
    
                return Tuple.Create(result, process.ExitCode.ToString());  
            }  
        }  
    

89347-750d00a0-e017-4936-93e1-95d224ebb6e4.txt89348-difference-of-result.txt

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,345 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,201 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,117 questions
0 comments No comments
{count} votes