Adventures in Cygwin Fork Performance (2023)

introduction to the problem

As you may know, I maintain quite a few packages for Cygwin. Cygwin is a compatibility layer for Windows that makes it easier to run applications designed to run on Linux (details inwww.cygwin.com).

Due to Windows and NT kernel limitations, Cygwin is generally much slower to run than Linux, and one particular slowdown is due to the complex way Cygwin must emulate the Linux fork() call. This feature is used when creating processes, so things like bash scripts and make files tend to run very slowly in Cygwin.

I decided to investigate my issues because my packaging was taking too long, even compared to other much slower systems using other Cygwin maintainers.

I have made some other posts on Cygwin such as:this old. DDRescue GUI also uses Cygwinto support Windows.

DISCLAIMER OF LIABILITY:This is an informational guide - I am not responsible for any damage to your Windows installation. Note that most of the changes I've made here have had minimal impact and are difficult to measure, but I believe that's because QEMU/KVM has already eliminated most of the overhead. I suspect this guide will be very helpful for those running VirtualBox, but I can't confirm that. General troubleshooting steps should help.

OBSERVATION:Something I forgot to mention is that the drop in fork performance over time was eliminated by these changes - it started out relatively "quickly", but then got so bad that it became a significant waste of time building packages. Also, my packaging time was drastically reduced after these changes. Unfortunately, I didn't measure the before and after, so I can't prove the change.

TO UPDATE: There is a general guide to help you get started with Cygwinhttps://www.pcwdld.com/cygwin-cheat-sheet.

installation details

I originally ran Windows in VirtualBox which turned out to be MUCH slower than using QEMU/KVM with virt-manager. Many of the performance issues have been fixed by just using QEMU/KVM, but apparently this only works on Linux hosts. Fork speed seems to drop on repeated attempts on Cygwin but not on Linux.

Here are my configuration details:

CPU: 6-core Ryzen 3600 (at standard speed).

(Video) Adventures in Cygwin's fork Performance

RAM: 32GB (16GB dedicated to Windows VM)

Hipervisor: QEMU/KVM (hardware acceleration on).

Storage: 100 GB virtual disk connected to VirtIO (much faster than emulating SATA).

Antivirus: Avira Free Antivirus (with the exception of Cygwin).

Windows Version: Windows 10 20H2 (although this walkthrough is also relevant for earlier Windows versions). Almost a clean install, minimal additional apps added.

Sistema operacional host: Linux Mint 20 Cinnamon (64 bits).

Cygwin: 3.1.6, 64-bit (32-bit Cygwin is unreliable and erratic due to some limitations). The CYGWIN environment variable is set to winsymlinks:lnk proc_retry:3.

The video

first benchmarks

To measure the performance difference, I use a fork benchmark program available athttps://github.com/mondalaci/fork-benchmark. I ran the benchmark 3 times for each run and averaged the results, with 100 clean forks and boots between each run.

I decided to test my Linux host OS as well, just out of interest and to demonstrate how much slower Cygwin is compared to Linux, making sure to close as many programs as possible. Note that my screen recorder slowed things down a bit.

(Video) cygwin fork error

Linux: 0.23 seconds (average of 3 runs).

Cygwin: 13 seconds (accurate to the nearest second, with time delay).

diagnostic stages

Disabling my antivirus (health check)

I had already made exceptions for Cygwin folders, but I thought it would be a good idea to double-check that my antivirus wasn't interfering in some way. I suggest you choose the "Disable until restart" option or something like that in case you forget to re-enable your antivirus.

Results: 13 seconds (accurate to the second, with drop).

This was good because it meant my antivirus was configured correctly. If Cygwin is suddenly much faster, you may need to check that you have defined exceptions for the C:\Cygwin folder (or wherever you installed Cygwin).

Script Debloat

This script disables a bunch of Windows 10 bloatware that slows down your system, courtesy of Chris Titus Tech on YouTube. My systems run noticeably faster afterwards for everyday use. Ignore this if you are not running Windows 10.

You can find instructions on how to do this athttps://christitus.com/debloat-windows-10-2020/. I selected "Essential Settings", then turned off Cortana and OneDrive, then "Background Apps", which limits the number of apps running in the background.

Note: It's a good idea to back up your data before doing this.

Results: 12.2 seconds (with fall). A small improvement, but probably within the margin of error.

Change Windows virtual memory settings (VM only)

I disabled the paging file in Control Panel > System > Advanced System Settings. You probably don't want to do this on bare metal, but it can improve VM performance.

(Video) cygwin: how to fix fork failures

Results: 13.2 seconds (with fall). Probably within the margin of error.

Change Windows Power Management Settings

You might also not want to do this on bare metal to save power.

Windows uses the Balanced plan by default, but there is also a "Performance" plan that can slightly improve performance. I also went through the individual settings, but I didn't change much.

Results: 12.6 seconds (with fall). A small improvement, but probably within the margin of error. However, we set the fastest individual time at 10.4 seconds.

Change Windows performance settings

Windows has several general performance and graphics fidelity settings that can affect performance (especially if, like me, you don't have video acceleration). This can also be found in advanced system settings.

I disabled everything except font smoothing, drag window content and window shadows. You may also want shadows on the desktop icon.

Results: 12.8 seconds (with drop). Probably within the margin of error. Again. At this point I'm a little frustrated!

Disable System Restore

Again, you probably only want to do this if you're using a VM and have snapshots/backups. This option can be found under System Properties > System Restore. You can also delete old restore points here.

Results: 12.2 seconds (with fall). A small improvement, but probably within the margin of error.

Edit the cygserver (Cygwin Server) options.

This is a Cygwin specific configuration change. See details of what can changehttps://cygwin.com/pipermail/cygwin-apps/2020-December/040796.html(Click "Previous Post by Thread" a few times for more context.)

(Video) Cygwin from Windows is very slow/ laggy (6 Solutions!!)

Results: 12.2 seconds (with fall). Like this!

Disable some Windows services

Do this at your own risk.This can seriously affect your system's stability or reliability. I used this article as a guide:https://www.thewindowsclub.com/which-windows-10-services-safe-to-disable.

You can also disable unnecessary startup programs via msconfig or task manager.

Watch the video on YouTube if you want to see exactly what I changed.

Results: 12.6 seconds (with fall).

Extra: KVM-CPU-Configuration

By default, KVM specifies many CPU sockets instead of cores or threads. Windows does not support more than 2 CPUs so you may need to change this to improve performance. I can't believe I missed it.

Results: 12.6 seconds (with fall). That's disappointing, but I think it's still within the margin of error.

Conclusion on Cygwin performance

Sometimes it's better to start with the simple things! I find it interesting that forking with 2 cores was faster than with 6 in VirtualBox. I completed compiling a package after the video was finished and it was significantly faster than before, which was nice.

I hope I helped and until the next post 🙂

(Video) Fixing a Slow Cygwin by Re-installing it the Right Way

Related

FAQs

What are the benefits of Cygwin? ›

The advantage of having cygwin available is that you can standardize your applications and shell scripts across all platforms. In terms of POSIX compliance among the big three (Windows, Mac OS X, and Linux), Windows is the only platform that lacks common UNIX tools and paradigms.

Why use Cygwin on Windows? ›

Cygwin offers users a Linux-like experience in a Windows environment. This capability helps developers migrate applications from Unix or Linux to Windows-based systems and makes it easier to support their applications running on the Windows platform.

What are the tools for Cygwin? ›

Cygwin is a collection of GNU and Open Source tools that provide a Linux-like environment for Windows: using it we can install and use llvm (which includes the GCC compilers), Clang (which includes Clang compilers), GDB (a debugger used by both compilers), and make/cmake (tools that which we use to specify how to build ...

What does Cygwin include? ›

Cygwin consists of a library that implements the POSIX system call API in terms of Windows system calls to enable running of a large number of application programs equivalent to those on Unix systems, and a GNU development toolchain (including GCC and GDB) to allow software development.

How can I make Cygwin faster? ›

Trim down your Windows PATH (to the bare bones like %SystemRoot%\system32;%SystemRoot%) Remove things you don't need from bashrc and bash_profile. Move things you only need in your terminal window from bashrc to bash_profile. One surprisingly large time suck in Cygwin is Bash completion.

Is there anything better than Cygwin? ›

MobaXterm

MobaXterm is a free Windows-based SSH server and tabbed client. It is one of the best and enhanced terminals for various types of remote computer network tools. The developers regard the MobaXterm as an ultimate remote computer toolbox, so it is used most of the time.

Is Cygwin slow? ›

Introduction to the problem

Due to limitations of Windows and the NT kernel, Cygwin is often a lot slower than Linux when running, and one particular slowdown is due to the complex way Cygwin has to emulate the Linux fork() call.

Is Cygwin still relevant? ›

Cygwin is still relevant if you wish to have native *nix commands available to you on the Windows platform.

Which is better Cygwin or MinGW? ›

Is MinGW (MinGW-64) better than Cygwin in terms of MSVC alternative for creating Windows application? If your program will run only on Windows, then MinGW is likely the better choice. MinGW is designed to create Windows applications. It doesn't require users to install additional software to run your application.

Does Cygwin have a GUI? ›

XLaunch is a GUI wizard for starting the Cygwin/X X server and a local or remote X client. These sessions can be saved and shared as . xlaunch files.

Does Cygwin have bash? ›

The Cygwin installation creates a Bash shell along with a UNIX environment by which you can compile and run UNIX-like programs. Using this one can even create an emulated X server on your windows box and run UNIX-like GUI software tools.

Is Cygwin a C compiler? ›

Cygwin is a UNIX environment, developed by Red Hat, for Windows. You can compile your C programs by the command gcc in the Cygwin command window.

Does Cygwin have a C++ compiler? ›

description: The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, and Go, as well as libraries for these languages (libstdc++, libgcj,...).

Does Cygwin have Python? ›

Installing Python for Cygwin. Packages are installed for Cygwin using its setup utility, setup-x86_64.exe for 64-bit (source: http://cygwin.com/install.html). By default, the Cygwin setup utility asks for elevated Administrative permissions.

Is Cygwin same as git bash? ›

Git bash, and related tools in msysgit package, are pure Windows executables. That's why you cannot run Cygwin tools into Git bash, since these are not completely windows programs (they need the cygwin.

Can Cygwin compile for Windows? ›

To compile and run SU2 in Cygwin on a Windows machine, you will need to configure Cygwin with the appropriate packages (listed below), and then continue from within Cygwin as though you were using a linux machine. In summary, the steps are: Download Cygwin installer.

Should I install all Cygwin packages? ›

You can always install any package you want after you've installed Cygwin. There is no need to install them all at once go. i'm sure most people(apart from the OP perhaps) are aware that you can do it very manually what you call 'doing the effort' and while you say about backing it up you don't state how.

What should I install from Cygwin? ›

Essential Cygwin Development Packages
  1. Devel: cmake. cmake-gui. gcc-core. gcc-g++ gdb. git. make.
  2. Libs: libboost-devel.
  3. Python: python3.
  4. Shells: chere (for shell integration)
  5. X11: (Needed for cmake-gui) gnu-free-fonts. xinit.
Dec 16, 2015

Is MSYS2 better than Cygwin? ›

The difference between MSYS2 and CYGWIN is that MSYS2 is oriented to the development of native Windows packages, while CYGWIN tries to provide a complete POSIX-like system to run any Unix application on it. For that reason, we recommend the use of MSYS2 as a subsystem to be used with Conan.

Is MinGW and Cygwin same? ›

MinGW (short for "Minimalist GNU for Windows"), is a minimalist (i.e., small but fewer features compared with cygwin) development environment for native Microsoft Windows applications, in particular: 1. A port of the GNU Compiler Collection (GCC), including C, C++, ADA and Fortran compilers; 2.

Can I have both MinGW and Cygwin? ›

You can install MinGW-W64 under "Cygwin" by selecting these packages (under "Devel" category): mingw64-x86_64-gcc-core : 64-bit C compiler for native 64-bit Windows. The executable is " x86_64-w64-mingw32-gcc ". mingw64-x86_64-gcc-g++ : 64-bit C++ compiler for native 64-bit Windows.

Which is better Cygwin or WSL? ›

In my opinion, WSL performs better than Cygwin, but your mileage may vary. The best thing to do is install it and try it out and see how it works for you. Yes, definitely. WSL is more than Cygwin.

Can Cygwin run Linux programs? ›

Cygwin is a way of running Linux programs on Windows, somewhat like what WINE is for Linux. However, Cygwin works in a fundamentally different way, and programs have to be re-compiled to work in it. Nevertheless, it is and has been a fairly popular way of running a lot of Linux programs on Windows.

Can Cygwin run exe? ›

Cygwin follows the Linux rules, where there are no default extensions for executable files. Such files are defined as executable by modifying their attributes using the chmod command, not by their extension. You should not call the files by the same name, as "file" does not invoke "file.exe".

What language does Cygwin use? ›

Cygwin software packages are used in Unix-like operating systems, including GNU command line tools such as cat, diff, grep, and the bash command shell. They also include support for programming languages like C++, Fortran, Perl, Python, and Ruby, and server and client support.

Does Cygwin have valgrind? ›

Valgrind. Valgrind only works on Unix-based systems (e.g., GNU/Linux, FreeBSD, and MacOSX). It does not work on Cygwin because Cygwin emulates UNIX at the library layer, but Valgrind operates at the system call layer and the Windows system calls are significantly different than UNIX system calls.

What is WSL vs MinGW vs Cygwin? ›

MinGW programs run as native Windows programs using undocumented Windows native libraries. WSL binaries don't run under Windows by themselves; they only run in the WSL environment (or possibly native Linux systems). WSL maps Linux kernel calls to Windows kernel calls, whereas Cygwin implements Unix/Posix library calls.

What happened to MinGW? ›

The good news is that MinGW is still available on MinGW - Minimalist GNU for Windows download | SourceForge.net. Note that the maintainer announced on the homepage: This project is in the process of moving to osdn.net/projects/mingw, you can continue to follow us there.

Is MinGW same as G ++? ›

Mingw executables

They also provide other compiler drivers, which in the case of mingw are executables such as g++, c++, g77, etc. These drivers invoke the appropriate compiler programs to compile your source code. Note that g++ and c++ are identical files except for the name difference.

What does MinGW stand for? ›

MinGW means Minimalist GNU for Windows: GNU is a source of open source programming tools (GNU stands for GNU is Not Unix). In this handout you will download the files needed by GNU C++; in the next you will download a version of Eclipse that is already set up to use MinGW.

Does Cygwin have cURL? ›

Starting Cygwin

You can now start using cURL to send HTTP requests. Tip: Don't delete the setup*-exe file. Move it to C:\cygwin64 folder. You can use it at any time in the future to update your Cygwin installation, with new/updated packages for example.

Does Cygwin have Git? ›

Git can be installed in Cygwin along with it. When installing Cygwin it will ask some extra packages, there the Git option can be included. This is the only way to install Git in Cygwin.

Does Cygwin have Sudo? ›

Sudo for Cygwin

It allows you to run applications in elevated user mode from a non-elevated cygwin shell. It is based on nu774's tool and has full terminal support, so you can run interactive applications like vim or a shell through it.

Does Cygwin have SSH? ›

Each of the machines that run a browsechild client are required to run an SSHD daemon. To setup the Cygwin SSHD server you must first complete the initial "SSH Client Setup" steps.

Does Cygwin have vim? ›

Vim is part of the standard Cygwin installation and can run from a Cygwin shell window. The text-based console Vim works fine in Cygwin, but Cygwin's gvim expects an X Window System server to be running and will degrade gracefully into running text-based Vim if started without this server.

Is Cygwin a terminal emulator? ›

mintty is a free and open source terminal emulator for Cygwin, the Unix-like environment for Windows. It features a native Windows user interface and does not require a display server; its terminal emulation is aimed to be compatible with xterm.
...
mintty.
TypeTerminal emulator
LicenseGPL-3.0-or-later
Websitemintty.github.io
11 more rows

Is Cygwin a vmware? ›

As far as I am concerned, Cygwin is a different concept. Unlike virtual machine it provides an DLL which emulates an Linux environment/layer, which can run and build linux program on a windows machine.

Is MinGW same for C and C++? ›

The MinGW compiler is a well known and widely used software for installing GCC and G++ compilers for the C and C++ programming languages.

Does Cygwin have Perl? ›

NOTE: There are pre-built Perl packages available for Cygwin and a version of Perl is provided in the normal Cygwin install. If you do not need to customize the configuration, consider using one of those packages.

Can Cygwin run Docker? ›

You could copy the export portion of this and put it your . bash_profile file and then you could talk to your docker machine and run docker images from cygwin.

Does Cygwin have OpenSSL? ›

Cygwin offers a simple way to install a large collection of free and open-source software (including OpenSSL) on Windows.

What is Vim Cygwin? ›

description: Vim (Vi IMproved) is an almost compatible version of the UNIX editor vi. Almost every possible command can be performed using only ASCII characters. Many new features have been added: multilevel undo, command line history, file name completion, block operations, and editing of binary data.

Should I use git GUI or git bash? ›

Git Bash emulates a bash environment on windows. It lets you use all git features in command line plus most of standard unix commands. Useful if you are used to Linux and want to keep the same habits. Git GUI is a Graphical User Interface letting you use Git without touching command line.

What is Cygwin vs GnuWin32? ›

Cygwin is for people who want to use UNIX on their Windows OS. MSYS is for people who want to build Windows programs using the GNU/UNIX build tools. GnuWin32 is a port of individual GNU programs and libraries to Windows. Text files, particularly line endings.

What is bash in Cygwin? ›

description: Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003. 2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use.

Is Cygwin any good? ›

You have the advantage of being able to run linux commands. It also useful if you want to set up an ssh connection from another box to a windows box. Cygwin's install also has a good set up program that allows you to install loads of useful tools from networking to programming, visual, etc.

Is Cygwin still used? ›

Cygwin version

The most recent version of the Cygwin DLL is 3.4.6. The Cygwin DLL currently works with all recent, commercially released x86_64 versions of Windows, starting with Windows 7. For more information see the FAQ.

What is the difference between Cygwin and Ubuntu? ›

Cygwin is an open source tool with 27 GitHub stars and 6 GitHub forks. Here's a link to Cygwin's open source repository on GitHub. Ubuntu is much more faster over Windows and helps to get software and other utilities easier and within a short span of time compared to Windows.

Can I run python in Cygwin? ›

Installing Python for Cygwin. Packages are installed for Cygwin using its setup utility, setup-x86_64.exe for 64-bit (source: http://cygwin.com/install.html). By default, the Cygwin setup utility asks for elevated Administrative permissions. These are not necessary to install and update the base Cygwin environment.

Can Cygwin run Linux commands? ›

Cygwin is a collection of tools that provide a Linux Operating System's terminal look, feel, and some of its basic functionality for users of Windows OS who want to have a go over the basic commands of Linux without worrying about installing a Linux OS.

Is Cygwin better than WSL? ›

No. Cygwin provides a POSIX compatibility layer so that UNIX based programs can be compiled on Windows as native Windows applications. WSL is a lightweight Hyper-V container for running native Linux BINARIES, and it is only able to run some - not all of them.

Videos

1. Easy Cygwin installation guide
(Abhinand Valasseri)
2. Fixing Slow Cygwing Tab Completion
(whiteboardcoder)
3. SSH running slow on cygwin
(Roel Van de Paar)
4. X10 Tutorial in Beijing by Dave Grove
(MichaelJamesHind)
5. WSL2 Sucks in Ways People Ignore. Use Git-Bash Instead [20210324163411]
(rwxrob)
6. Track 106 High Performance Fuzzing Richard Johnson
(Adrian Crenshaw)
Top Articles
Latest Posts
Article information

Author: Kareem Mueller DO

Last Updated: 03/15/2023

Views: 6452

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Kareem Mueller DO

Birthday: 1997-01-04

Address: Apt. 156 12935 Runolfsdottir Mission, Greenfort, MN 74384-6749

Phone: +16704982844747

Job: Corporate Administration Planner

Hobby: Mountain biking, Jewelry making, Stone skipping, Lacemaking, Knife making, Scrapbooking, Letterboxing

Introduction: My name is Kareem Mueller DO, I am a vivacious, super, thoughtful, excited, handsome, beautiful, combative person who loves writing and wants to share my knowledge and understanding with you.