mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
test: profile slow close and fstat on the SD library
This commit is contained in:
1 parent
59cac100e8
commit
eb44931973
2 files changed
+23
-1
No files matched your search
@@ -1250,12 +1250,22 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags) {
|
||||
}
|
||||
|
||||
void bl_fsync_fds_closed(unsigned int first, unsigned int last) __attribute__((visibility("hidden")));
|
||||
int bl_meta_on(void) __attribute__((visibility("hidden")));
|
||||
uint64_t bl_meta_now(void) __attribute__((visibility("hidden")));
|
||||
void bl_meta_log(const char *op, int dirfd, const char *path, int flags, uint64_t start, long result, int err)
|
||||
__attribute__((visibility("hidden")));
|
||||
|
||||
int close(int fd) {
|
||||
if (fd >= 0) bl_fsync_fds_closed((unsigned int)fd, (unsigned int)fd);
|
||||
uint64_t *t = __atomic_load_n(&ns_fdt, __ATOMIC_ACQUIRE);
|
||||
if (t && fd >= 0 && fd < NS_FDS && __atomic_load_n(&t[fd], __ATOMIC_ACQUIRE)) ns_forget(fd);
|
||||
return ns_close_fd(fd);
|
||||
if (!bl_meta_on()) return ns_close_fd(fd);
|
||||
uint64_t t0 = bl_meta_now();
|
||||
int r = ns_close_fd(fd);
|
||||
int e = errno;
|
||||
if (bl_meta_now() - t0 > 1000000ULL) bl_meta_log("close", fd, "/steamapps/(slow close)", 0, t0, r, e);
|
||||
errno = e;
|
||||
return r;
|
||||
}
|
||||
|
||||
int dup2(int oldfd, int newfd) {
|
||||
|
||||
@@ -327,12 +327,24 @@ int truncate(const char *path, off_t length) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int bl_meta_on(void) __attribute__((visibility("hidden")));
|
||||
void bl_meta_log(const char *op, int dirfd, const char *path, int flags, uint64_t start, long result, int err)
|
||||
__attribute__((visibility("hidden")));
|
||||
|
||||
int fstat(int fd, struct stat *out) {
|
||||
int entry_errno = errno;
|
||||
if (next_fstat == NULL) next_fstat = dlsym(RTLD_NEXT, "fstat");
|
||||
if (next_fstat == NULL) { errno = ENOSYS; return -1; }
|
||||
initialize();
|
||||
errno = entry_errno;
|
||||
if (bl_meta_on()) {
|
||||
uint64_t t0 = now_ns();
|
||||
int r = next_fstat(fd, out);
|
||||
int e = errno;
|
||||
if (now_ns() - t0 > 500000ULL) bl_meta_log("fstat", fd, "/steamapps/(slow fstat)", 0, t0, r, e);
|
||||
errno = e;
|
||||
if (!enabled) return r;
|
||||
}
|
||||
if (!enabled) return next_fstat(fd, out);
|
||||
uint64_t start = now_ns();
|
||||
errno = entry_errno;
|
||||
|
||||
Reference in new issue
Block a user