Skip to content

Commit dad0bf4

Browse files
authored
Merge pull request #9 from ArchitAnant/v5
V5
2 parents 9ee0049 + 08804c1 commit dad0bf4

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

debian/changelog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
ffind (1.1-1) unstable; urgency=medium
2+
3+
* Added batching support with io_uring (up to 64 ops).
4+
5+
-- Archit Anant <[email protected]> Sun, 31 Aug 2025 15:30:00 +0530
6+
7+
18
ffind (1.0-1) unstable; urgency=medium
29

310
* Initial release (Closes: #000000)
411

512
-- Archit Anant <[email protected]> Sat, 23 Aug 2025 20:00:00 +0530
13+

src/submissions.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,24 @@
77
#include <unistd.h>
88
#include <dirent.h>
99
#include "../headers/request.h"
10+
#define BATCH_SIZE 64
1011

12+
static int pending_in_batch = 0;
1113

12-
void submit_open_request(const char *path, struct io_uring *ring, int *inflight_ops) {
14+
void flush_batch(struct io_uring *ring){
15+
if (pending_in_batch>0)
16+
{
17+
int ret = io_uring_submit(ring);
18+
if (ret<0)
19+
{
20+
fprintf(stderr, "Error in io_uring_submit: %s\n", strerror(-ret));
21+
}
22+
pending_in_batch = 0;
23+
}
24+
25+
}
26+
27+
void submit_open_request(const char *path, struct io_uring *ring, int *inflight_ops,int force_flush) {
1328
Request *req = malloc(sizeof(Request));
1429
if (!req) {
1530
perror("malloc request");
@@ -29,6 +44,14 @@ void submit_open_request(const char *path, struct io_uring *ring, int *inflight_
2944
io_uring_sqe_set_data(sqe, req);
3045

3146
(*inflight_ops)++;
47+
pending_in_batch++;
48+
49+
if (pending_in_batch>=BATCH_SIZE || force_flush)
50+
{
51+
flush_batch(ring);
52+
//pending_in_batch=0;
53+
}
54+
3255
}
3356

3457

@@ -67,7 +90,7 @@ void handle_completion(struct io_uring_cqe *cqe, const char *search_term, struct
6790
// Using d_type is much faster than calling stat() for every entry.
6891
if (entry->d_type == DT_DIR) {
6992
// RECURSIVE STEP: If it's a directory, submit a new async 'openat' request.
70-
submit_open_request(full_path, ring, inflight_ops);
93+
submit_open_request(full_path, ring, inflight_ops,0);
7194
} else if (entry->d_type == DT_REG) {
7295
// It's a regular file. Check if its name matches the search term.
7396
if (strstr(entry->d_name, search_term) != NULL) {
@@ -76,6 +99,11 @@ void handle_completion(struct io_uring_cqe *cqe, const char *search_term, struct
7699
}
77100
// Note: We are ignoring DT_UNKNOWN, symlinks, etc. for simplicity.
78101
}
102+
if (pending_in_batch>0)
103+
{
104+
flush_batch(ring);
105+
}
106+
79107

80108
// Clean up resources for the directory we just finished scanning.
81109
closedir(dir_stream); // This also closes the underlying dir_fd.

0 commit comments

Comments
 (0)