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

piping from/to subprocesses is extremely slow on Windows #1568

Open
floitsch opened this issue Apr 21, 2023 · 0 comments
Open

piping from/to subprocesses is extremely slow on Windows #1568

floitsch opened this issue Apr 21, 2023 · 0 comments

Comments

@floitsch
Copy link
Member

floitsch commented Apr 21, 2023

The following function takes ~100 seconds to copy the SDK (~385 files and 94MB). On Linux the whole test is finished in 3 seconds.

copy_directory --source/string --target/string:
  directory.mkdir --recursive target
  source = source.replace --all "\\" "/"
  target = target.replace --all "\\" "/"
  // We are using `tar` so we keep the permissions.
  tar := tool_path_ "tar"
  from := pipe.from [tar, "c", "-f", "-", "-C", source, "."]
  to := pipe.to [tar, "x", "-f", "-", "-C", target]
  writer := writer.Writer to
  while chunk := from.read:
    writer.write chunk
  from.close
  to.close
tool_path_ function
tool_path_ tool/string -> string:
  if platform != PLATFORM_WINDOWS: return tool
  // On Windows, we use the <tool>.exe that comes with Git for Windows.

  // TODO(florian): depending on environment variables is brittle.
  // We should use `SearchPath` (to find `git.exe` in the PATH), or
  // 'SHGetSpecialFolderPath' (to find the default 'Program Files' folder).
  program_files_path := os.env.get "ProgramFiles"
  if not program_files_path:
    // This is brittle, as Windows localizes the name of the folder.
    program_files_path = "C:/Program Files"
  result := "$program_files_path/Git/usr/bin/$(tool).exe"
  if not file.is_file result:
    throw "Could not find $result. Please install Git for Windows"
  return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant