Git Product home page Git Product logo

linuxasynccopying's Introduction

Asynchronous File Copying for Linux

๐Ÿ› Features

  • Asynchronous I/O operations for non-blocking file copying.
  • Customizable block size for copying, set by the user.
  • The number of simultaneous asynchronous operations can be specified by the user.
  • Timing of the copy operation to determine the duration of the process.

โš™๏ธ Requirements

  • A Linux environment with support for POSIX AIO.
  • GCC or another compatible C compiler.
sudo apt update
sudo apt install gcc git -y

๐Ÿ› ๏ธ Compilation and Usage

1. To compile the program, use the following commands:

Clone the repo:
git clone https://github.com/a13xe/LinuxAsyncCopying.git
Navigate to the directory:
cd LinuxAsyncCopying
Compile the executable (choose one):
gcc -o async_copy async_copy_aio_error.c -lrt
gcc -o async_copy async_copy_aio_suspend.c -lrt
Execute the program:
./async_copy

2. The program will prompt you for these inputs (Example):

Screenshot Screenshot

๐Ÿ”– Comparing Performance: aio_suspend vs. aio_error

  • The performance difference between using aio_suspend and active waiting with aio_error can be explained by the differences in waiting mechanisms and processing of asynchronous operations.

  • When you use aio_suspend, the program pauses and waits for a notification from the kernel about the completion of at least one of the asynchronous operations, which can lead to some delay since the program "wakes up" only after receiving such a notification. This means there can be some time between the completion of the operation and the resumption of the program's work during which the CPU is not occupied with processing other copying operations.

  • On the other hand, active waiting with aio_error leads to the program constantly checking the status of each asynchronous operation in a loop. Although this might seem less efficient in terms of CPU usage, such an approach can allow for a quicker response to the completion of operations, especially if the operations finish at different speeds. This can lead to an earlier start of new read or write operations, which, in turn, can speed up the overall copying process.

  • It is also important to consider that the performance of asynchronous I/O can greatly depend on the system characteristics, such as disk performance, system load, block size, and the number of concurrent asynchronous operations. In some cases, active waiting might be more preferable if it allows for a more efficient use of the available I/O bandwidth, despite the higher CPU consumption.

  • Ultimately, the choice between aio_suspend and active waiting with aio_error should be based on the specific performance and resource requirements of your application, as well as the characteristics of the target system. In some cases, it might be useful to conduct your own performance testing to determine the most efficient approach.

  • In my case, when using aio_suspend, a 4 GB file is copied in 16 seconds using an 8 KB block size and 8 operations, whereas using aio_error for active waiting, the same operation takes only 9 seconds

linuxasynccopying's People

Contributors

a13xe avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.