---
type: "article"
title: "/proc/thread-self"
newsletter: "Jordi Villar"
newsletter_handle: "jordivillarcom"
newsletter_url: "https://usecommune.com/n/jordivillarcom"
author: "Jordi Villar (@jordi)"
published: "2024-06-13T13:19:48.108Z"
canonical_url: "https://usecommune.com/n/jordivillarcom/a/proc-thread-self"
markdown_url: "https://usecommune.com/n/jordivillarcom/a/proc-thread-self.md"
chat_url: "https://usecommune.com/n/jordivillarcom/a/proc-thread-self/chat"
source_url: "https://jordivillar.com/notes/proc/"
body_source: "imported"
likes: 0
replies: 0
body_words: 248
---

# /proc/thread-self

Read full article in your browser [here](https://jordivillar.com/notes/proc/)

# /proc/thread-self

I’ve never invested much time in understanding how operating systems work. It has never been on my interests list, nor have I considered it useful knowledge for my career. What can I say? We all make bad decisions in our lives.

Over the last two years, I have invested a lot of time in understanding how some things work in Linux. Those are the consequences (or benefits?) of working with a complex and low-level system like a database.

This week, I was working on tracking data that was read from the page cache. While debugging some ClickHouse metrics directly collected from the Kernel, I discovered the `/proc/thread-self` directory[1](#user-content-fn-1).

> /proc/thread-self
>
> When a thread accesses this magic symbolic link, it resolves to the process’s own /proc/self/task/\[tid\] directory.

So `/proc/thread-self` points to the `proc` folder for the current thread. In those folders, you can find a lot of helpful information. In my case, I was interested in `/proc/thread-self/io` [2](#user-content-fn-2), where you have IO statistics.

I was focused on investigating whether the Kernel reported bytes read from S3 inside `rchar`. I shared more information in [this PR](https://github.com/ClickHouse/ClickHouse/pull/63276) in ClickHouse repository. Despite the PR being closed, the examples I shared there still hold valuable insights and a reproducer that can contribute to the collective understanding of the system.

## Footnotes

1. There is also a `/proc/self` for the current process. This is something I didn’t know either. [↩](#user-content-fnref-1)
2. [https://docs.kernel.org/filesystems/proc.html#proc-pid-io-display-the-io-accounting-fields](https://docs.kernel.org/filesystems/proc.html#proc-pid-io-display-the-io-accounting-fields) [↩](#user-content-fnref-2)

***

## Discussion

No replies yet.
