# Lsr: ls but with io\_uring

**URL:** <https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990>\
**Category:** Showcase\
**Created:** [May 6, 2025, 5:30pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990 "2025-05-06T17:30:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rockorager](https://ziggit.dev/user_avatar/ziggit.dev/rockorager/32/502_2.png) [@rockorager](https://ziggit.dev/u/rockorager)\
**Post date:** [May 6, 2025, 5:30pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/1 "2025-05-06T17:30:12Z")

</div>

I applied some of my io\_uring learnings to writing an implementation of `ls(1)` with the goal of minimizing syscalls. The repo is [here](https://tangled.sh/@rockorager.dev/lsr), and I did a little writeup [here](https://rockorager.dev/log/lsr-ls-but-with-io-uring/). I was mostly interested in the syscall reduction I could get in a realistic program which relies very little on traditional IO (reads, writes, etc). Nearly all the IO for something like `ls` are syscalls: `statx` to be specific. I benchmarked syscalls and time of several popular options, syscall results are below.

| Program | n=10 | n=100 | n=1,000 | n=10,000 |
| --- | --- | --- | --- | --- |
| lsr -al | 20 | 28 | 105 | 848 |
| ls -al | 405 | 675 | 3,377 | 30,396 |
| eza -al | 319 | 411 | 1,320 | 10,364 |
| lsd -al | 508 | 1,408 | 10,423 | 100,512 |
| uutils ls -al | 445 | 986 | 6,397 | 10,005 |

and here’s a bonus screenshot! I added some fancy icons to be like the other big guys (eza and lsd):

 ![screenshot](https://ziggit.dev/uploads/default/original/2X/3/38d8f13ded1af9b5f4d7767724c57b9948441811.webp)

---

<div class="post-metadata">

**Author:** ![motiejus](https://ziggit.dev/user_avatar/ziggit.dev/motiejus/32/3681_2.png) [@motiejus](https://ziggit.dev/u/motiejus)\
**Post date:** [May 10, 2025, 7:10am UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/2 "2025-05-10T07:10:34Z")

</div>

Nice! Curious, did you happen to measure latency differences?

Ah, I see it’s in the write-up. I think you can put the latency table here too, because in the end, that’s all that matters (as long as the ouput is correct) for ls. 🙂

---

<div class="post-metadata">

**Author:** ![rockorager](https://ziggit.dev/user_avatar/ziggit.dev/rockorager/32/502_2.png) [@rockorager](https://ziggit.dev/u/rockorager)\
**Post date:** [May 10, 2025, 12:13pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/3 "2025-05-10T12:13:05Z")

</div>

Here’s the table!

| Program | n=10 | n=100 | n=1,000 | n=10,000 |
| --- | --- | --- | --- | --- |
| lsr -al | 372.6 µs | 634.3 µs | 2.7 ms | 22.1 ms |
| ls -al | 1.4 ms | 1.7 ms | 4.7 ms | 38.0 ms |
| eza -al | 2.9 ms | 3.3 ms | 6.6 ms | 40.2 ms |
| lsd -al | 2.1 ms | 3.5 ms | 17.0 ms | 153.4 ms |
| uutils ls -al | 2.9 ms | 3.6 ms | 11.3 ms | 89.6 ms |

---

<div class="post-metadata">

**Author:** ![Validark](https://ziggit.dev/user_avatar/ziggit.dev/validark/32/646_2.png) [@Validark](https://ziggit.dev/u/Validark)\
**Post date:** [May 10, 2025, 2:01pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/4 "2025-05-10T14:01:55Z")

</div>

This is BLAZINGLY FAST!!

---

<div class="post-metadata">

**Author:** ![rockorager](https://ziggit.dev/user_avatar/ziggit.dev/rockorager/32/502_2.png) [@rockorager](https://ziggit.dev/u/rockorager)\
**Post date:** [May 10, 2025, 2:11pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/5 "2025-05-10T14:11:38Z")

</div>

So fast it doesn’t even need emojis!

---

<div class="post-metadata">

**Author:** ![cancername](https://ziggit.dev/user_avatar/ziggit.dev/cancername/32/8752_2.png) [@cancername](https://ziggit.dev/u/cancername)\
**Post date:** [May 11, 2025, 1:36pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/6 "2025-05-11T13:36:23Z")

</div>

🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀

---

<div class="post-metadata">

**Author:** ![chrboesch](https://ziggit.dev/user_avatar/ziggit.dev/chrboesch/32/438_2.png) [@chrboesch](https://ziggit.dev/u/chrboesch)\
**Post date:** [May 11, 2025, 4:26pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/7 "2025-05-11T16:26:09Z")

</div>

Really cool, with alias my new ‘l’, ‘ll’. 😀

---

<div class="post-metadata">

**Author:** ![Southporter](https://ziggit.dev/user_avatar/ziggit.dev/southporter/32/2500_2.png) [@Southporter](https://ziggit.dev/u/Southporter)\
**Post date:** [May 16, 2025, 7:35pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/8 "2025-05-16T19:35:08Z")

</div>

I’ve been running into an intermittent issue. Occasionally I will get an `error: SystemResources` when I run it. Eventually it corrects, but if I get it in one shell session, then that session is always returning that error.

---

<div class="post-metadata">

**Author:** ![rockorager](https://ziggit.dev/user_avatar/ziggit.dev/rockorager/32/502_2.png) [@rockorager](https://ziggit.dev/u/rockorager)\
**Post date:** [May 16, 2025, 7:40pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/9 "2025-05-16T19:40:21Z")

</div>

What kernel version do you have?

---

<div class="post-metadata">

**Author:** ![Southporter](https://ziggit.dev/user_avatar/ziggit.dev/southporter/32/2500_2.png) [@Southporter](https://ziggit.dev/u/Southporter)\
**Post date:** [May 16, 2025, 7:42pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/10 "2025-05-16T19:42:35Z")

</div>

```sh
$ uname -srm
Linux 6.14.5-300.fc42.x86_64 x86_64

```

Default kernel for Fedora 42

---

<div class="post-metadata">

**Author:** ![Southporter](https://ziggit.dev/user_avatar/ziggit.dev/southporter/32/2500_2.png) [@Southporter](https://ziggit.dev/u/Southporter)\
**Post date:** [May 16, 2025, 7:43pm UTC](https://ziggit.dev/t/lsr-ls-but-with-io-uring/9990/11 "2025-05-16T19:43:53Z")

</div>

Looks like it might be due to memory pressure (reported as 90% memory usage)? I killed a few processes and it’s working again.
