Skip to content

Commit 79d1fbe

Browse files
committed
[add] use yarn instead of npm
1 parent 8f71195 commit 79d1fbe

13 files changed

+10070
-11481
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
author: Benjamin Gallois
3+
authorTitle: FastTrack creator
4+
authorURL: https://github.com/bgallois
5+
authorImageURL: https://avatars0.githubusercontent.com/u/23381534?s=400&u=d95b3af191c247daa425285a0b1847e2326ca7dc&v=4
6+
title: Performance comparison between Linux and Windows
7+
---
8+
```
9+
Copyright (C) FastTrack.
10+
Permission is granted to copy, distribute and/or modify this document. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
```
12+
13+
14+
## FastTrack performance comparison between Linux and Windows
15+
16+
FastTrack is a multi-platform application available for Linux, macOS, and Windows. In this post, we will compare the performance of the Linux and Windows versions. We will see that the performance depends a lot on how OpenCV was built and how to build it for performance.
17+
18+
### The setup
19+
20+
The benchmark will be performed using FastTrack version 6.1.1 on a computer with an Intel(R) Core(TM) i7-8565U and 16Go of RAM.
21+
The Linux version was compiled using the GCC compiler with the default release flag of Qt. We used two Windows compilers: MSVC 2019 used for the FastTrack stable release, and MinGW_64 (GCC for Windows. MinGW_64 is not used for binary releases because it lacks the QtWebEngine package but a lighter version of FastTrack can be compiled using the NO_WEB compilation flag).
22+
We use OpenCV 4.5.5 and Qt 6.2.2 to perform the benchmark. We chose the test dataset of FastTrack ZFJ_001 with the parameters included with it and the PAR_001 from the two-dimensional dataset.
23+
24+
### Results
25+
26+
The results of the benchmark are displayed in Figure.1 for ZFJ_001 and Figure.2 for PAR_001. We see that the tracking is significantly slower on Windows than on Linux and that the MinGW_64 compiler yield better performance than MSVC2019.
27+
28+
| ![alt text](./img/benchmark_zfj.png) |
29+
|:--:|
30+
| Figure 1. Benchmark for ZFJ_001. |
31+
32+
33+
| ![alt text](./img/benchmark_par.png) |
34+
|:--:|
35+
| Figure 2. Benchmark for PAR_001. |
36+
37+
These results can be explained by several factors. First, compiler optimizations are not the same and it seems that out-of-the-box Qt and OpenCV are generally faster with GCC. Another point is that FastTrack writes heavily on the disk using both the SQLite database and plain text files. I/O performance varies widely depending on operating system and hardware and is generally better on Linux.
38+
39+
In our case, we can pinpoint a large part of the performance difference to the core operations of the tracking (object detection and ellipse computation) powered by OpenCV that are significantly slower on Windows.
40+
41+
### What we can do
42+
43+
Performance can be improved by tweaking compiler optimization flags and compiling OpenCV using system-specific optimizations if available.
44+
45+
Figure.3 presents the performance for the pre-built OpenCV library and the optimized version compiled with MSVC2019. Optimized OpenCV was compiled with TBB, OpenMP, and IPP enabled and is 1.7 times faster than the pre-built version but still 1.6 times slower than the Linux version.
46+
47+
| ![alt text](./img/benchmark_msvc.png) |
48+
|:--:|
49+
| Figure 3. Pre-built vs omptimized OpenCV library (PAR_001). |
50+
51+
On Linux, OpenCV is compilated as packaged by the Linux distribution. For example, [ArchLinux](https://github.com/archlinux/svntogit-packages/blob/packages/opencv/trunk/PKGBUILD) and [Ubuntu](https://launchpadlibrarian.net/573124241/buildlog_ubuntu-jammy-amd64.opencv_4.5.4+dfsg-9ubuntu2_BUILDING.txt.gz) are not packaged with the same flags enabled and there is still room for performance improvement. In Figure.4, we compare the performance of the AppImage packaged on Ubuntu with the ArchLinux version available on AUR. We see that the native package is slightly faster than the AppImage but still performing very well.
52+
53+
| ![alt text](./img/benchmark_linux.png) |
54+
|:--:|
55+
| Figure 4. AppImage vs Arch Linux package from AUR (PAR_001). |
56+
57+
### Final words
58+
59+
Pre-built binaries of FastTrack will most likely perform better on Linux than on Windows for equivalent hardware. Most Linux distributions will provide a pre-built OpenCV library well optimized whereas FastTrack for Windows is built against the pre-built OpenCV library for MSVC.
60+
A custom compilation of OpenCV and FastTrack with platform-specific optimizations will provide maximum performance in any case.
61+
Ultimately, switching to MinGW_64 will be the only way to start to fill the performance gap on Windows. In the next post, we will see how to compile OpenCV and (light) FastTrack with MinGW_64 and if it is possible to have performance as best as the standard Linux version.
62+
63+
### Reference
64+
65+
[OpenCV compilation flags](https://docs.opencv.org/4.5.5/db/d05/tutorial_config_reference.html)

FastTrack/blog/2022-02-02-MinGW.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
author: Benjamin Gallois
3+
authorTitle: FastTrack creator
4+
authorURL: https://github.com/bgallois
5+
authorImageURL: https://avatars0.githubusercontent.com/u/23381534?s=400&u=d95b3af191c247daa425285a0b1847e2326ca7dc&v=4
6+
title: MinGW_w64 FastTrack version
7+
---
8+
9+
Since version 6.2.0, FastTrack has been compilated using MinGW_w64 instead of MSVC2019.
10+
[MinGW_w64](https://www.mingw-w64.org/) is a fork of the MinGW project that provides the GCC compiler for Windows. With a "better-conforming and faster math support compared to VisualStudio's" and a pthreads library, [this compiler yields better performance](https://www.fasttrack.sh/blog/2022/01/14/Performance) for the OpenCV library and thus for FastTrack.
11+
12+
Compiling FastTrack using MinGW_w64 provides several improvements. First, it provides the [getopt.h](https://www.gnu.org/software/gnulib/manual/html_node/getopt_002eh.html) header necessary to the FastTrack-Cli. From version 6.2.0, the command line interface of FastTrack is available natively on Windows. Secondly, OpenCV compiled using [MinGW_w64 is more performant than with MSVC](https://www.fasttrack.sh/blog/2022/01/14/Performance/#results) and Qt seems more responsive. Finally, the bundle (executable plus DLLs) is lighter than its MSVC counterpart (42,7 MB vs 62.8 MB).
13+
14+
Compiling FastTrack using MinGW_w64 comes with some challenges. The main dependency of FastTrack is OpenCV and it does not provide pre-built binaries for MinGW_w64, therefore, we need to compile OpenCV from sources. This compilation is done one time in [this](https://github.com/FastTrackOrg/Windows_MinGW_64_OpenCV) GitHub repository and files are downloaded at compile time to save processing energy.
15+
Conveniently, Qt provides pre-built binaries and the whole [MinGW_w64 toolchains in its archives](https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/tools_mingw90/). Installing Qt and MinWG_w64 can be done very easily without external sources. The windeployqt Qt tool takes care of the DLLs (Qt and MinGW_x64) needed at runtime and the resulting bundle is very light.
16+
MinGW_w64 version of Qt does not provide the QtWebEngine, thus, the in software documentation is not available anymore.
17+
18+
To conclude, MinGW_w64 version of FastTrack has better performance, a lighter footprint with only one drawback: recompile OpenCV when newer versions will be available. For developers, the environment is easier to set up with only three commands necessary.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
author: Benjamin Gallois
3+
authorTitle: FastTrack creator
4+
authorURL: https://github.com/bgallois
5+
authorImageURL: https://avatars0.githubusercontent.com/u/23381534?s=400&u=d95b3af191c247daa425285a0b1847e2326ca7dc&v=4
6+
title: Tracking performance across FastTrack releases
7+
---
8+
9+
In this post, we will use [Hyperfine](https://github.com/sharkdp/hyperfine) to compare the performance of several versions of FastTrack to see how FastTrack performance has improved or degraded over time.
10+
11+
## Methods
12+
13+
We will automate the benchmark with a python script that will:
14+
1. Select the FastTrack version.
15+
2. Compile FastTrack.
16+
3. Run hyperfine.
17+
18+
```python
19+
1 import os
20+
2
21+
3 def compile(versions, cmd):
22+
4 for i in versions:
23+
5 os.system("make distclean -s")
24+
6 os.system("git checkout -f v{}".format(i))
25+
7 if i[0] == "6": # Choose qt version
26+
8 os.system("qmake6 CONFIG+=release src/FastTrack-Cli.pro")
27+
9 elif i[0] == "5":
28+
10 os.system("qmake CONFIG+=release src/FastTrack-Cli.pro")
29+
11 os.system("make")
30+
12 os.system("make clean")
31+
13 os.system("mv build_cli {}".format(i))
32+
14 cmd += "\'{}/fasttrack-cli --path test/dataSet/images/frame_000001.pgm --cfg test/dataSet/images/Groundtruth/Tracking_Result/cfg.toml\' ".format(i)
33+
14 return cmd
34+
15
35+
16 versions = ["6.2.4", "6.2.3", "6.2.1", "6.2.0", "6.1.2", "6.0.0", "5.3.5", "5.2.3"]
36+
17 cmd = compile(versions, "hyperfine -w 20 -m 100 ")
37+
18 os.system("git checkout -f master")
38+
19 os.system(cmd + "--export-markdown benchmark.md")
39+
```
40+
41+
## Results
42+
43+
The results of the benchmark are displayed in the graph below with horizontally the version of FastTrack (left is the more recent), and vertically the mean time to perform 50 tracking analyses of the test dataset (less time is better). We can see two interesting breakpoints of performance.
44+
45+
![](img/version_bench.svg)
46+
47+
The fastest version is by far the 6.2.4 (latest at the time of writing). This is due to the optimized rewriting of a core function of the tracking. This function computes the object's direction and is used ~nObject\*nImage times. A slight gain can greatly impact the overall performance.
48+
49+
We see a degradation of performance between versions 6.0.0 and 6.1.2. This degradation was introduced when FastTrack started to use the SQLite database as a backend. In version 6.0.0 and prior, tracking data were directly saved as a plain text file. This was fine for the tracking but loading the data for reviewing was consuming a lot of RAM and was very slow. Version 6.1.0 and later introduced an SQLite database to store the tracking data but still keep the plain text file for compatibility. This development choice increased performance for the tracking review but slightly degraded the tracking time. Inserting data in the database is faster but generating and writing the text file needed to keep the compatibility introduces a small time overhead degrading the tracking performance. Overall, tracking plus reviewing was faster.
50+
51+
Less significantly, we see a slight increase in performance between versions 6.1.2 and 6.2.3 caused by small optimizations in the code. We see also that migrating from Qt5 (FastTrack 5.3.5 and prior) to Qt6 (FastTrack 5.3.5 and later) doesn't change the performance.
52+
53+
## Conclusion
54+
55+
A tracking analysis is the repetition of a few functions on a lot of images. Marginal gains on these functions can cumulate to a large increase in tracking speed. We work to increase the overall performance with each release of FastTrack and there is still gain to be found.
56+

FastTrack/blog/2022-03-18-OpenCL.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
author: Benjamin Gallois
3+
authorTitle: FastTrack creator
4+
authorURL: https://github.com/bgallois
5+
authorImageURL: https://avatars0.githubusercontent.com/u/23381534?s=400&u=d95b3af191c247daa425285a0b1847e2326ca7dc&v=4
6+
title: Closing the performance gap on Windows
7+
---
8+
9+
As mentioned in previous posts, FastTrack on Windows is slow compared to the Linux and macOS versions. Since version 6.2.5, the tracking speed dramatically improved on Windows.
10+
11+
## Problem
12+
13+
One user reported a bug involving a [memory leak on Windows]( https://github.com/FastTrackOrg/FastTrack/issues/48) for a specific video format. We investigated this bug and were able to find that it came from the OpenCL library. OpenCL was unable to share a buffer leading to multiple deep copies of images and ultimately a RAM overload. This bug was restricted to the tracking class and reproducible only with a specific video. A hotfix was deployed by deactivating OpenCL.
14+
As usual, we run the performance benchmark and no changes were seen... except for Windows (see graph). Surprisingly, deactivating OpenCL increases tracking performance by 52% on Windows.
15+
16+
![](img/opencl.svg)
17+
18+
## OpenCL
19+
20+
"[OpenCL](https://www.khronos.org/opencl/) (Open Computing Language) is a framework for writing programs that execute across heterogeneous platforms" CPUs, GPUs, DSPs, and FPGAs. [OpenCV uses OpenCL](https://opencv.org/opencl/) by the mean of the transparent API that adds hardware acceleration with a minimal change in the code (use UMat instead of Mat to store images). Using hardware acceleration can increase performance when expensive operations are applied to the image, otherwise, the overhead time to moving the data to the GPU dominate.
21+
There is numerous posts ([1](https://discuss.pixls.us/t/darktable-3-4-3-5-opencl-slow-on-windows-10/25309/19),[2](https://community.khronos.org/t/opencl-on-windows-much-slower-than-on-mac/2100)) on the internet that talk about performance issues with OpenCL. Only one thing is certain, deactivating OpenCL in FastTrack leads to consistent performance across platforms.
17.9 KB
Loading

FastTrack/blog/img/benchmark_msvc.png

20.1 KB
Loading

FastTrack/blog/img/benchmark_par.png

23.4 KB
Loading

FastTrack/blog/img/benchmark_zfj.png

23.3 KB
Loading

0 commit comments

Comments
 (0)