Fixing slow HDD Windows 10

This article is dedicated to all die hard hdd users.

Original (Mae Mu)

1.5 years of using HP Pavilion laptop HDD dualboot (Windows 10) and SSD (Ubuntu) I began to notice a very long loading of applications, a common interface unresponsive, hangs on simple operations in Windows 10. The problem has been minimized to the extent that the use of a laptop has become possible again. Next, I will describe the action that I have taken to correct the problem.


For the study to be eliminated mystification of any order, first determine the root cause damage hard drives. What can go wrong when dealing with a hard drive? Problems can occur in the physical layer electronics and logical data software.
By electronics problems include such things as PC / Laptop power problems; Wear a hard disk component failure in the circuits and chips internal drive components, software, firmware error, the consequences of hit shock / disc falls, or similar problems with other devices that affect its operation.
Hard disk wear and tear is considered critical time of occurrence of the amount of such a large number of bad sectors (bad block) in which the further operation of the disc is not possible. These blocks are blocked by the hard drive firmware, the data is transferred to other sectors automatically and should not affect the disk performance to a certain critical point.
The problems include programming logic error in the file system due to incorrect operation of the application, a user action: off on the hot device, the completion of the recording process without properly stopping the application, errors in drivers, operating system services.
Not having a specialized electronic diagnostic tools, we only need to check the correct software level, already in the process of electronics may show problems that are usually eliminated by block repair (replacement of components / chips); Next, consider the software methods of diagnosis using diagnostic tools. It is worth noting that all utilities must be run on a system with the highest priority, as other applications may interfere with measurements of performance, lock the drive read / write, which will lead to incorrect results of diagnosis.


S.M.A.R.T. monitoring service for storage devices -. HDD, SDD, eMMC etc. It allows to evaluate the wear devices, view the number of bad blocks, based on the data to take further action. View SMART can be used in various applications for working with disks, I prefer to use tools from the manufacturer. For your hard drive Seagate SeaTools utility I used, output status as a GOOD for him, that is, drive firmware finds that all is well.

Manufacturer Tools

Disc producer utility provides tests to check his work. SeaTools has several types of tests, you can use them all to localize the problem. Quick and simple tests can not detect any problems, so I prefer for many tests. In my case only on the Long Test errors were found.


To check the correctness of the reading, finding slow or dead blocks, I wrote an application slowride. It works on a very simple principle – opens a handle to a block device, with user-defined settings produces read data of the entire device, with measurements of time, slow output blocks. The program stops at the first error, would then have to go to more serious utility to remove the data as a simple data disc methods is not possible to read.
In my case, reading the entire disk it was carried out properly, with little drawdown speed – 90MB / s (5400rpm) in one second, in some areas of the disc. From which one could conclude that I am dealing with a software problem.

Acoustic Analysis

This method does not apply to software methods of diagnosis, however, it is important enough to fix the problem. For example, when the operating part supply unit, a hard disk may Freeze / hang emitting a loud click.
In my case, when dealing with the disc in Windows 10, I heard familiar to all owners of HDD, loud buzz run around the drive head when you try to do anything in the operating system, but the sound was almost constant, it made me think about too much disk fragmentation, disk reloading background service.


Electronics problems during software diagnostics have not been found, chunked read the entire disc was completed correctly, but showed SeaTools errors Long Test verification.

Manufacturer Tools

Manufacturer disk diagnostic software in addition provides the error correction procedure. The SeaTools is responsible for this Fix All button, then agreed to accept the potential loss of data, it will start the process of correction. I did my case, this fix? No, the drive continued to work as loudly and slowly, but the Long Test error is no longer shown.


CHKSDK is Microsoft’s tool to eliminate programming errors for Windows file systems. Over time, these errors accumulate on the disc and can greatly interfere with the work, including the result in the inability to read / write any data at all. Instructions on the use of tools you can find on the Microsoft site, I recommend to use all possible flags for error correction (at the time of this writing, is / r / b / f); Need to run a check with the administrator via the Windows terminal (cmd), for the system partition it will be held on the system boots, it may take a very long time, in my case took 12 hours.
I did this fix in my case? Not.

Disk Defragmenter

Working with the disk data blocks is carried out, large files typically stored in multiple blocks / fragments. Over time, a lot of deleted files create empty blocks that are not there, because of this when writing files to fill these voids, and disk head has to physically travel long distances. This problem is called fragmentation, and with her face only a user’s hard drive. At the time several fixes fragmentation of my hard drive was 41%, visually it looks like this:

That is bad. See fragmentation, to defragment, you can use Defragger utility or built defragmenter. You can also turn the service on “Optimize drives” in Windows 10, put down a defragmentation schedule in the control panel.Defragment only need the HDD, discs include undesirable for SSDAs this will lead to accelerated wear of the disc, probably for this reason that defragmentation is disabled by default.

Also known is an alternative embodiment of defragmentation – transferring data to another disk, the formatting of the disk, and copying the data back. In this case, data will be recorded on a completely empty sector, while maintaining the correct logical structure to run the system. This reset option is fraught with problems potentially critical metadata that may not move during normal copying.

Disable Services

With utility Mark Russinovich Process Monitor you can track the processes that load the hard drive their business, just include the column IO Write / Read. After the study of this column, I disabled the service Xbox Game Bar, a well-known service background acceleration Superfetch programs under the new name SysMain, through the panel of the control panel services. Superfetch should constantly analyze the application used by the user, and accelerate their launch using caching in memory, in my case it led to a background downloading the entire disc and the inability to work.

Clean the Drive

I also removed the old app, unwanted files, thus freeing up the sector to correct the fragmentation, simplifying the job of the operating system, reducing the number of useless, heavy services and programs.


What helped the most? A marked difference in performance was achieved after a disk defrag, spontaneous hang persists by disabling services Xbox and Superfetch. It would not have these problems if I used the SSD? Problems with slow performance when fragmentation would definitely would not have been a problem with the services had to remove in any case, and software errors do not depend on the type of drive. In the near future I plan to complete the migration to the SSD, but for now, “Long live the pancakes, pancakes forever!”



Slowride Storage Benchmark Utility

Slowride – utility benchmark utility for block devices for POSIX operation systems with root access to /dev/sd*. You can check blocks read speed in terminal, set threshold for operations to diagnose problems with block device.
Command to perform 100mb blocks read of entire device with 2 seconds threshold:

sudo ./slowride /dev/sda 100 2000

Source Code


Space Jaguar 3D Action RPG

For a long time I have not announced new projects) The next project I’m starting to work on is a 3D action RPG called Space Jaguar. A story in a sci-fi setting about a tough guy named Jag and his difficult adventure in search of a missing father. There will be 3D graphics on the Flame Steel Engine (or possibly on any other popular), using the achievements of past projects (Death Mask, Cube Art Project), a comedy story with many references, arcade battles and bosses. I’m not ready to talk about release date of the full version, I plan to release the game in parts.

Project Repository:


Backend server C++ FCGI

Quick note about how I wrote the backend for 3D Cube Art Project editor, the server needs to store and display the user work from web version, giving them a short URL on the save button. At first I wanted to use the Swift/PHP/Ruby/JS or some similar modern language for the backend, but looking at the characteristics of my VPS was decided to write a server on the C/C ++.
First you need to install on the server and libfcgi fcgi support module for your web server, for example Ubuntu and Apache:

sudo apt install libfcgi libapache2-mod-fcgid

Next, configure the module in the config file:

FcgidMaxProcessesPerClass – the maximum number of processes in the class, I put 1 process because it does not count on a big load.
AddHandler fcgid-script .fcgi – file extension which should start fcgi module.
Add in the config directory which will run cgi applications:

Next, write an application to the C/C ++ with fcgi support, collect it, and it is copied to the folder /var/www/html/cgi-bin.
Examples code and build script:
Then you need to restart your web server:

systemctl restart apache2

Next, put down the necessary rights for the execution of cgi-bin folder via chmod.
After that, your cgi program should work through the browser to the link, for example Cube Art Project Server:
If something does not work, then see the web server logs, or connect the debugger to a running process, the debugging process should not differ from the usual process of debugging the client application.


Source Code


Cube Art Project

Cube Art Project – cubes based 3D editor.
You can build, remove cubes, move around scene by WSAD + E controls, use mouse wheel to change cube color. Only 16 colors are supported, but there will be enhancements in future.

Web version

Web version with save feature



Linux (x86-64)

(Proof of concept, usb-mouse required)

Source Code

Technologies: SDL, Emscripten, MinGW, Glew, GLM, Cpp-JSON


Porting C++ SDL Application To Android

In this article I will describe his experience porting 3D editor prototype Cube Art Project on Android.
First, look at the result, the emulator running the editor with 3D cursor red cube:

To build a successful have to do the following:

  1. Install the latest Android SDK and NDK (National Palace of Culture version of the fresher the better).
  2. Download the code SDL2, take out a template to build an application for android.
  3. Add SDL Image, SDL Mixer for assembly.
  4. Add the library of my game engine and toolkit, their dependencies (GLM, JSON for Modern C++)
  5. Adapt the assembly files for Gradle.
  6. Adapt the C ++ code to be compatible with Android, changes were platform specific components (OpenGL ES, the graphics context initialization)
  7. Assemble and test the project on the emulator.

Project Template

Load the source code SDL, SDL Image, SDL Mixer:
The docs folder contains detailed instructions on working with project android template; copy the directory android-project in a separate folder, make a symlink or copy the SDL folder in android-project / app / jni.
Substitute the correct identifier for avd flag, run the emulator from the Android Sdk directory:

cd ~/Android/Sdk/emulator
./emulator -avd Pixel_2_API_24

Specify the path to the script, pick a project:

rm -rf app/build || true
export ANDROID_HOME=/home/demensdeum/Android/Sdk/
export ANDROID_NDK_HOME=/home/demensdeum/Android/android-ndk-r21-beta2/
./gradlew clean build
./gradlew installDebug

Should meet SDL project template with the code in C from a file



Download the source code archives for SDL_image, SDL_mixer:

Load depending on your project, for example, my shared library:

All of this was discharged into app / jni, each “module” in a separate folder, such as app / jni / FSGL. Next, you have the option to find workers generators and files, I have not found, but maybe there’s a simple solution based on CMake. Click on a link and start to get acquainted with the format of the build files for Android NDK:

You should also read about different APP_STL implementation NDK:

After reviewing create for each “module” file, further example of an assembly file shared library Cube-Art-Project:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

APP_STL := c++_static
APP_CPPFLAGS := -fexceptions
LOCAL_MODULE := CubeArtProject
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/../include $(LOCAL_PATH)/../include/FlameSteelCommonTraits/src/FlameSteelCommonTraits

define walk
  $(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e)))

ALLFILES = $(call walk, $(LOCAL_PATH)/src)
FILE_LIST := $(filter %.cpp, $(ALLFILES))
$(info CubeArtProject source code files list)
$(info $(FILE_LIST))

LOCAL_SHARED_LIBRARIES += FlameSteelCommonTraits
LOCAL_SHARED_LIBRARIES += FlameSteelEngineGameToolkit

LOCAL_LDFLAGS := -static-libstdc++

CMake any experienced user realizes this configuration with the first string formats are very similar in no GLOB_RECURSIVE, so we have to recursively search for source files with walk functions.

Change, with-but to build C++ instead of C code:

APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
APP_STL := c++_static
APP_CPPFLAGS := -fexceptions

Rename YourSourceHere.c -> YourSourceHere.cpp, grep for entry, change the path in the assembly, for example:

app/jni/src/ := YourSourceHere.cpp

Next, try to build the project, if you see an error from the compiler about the absence of Heather, check the correctness of the ways in; if mistakes are kind of linker “undefined reference”, check the correctness of indications of source code files in assemblies ottreysit lists possible by specifying $ (info $ (FILE_LIST)) in file. Do not forget the double-linking mechanism, with modules in LOCAL_SHARED_LIBRARIES key and correct linking through the LD, for example FSGL:


Adaptation And Launching

I had to change some things, for example to remove GLEW of assemblies for iOS and Android, to rename part of OpenGL calls, adding a suffix EOS (glGenVertexArrays -> glGenVertexArraysOES), include macro missing modernistic features debug, the cherry on the cake is the implicit include vulnerability GLES2 Heather indicating macro GL_GLEXT_PROTOTYPES 1 :

#include "SDL_opengles2.h"

Also, a black screen in the first starts with an error type “E / libEGL: validate_display: 255 error 3008 (EGL_BAD_DISPLAY)”, has changed initialize SDL window, GL profile initialization and it worked:

SDL_DisplayMode mode;
int width = mode.w;
int height = mode.h;

window = SDL_CreateWindow(


On the default emulator application is installed with the “Game” icon SDL and name.

I needed to explore the possibility of automatically generating assembly files based on CMake, or else migrate assembly for all platforms on Gradle; CMake but remains the de facto choice for the current development in C++.

Source Code



LazyFoo Productions Website

Perhaps it is worth mentioning the website from which almost always start my projects and new development, it LazyFoo Productions website where you can find answers to the enough hardcore topics: Examples of the use of sophisticated the API, learn how to combine the seemingly incompatible systems (Android / C ++) with a detailed an explanation of the principles of work, working code examples.


Flipped World

To develop a new project Cube Art Project has adopted a methodology for the development of Test Driven Development. In this approach, implemented first test for a particular functional application, and then implemented this functionality. A great advantage in this approach, I believe the final implementation of the interfaces, the most uninitiated in the details of implementation, prior to the development of the functional. With this approach, the test dictates the further implementation, added to all the advantages of contract programming when interfaces are contracts for the implementation.

Cube Art Project – 3D editor in which the user builds the shape of cubes, not so long ago, this genre was very popular. Since this graphic application, I decided to add tests to the validation of screenshots.

For screenshot validation you need to get them from OpenGL context first, it is done with the help of glReadPixels function. Description of function arguments are simple – the starting position, width, height, format (. RGB / RGBA / etc.), a pointer to the output buffer, anyone working with SDL or having experience with data buffers in C will simply substitute the correct arguments. However consider it necessary to describe an interesting feature of the output buffer glReadPixels, the pixels stored therein upwards and in SDL_Surface all basic operations taking place downwards.

That is, the reference by uploading a screenshot from the png file, I could not compare the two buffers in the forehead, as one of them upside down.

To flip the output buffer of OpenGL you need to fill it up taking away the height of the screenshot to coordinate Y. However, cost to take into account that there is a chance to go beyond the buffer limits, if not take the unit to fill the time, which will lead to memory corruption.

Since I’m all over the place trying to use OOP paradigm “programming interfaces”, instead of a direct C-like memory access at the sign, when you try to write data outside of the buffer object I reported it to the method of borders through validation.

Final code method of obtaining screenshots in the style of top-down:

    auto width = params->width;
    auto height = params->height;

    auto colorComponentsCount = 3;
    GLubyte *bytes = (GLubyte *)malloc(colorComponentsCount * width * height);
    glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, bytes);

    auto screenshot = make_shared(width, height);

    for (auto y = 0; y(redColorByte, greenColorByte, blueColorByte, 255);
            screenshot->setColorAtXY(color, x, height - y - 1);



Source Code