{"id":22451857,"url":"https://github.com/isac322/linux_aio","last_synced_at":"2025-08-02T00:32:24.646Z","repository":{"id":50744474,"uuid":"166406192","full_name":"isac322/linux_aio","owner":"isac322","description":"Linux AIO ABI wrapper for python (module)","archived":false,"fork":false,"pushed_at":"2019-01-29T12:06:33.000Z","size":147,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-18T17:09:03.259Z","etag":null,"topics":["abi","aio","api","asynchronous","library","linux","python","python-module","python3","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isac322.png","metadata":{"files":{"readme":"README.kor.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-18T13:05:23.000Z","updated_at":"2023-12-03T02:33:35.000Z","dependencies_parsed_at":"2022-09-10T18:01:56.054Z","dependency_job_id":null,"html_url":"https://github.com/isac322/linux_aio","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Flinux_aio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Flinux_aio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Flinux_aio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Flinux_aio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isac322","download_url":"https://codeload.github.com/isac322/linux_aio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228419605,"owners_count":17916772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abi","aio","api","asynchronous","library","linux","python","python-module","python3","wrapper"],"created_at":"2024-12-06T06:09:00.076Z","updated_at":"2024-12-06T06:09:00.884Z","avatar_url":"https://github.com/isac322.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\\[english\\]](https://github.com/isac322/linux_aio/blob/master/README.md) | **\\[한국어 (korean)\\]**\n\n# linux_aio: Python wrapper for [Linux Kernel AIO](http://lse.sourceforge.net/io/aio.html)\n\n[![](https://img.shields.io/travis/com/isac322/linux_aio.svg?style=flat-square)](https://travis-ci.com/isac322/linux_aio)\n[![](https://img.shields.io/pypi/v/linux_aio.svg?style=flat-square)](https://pypi.org/project/linux-aio/)\n[![](https://img.shields.io/codecov/c/github/isac322/linux_aio.svg?style=flat-square)](https://codecov.io/gh/isac322/linux_aio)\n[![](https://img.shields.io/pypi/implementation/linux_aio.svg?style=flat-square)](https://pypi.org/project/linux-aio/)\n[![](https://img.shields.io/pypi/pyversions/linux_aio.svg?style=flat-square)](https://pypi.org/project/linux-aio/)\n[![](https://img.shields.io/pypi/wheel/linux_aio.svg?style=flat-square)](https://pypi.org/project/linux-aio/)\n[![](https://img.shields.io/pypi/l/linux_aio.svg?style=flat-square)](https://pypi.org/project/linux-aio/)\n[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg?style=flat-square)](https://saythanks.io/to/isac322)\n\n[Linux Kernel AIO](http://lse.sourceforge.net/io/aio.html)를 직접 사용하는 Python High-level wrapper 모듈.\n\nSee [linux_aio_bind](https://pypi.org/project/linux-aio-bind) if you want to handle the API directly at low-level.\n\n## Linux Kernel AIO이란?\n\n[Linux IO Model 정리 표](https://oxnz.github.io/2016/10/13/linux-aio/#io-models)\n\n간단하게 줄이면 [read(2)](http://man7.org/linux/man-pages/man2/read.2.html)나 [write(2)](http://man7.org/linux/man-pages/man2/write.2.html)와 같은 Blocking IO operation들을 Non-blocking하며 비동기적으로 사용하게 해준다.\n\n\n### 관련 문서\n\n- [Linux Asynchronous I/O](https://oxnz.github.io/2016/10/13/linux-aio/)\n- [Linux Kernel AIO Design Notes](http://lse.sourceforge.net/io/aionotes.txt)\n- [How to use the Linux AIO feature](https://github.com/littledan/linux-aio) (in C)\n\n\n### **[POSIX AIO](http://man7.org/linux/man-pages/man7/aio.7.html)와는 다르다**\n\nPOSIX AIO의 API들은 `aio_` 접두사를 가지지만, Linux Kernel AIO는 `io_` 접두사를 가진다.\n\n\n비동기 입출력을 위한 [POSIX AIO API](http://man7.org/linux/man-pages/man7/aio.7.html)가 이미 존재 하지만, Linux는 user-space인 [glibc](https://www.gnu.org/software/libc/manual/html_node/Asynchronous-I_002fO.html)에서 내부적으로는 multi-threading을 사용하도록 구현하였다.\n따라서, 밑에서 실험을 통해 보이겠지만 blocking IO API를 사용하는것 보다 많이 안좋은 성능을 보인다.\n\n\n## 구현 및 구조\n\n### `linux_aio` 패키지\n\n- Linux kernel AIO의 Low-level binding인 [linux_aio_bind](https://pypi.org/project/linux-aio-bind) 패키지를 기반으로 구현\n- [linux_aio_bind](https://pypi.org/project/linux-aio-bind)와 달리 `ctypes`에대한 지식 없이도 사용 가능\n- [test codes](https://github.com/isac322/linux_aio/tree/master/test)의 코드들에서 예제 확인 가능\n\n\n## 예제\n\n[test](https://github.com/isac322/linux_aio/tree/master/test)의 코드들에서 예제 확인 가능\n\n\n## Notes \u0026 Limits\n\n- 당연하게도 Linux에서만 사용 가능하다\n- Wrapper이기 때문에 Linux의 제약을 그대로 가져온다\n\t- Kernel interface로 사용되는 파일에는 사용할 수 없다. (e.g. `cgroup`)\n\t- [때로 Blocking으로 동작하기도 함](https://stackoverflow.com/questions/34572559/asynchronous-io-io-submit-latency-in-ubuntu-linux)\n\t\t- 해당 글 포스팅 이후 개발로 완화된 것들이 있기도 하다\n\t- 아직 개발중인 API이기 때문에, 기능이 추가되기도 한다\n\t- 또한 Linux 버전이 낮은 경우 일부 지원하지 않는 기능이 있기도 하다\n\t\t- [Linux man pages (4.16)](http://man7.org/linux/man-pages/man2/io_submit.2.html)와 그 관련 API 문서 확인 필요\n\n\n## 성능 비교\n\n[Experiment script](https://gist.github.com/isac322/8606f5c464fa390cb88b47354981cdab) (requires python 3.7)\n\n### 실험 환경\n\n- Distribution: Ubuntu Server 16.04.5 LTS\n- Linux: 4.19.0\n- CPU: 2-way Intel(R) Xeon(R) CPU E5-2683 v4 @ 2.10GHz\n- MEM: total 64GB\n- Storage: SK hynix SC300B SATA 512GB\n- Python: 3.7.2 ([Ubuntu ppa](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa))\n\n\n- `1ms` 간격으로 총 `1000`번 읽기를 시도한다\n- 파일 크기는 `1KB` ~ `100KB`로 다양하지만 작다\n- 동시에 읽는 파일의 개수를 늘려가면서 실험한다\n- 고성능 서버에서 실험하였기 때문에, 일반 데스크탑에서 실험할 경우 더 큰 성능차이가 있을 수 있다\n\n\n### 비교 대상\n\n- [aiofiles](https://pypi.org/project/aiofiles/) - Thread pool 사용\n- [aiofile](https://pypi.org/project/aiofile/) - POSIX AIO 사용\n- [libaio](https://pypi.org/project/libaio/) - [libaio](http://lse.sourceforge.net/io/aio.html) 사용\n- [python built-in open()](https://docs.python.org/3/library/functions.html#open)\n\n\n**완벽하게 fair한 비교는 아니다.**\n\n`aiofiles`와 `aiofile`은 [asyncio](https://docs.python.org/ko/3/library/asyncio.html)를 지원하는 라이브러리이며, `open()`는 Blocking이기 때문에 IO를 진행하는 동안 다른 작업을 할 수 없다는 단점이 있고, `libaio`와 `linux_aio`는 Non-blocking이지만 polling을 해야한다.\n\n\n### 결과\n\n**환경마다 다를 수 있으므로 참고용으로만 사용**\n\n#### 수행 시간\n\n- 단위: 초\n\n| 파일 개수 \t|   1   \t|   6   \t|   12  \t|   24  \t|\n|:---------:\t|:-----:\t|:-----:\t|:-----:\t|:-----:\t|\n|  aiofiles \t| 1.681 \t| 3.318 \t| 5.354 \t| 9.768 \t|\n|  aiofile  \t| 1.543 \t| 1.958 \t| 2.493 \t| 3.737 \t|\n|   libaio  \t| 1.311 \t| 1.344 \t| 1.362 \t| 1.423 \t|\n|   open()  \t| 1.252 \t| 1.322 \t| 1.375 \t| 1.481 \t|\n| linux_aio \t| 1.305 \t| 1.327 \t| 1.353 \t| 1.431 \t|\n\n#### 사용 스레드\n\n| 파일 개수 \t|  1  \t|  6  \t|  12 \t|  24 \t|\n|:---------:\t|:---:\t|:---:\t|:---:\t|:---:\t|\n|  aiofiles \t| 321 \t| 321 \t| 321 \t| 321 \t|\n|  aiofile  \t|   3 \t|   8 \t|  15 \t|  26 \t|\n|   libaio  \t|   1 \t|   1 \t|   1 \t|   1 \t|\n|   open()  \t|   1 \t|   1 \t|   1 \t|   1 \t|\n| linux_aio \t|   1 \t|   1 \t|   1 \t|   1 \t|\n\n#### 사용 메모리\n\n- 물리 메모리 (가상 메모리)\n\n| 파일 개수 \t|       1       \t|       6       \t|       12      \t|       24      \t|\n|:---------:\t|:-------------:\t|:-------------:\t|:-------------:\t|:-------------:\t|\n|  aiofiles \t| 21MB (22.6GB) \t| 21MB (22.6GB) \t| 21MB (22.6GB) \t| 21MB (22.6GB) \t|\n|  aiofile  \t|  17MB (258MB) \t|  17MB (654MB) \t| 17MB (1080MB) \t| 18MB (1949MB) \t|\n|   libaio  \t|   17MB (76MB) \t|   17MB (76MB) \t|   17MB (76MB) \t|   17MB (76MB) \t|\n|   open()  \t|   17MB (76MB) \t|   17MB (76MB) \t|   17MB (76MB) \t|   17MB (76MB) \t|\n| linux_aio \t|   17MB (76MB) \t|   17MB (76MB) \t|   17MB (76MB) \t|   17MB (76MB) \t|\n\n#### CPU 점유율\n\n| 파일 개수 \t|   1   \t|   6   \t|   12   \t|   24   \t|\n|:---------:\t|:-----:\t|:-----:\t|:------:\t|:------:\t|\n|  aiofiles \t| 42.8% \t| 85.0% \t| 102.2% \t| 113.2% \t|\n|  aiofile  \t| 31.4% \t| 52.4% \t|  67.0% \t|  84.0% \t|\n|   libaio  \t| 14.0% \t| 16.0% \t|  17.2% \t|  20.6% \t|\n|   open()  \t| 13.4% \t| 17.6% \t|  21.0% \t|  26.2% \t|\n| linux_aio \t| 13.0% \t| 15.0% \t|  16.0% \t|  21.0% \t|","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisac322%2Flinux_aio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisac322%2Flinux_aio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisac322%2Flinux_aio/lists"}