Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The fs.read metric is not produced when we read a file #5

Open
seanvaleo opened this issue Oct 9, 2023 · 0 comments
Open

The fs.read metric is not produced when we read a file #5

seanvaleo opened this issue Oct 9, 2023 · 0 comments

Comments

@seanvaleo
Copy link
Contributor

When we read a file with this test app (calling read or __read_chk), I observed that we do not produce an fs.read metric event. Also, in the fs.close event associated with the file read, file_read_bytes does not change from 0.

#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#define SIZE 512
static int fd;
static char buf[SIZE];

void verify_read(void) {
	//__read_chk(fd, buf, SIZE, SIZE);
	read(fd, buf, SIZE);
}

void setup(void) {
	memset(buf, '*', SIZE);
	fd = open("testfile", O_RDWR | O_CREAT, 0700);
	write(fd, buf, SIZE);
}

void cleanup(void) {
	if (fd > 0) close(fd);
}

int main() {
	setup();
	verify_read();
	cleanup();
}

We do see expected results using other commands:

SCOPE_EVENT_METRIC=true ./bin/linux/x86_64/scope head [some file]
scope events
seanvaleo pushed a commit that referenced this issue Oct 9, 2023
- In the case of the `host` application [1], the `host` app uses
 `libuv` to perform the DNS lookup.

- `uv__udp_sendmsg` uses the `syscall` to perform the sending message operation.
  The decision of whether to use `syscall` or `sendmsg` is based on checking the value of the
  `uv__sendmmsg_avail` variable in `uv__udp_sendmsg` [2].

- `uv__udp_recvmsg` uses `recvmsg` to perform the receiving message operation.
  The decision of whether to use `syscall` or `recvmsg` is based on checking the result
  of `uv_udp_using_recvmmsg` [3].

- The above explains why `libuv` uses `syscall` for sending messages and `recvmsg` for receiving messages.

- Additionally `libuv` check support for `recvmmsg()` and `sendmmsg()` using
  `uv__udp_mmsg_init` with calling `uv__sendmmsg(s, NULL, 0, 0)` [4]

The stack traces for the and `uv__udp_sendmsg` and `uv__udp_recvmsg`:

```
[#0] syscall()
[#1] uv__sendmmsg(...)
[#2] uv__udp_sendmmsg(..)
[#3] uv__udp_sendmsg(...)
[#4] uv__udp_send(...)
[#5] uv_udp_send(...)
```

```
[#0] recvmsg
[#1] uv__udp_recvmsg
```

Ref:
[1] https://github.com/isc-projects/bind9
[2] libuv/libuv@3d71366
[3] libuv/libuv@6b5aa66
[4] libuv/libuv@3d71366

Closes: #1586
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant