rage-iodine 6.4.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/iodine/fio.c +180 -5
- data/ext/iodine/fio.h +25 -0
- data/ext/iodine/iodine_perf.c +39 -0
- data/lib/iodine/version.rb +1 -1
- data/lib/iodine.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e60bf77bc44fda96f9ce2f896b32d846842cf6e09d9038d16df6f629d26feb1
|
|
4
|
+
data.tar.gz: 7891e6f73ba61d60426159b42986baff4fd0ad1fdbfcce524b15f9e61273d19e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51227df5ee06d7692fdcd9bbb36dc8ae123deca0facc914fe3ca22b6c08ca3af9fc30a59af6a7b84bf5bdc06b554f9cbb7b95cee4ac1754690df030c50a33e0a
|
|
7
|
+
data.tar.gz: 0274de3c8d4a7ade9245c806aa340cb102ed6c785a22922dbd5054b929104704f64a89a7d079017cbbf717583651e6a0f15dc8348b3258e8a4276a1d5a5a00f8
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ Please notice that this change log contains changes for upcoming releases as wel
|
|
|
6
6
|
|
|
7
7
|
## Changes:
|
|
8
8
|
|
|
9
|
+
#### Change log v.7.0.0 (2026-11-08)
|
|
10
|
+
|
|
11
|
+
**Update**: Add API for measuring event loop utilization (ELU).
|
|
12
|
+
|
|
9
13
|
#### Change log v.6.4.0 (2026-10-29)
|
|
10
14
|
|
|
11
15
|
**Update**: Avoid disk writes for small chunked request bodies.
|
data/ext/iodine/fio.c
CHANGED
|
@@ -637,6 +637,130 @@ struct timespec fio_last_tick(void) {
|
|
|
637
637
|
return fio_data->last_cycle;
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
+
/* *****************************************************************************
|
|
641
|
+
Event Loop Utilization (ELU) metrics
|
|
642
|
+
***************************************************************************** */
|
|
643
|
+
|
|
644
|
+
/* idle nanoseconds + monotonic start of the measurement window. */
|
|
645
|
+
static uint64_t fio_elu_idle_acc = 0;
|
|
646
|
+
static uint64_t fio_elu_window_start = 0;
|
|
647
|
+
/*
|
|
648
|
+
* Entry time of a wait (epoll, kqueue, poll) in progress.
|
|
649
|
+
* The reactor stamps it before a genuinely blocking wait and moves the
|
|
650
|
+
* measured interval into the accumulator when the wait exits. Keeping the
|
|
651
|
+
* in-progress interval out of the accumulator lets readers fold it in
|
|
652
|
+
* continuously, so a read never misses waiting time.
|
|
653
|
+
*/
|
|
654
|
+
static uint64_t fio_elu_entry_time = 0;
|
|
655
|
+
/* guards fio_acc_idle_acc + fio_elu_entry_time against readers from other threads. */
|
|
656
|
+
static fio_lock_i fio_elu_lock = FIO_LOCK_INIT;
|
|
657
|
+
/* Disabled by default the reactor follows its original path when off. */
|
|
658
|
+
static int fio_elu_enabled_flag = 0;
|
|
659
|
+
|
|
660
|
+
/** Monotonic nanosecond timestamp (failures read as 0 and are skipped). */
|
|
661
|
+
static uint64_t fio_elu_monotonic_ns(void) {
|
|
662
|
+
struct timespec ts;
|
|
663
|
+
|
|
664
|
+
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {
|
|
665
|
+
return 0;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return ((uint64_t)ts.tv_sec * 1000000000UL) + (uint64_t)ts.tv_nsec;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/* public API. */
|
|
672
|
+
void fio_elu_enable(void) {
|
|
673
|
+
if (fio_elu_enabled_flag) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
fio_lock(&fio_elu_lock);
|
|
678
|
+
fio_elu_idle_acc = 0;
|
|
679
|
+
fio_elu_entry_time = 0;
|
|
680
|
+
fio_unlock(&fio_elu_lock);
|
|
681
|
+
fio_elu_window_start = fio_elu_monotonic_ns();
|
|
682
|
+
fio_elu_enabled_flag = 1;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/* public API. */
|
|
686
|
+
int fio_elu_is_enabled(void) { return fio_elu_enabled_flag; }
|
|
687
|
+
|
|
688
|
+
/* public API. */
|
|
689
|
+
void fio_elu_snapshot(uint64_t *idle_out, uint64_t *elapsed_out) {
|
|
690
|
+
uint64_t idle_time = 0;
|
|
691
|
+
uint64_t entry_time = 0;
|
|
692
|
+
uint64_t now = 0;
|
|
693
|
+
uint64_t elapsed = 0;
|
|
694
|
+
|
|
695
|
+
if (fio_elu_enabled_flag) {
|
|
696
|
+
fio_lock(&fio_elu_lock);
|
|
697
|
+
idle_time = fio_elu_idle_acc;
|
|
698
|
+
entry_time = fio_elu_entry_time;
|
|
699
|
+
fio_unlock(&fio_elu_lock);
|
|
700
|
+
|
|
701
|
+
/* one reading binds both counters to the same instant. */
|
|
702
|
+
now = fio_elu_monotonic_ns();
|
|
703
|
+
|
|
704
|
+
/* a wait in progress counts as idle for its elapsed so far. */
|
|
705
|
+
if (entry_time && now > entry_time) {
|
|
706
|
+
idle_time += now - entry_time;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/* elapsed, same window as idle. */
|
|
710
|
+
if (now && now > fio_elu_window_start) {
|
|
711
|
+
elapsed = now - fio_elu_window_start;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
*idle_out = idle_time;
|
|
715
|
+
*elapsed_out = elapsed;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Stamps the entry time before a genuinely blocking wait (nonzero timeout).
|
|
720
|
+
* A reader may run on another thread, so the stamp is written under the
|
|
721
|
+
* lock, like every other access to it.
|
|
722
|
+
*/
|
|
723
|
+
static inline void fio_elu_poll_enter(void) {
|
|
724
|
+
uint64_t entry_time;
|
|
725
|
+
|
|
726
|
+
if (!fio_elu_enabled_flag) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
entry_time = fio_elu_monotonic_ns();
|
|
731
|
+
if (!entry_time) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
fio_lock(&fio_elu_lock);
|
|
736
|
+
fio_elu_entry_time = entry_time;
|
|
737
|
+
fio_unlock(&fio_elu_lock);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* A wait just finished: move the measured interval into the accumulator and
|
|
742
|
+
* clear the entry stamp under the lock, so that readers always observe the
|
|
743
|
+
* pair (idle, entry) consistently. The exit timestamp is captured before the
|
|
744
|
+
* lock: contention here is overhead, not event provider waiting, and must
|
|
745
|
+
* not inflate the measured idle interval.
|
|
746
|
+
*/
|
|
747
|
+
static inline void fio_elu_poll_exit(void) {
|
|
748
|
+
uint64_t exit_time, entry_time;
|
|
749
|
+
|
|
750
|
+
if (!fio_elu_enabled_flag) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
exit_time = fio_elu_monotonic_ns();
|
|
755
|
+
fio_lock(&fio_elu_lock);
|
|
756
|
+
entry_time = fio_elu_entry_time;
|
|
757
|
+
fio_elu_entry_time = 0;
|
|
758
|
+
if (entry_time && exit_time > entry_time) {
|
|
759
|
+
fio_elu_idle_acc += exit_time - entry_time;
|
|
760
|
+
}
|
|
761
|
+
fio_unlock(&fio_elu_lock);
|
|
762
|
+
}
|
|
763
|
+
|
|
640
764
|
#define touchfd(fd) fd_data((fd)).active = fio_data->last_cycle.tv_sec
|
|
641
765
|
|
|
642
766
|
/* public API. */
|
|
@@ -2141,8 +2265,20 @@ static size_t fio_poll(void) {
|
|
|
2141
2265
|
struct epoll_event internal[2];
|
|
2142
2266
|
struct epoll_event events[FIO_POLL_MAX_EVENTS];
|
|
2143
2267
|
int total = 0;
|
|
2268
|
+
int internal_count;
|
|
2269
|
+
|
|
2270
|
+
/* ELU: a blocking wait with a timeout counts as idle; a zero-timeout wait
|
|
2271
|
+
* or a disabled ELU follows the original path untouched. */
|
|
2272
|
+
int elu_measure = fio_elu_enabled_flag && timeout_millisec > 0;
|
|
2273
|
+
if (elu_measure) {
|
|
2274
|
+
fio_elu_poll_enter();
|
|
2275
|
+
}
|
|
2144
2276
|
/* wait for events and handle them */
|
|
2145
|
-
|
|
2277
|
+
internal_count = epoll_wait(evio_fd[0], internal, 2, timeout_millisec);
|
|
2278
|
+
if (elu_measure) {
|
|
2279
|
+
fio_elu_poll_exit();
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2146
2282
|
if (internal_count == 0)
|
|
2147
2283
|
return internal_count;
|
|
2148
2284
|
for (int j = 0; j < internal_count; ++j) {
|
|
@@ -2332,9 +2468,20 @@ static size_t fio_poll(void) {
|
|
|
2332
2468
|
const struct timespec timeout = {
|
|
2333
2469
|
.tv_sec = (timeout_millisec / 1000),
|
|
2334
2470
|
.tv_nsec = ((timeout_millisec % 1000) * 1000000)};
|
|
2471
|
+
|
|
2472
|
+
int active_count;
|
|
2473
|
+
|
|
2474
|
+
/* ELU: a blocking wait with a timeout counts as idle; a zero-timeout wait
|
|
2475
|
+
* or a disabled ELU follows the original path untouched. */
|
|
2476
|
+
int elu_measure = fio_elu_enabled_flag && timeout_millisec > 0;
|
|
2477
|
+
if (elu_measure) {
|
|
2478
|
+
fio_elu_poll_enter();
|
|
2479
|
+
}
|
|
2335
2480
|
/* wait for events and handle them */
|
|
2336
|
-
|
|
2337
|
-
|
|
2481
|
+
active_count = kevent(evio_fd, NULL, 0, events, FIO_POLL_MAX_EVENTS, &timeout);
|
|
2482
|
+
if (elu_measure) {
|
|
2483
|
+
fio_elu_poll_exit();
|
|
2484
|
+
}
|
|
2338
2485
|
|
|
2339
2486
|
if (active_count > 0) {
|
|
2340
2487
|
for (int i = 0; i < active_count; i++) {
|
|
@@ -2490,10 +2637,27 @@ static size_t fio_poll(void) {
|
|
|
2490
2637
|
int timeout = fio_timer_calc_first_interval();
|
|
2491
2638
|
size_t count = 0;
|
|
2492
2639
|
|
|
2640
|
+
int elu_measure = fio_elu_enabled_flag && timeout > 0;
|
|
2493
2641
|
if (start == end) {
|
|
2642
|
+
/* no sockets: throttling instead of polling still counts as waiting. */
|
|
2643
|
+
if (elu_measure) {
|
|
2644
|
+
fio_elu_poll_enter();
|
|
2645
|
+
}
|
|
2494
2646
|
fio_throttle_thread((timeout * 1000000UL));
|
|
2495
|
-
|
|
2496
|
-
|
|
2647
|
+
if (elu_measure) {
|
|
2648
|
+
fio_elu_poll_exit();
|
|
2649
|
+
}
|
|
2650
|
+
} else {
|
|
2651
|
+
if (elu_measure) {
|
|
2652
|
+
fio_elu_poll_enter();
|
|
2653
|
+
}
|
|
2654
|
+
int polled = poll(list + start, end - start, timeout);
|
|
2655
|
+
if (elu_measure) {
|
|
2656
|
+
fio_elu_poll_exit();
|
|
2657
|
+
}
|
|
2658
|
+
if (polled == -1) {
|
|
2659
|
+
goto finish;
|
|
2660
|
+
}
|
|
2497
2661
|
}
|
|
2498
2662
|
for (size_t i = start; i < end; ++i) {
|
|
2499
2663
|
if (list[i].revents) {
|
|
@@ -4557,6 +4721,17 @@ static fio_lock_i fio_accept_queue_lock;
|
|
|
4557
4721
|
static void fio_on_fork(void) {
|
|
4558
4722
|
fio_timer_lock = FIO_LOCK_INIT;
|
|
4559
4723
|
fio_data->lock = FIO_LOCK_INIT;
|
|
4724
|
+
|
|
4725
|
+
/* ELU: the child inherits a copy restart with a fresh window. A parent
|
|
4726
|
+
* thread may have held the lock mid-transfer, so reset it like the others. */
|
|
4727
|
+
fio_elu_lock = FIO_LOCK_INIT;
|
|
4728
|
+
fio_elu_idle_acc = 0;
|
|
4729
|
+
fio_elu_entry_time = 0;
|
|
4730
|
+
|
|
4731
|
+
if (fio_elu_enabled_flag) {
|
|
4732
|
+
fio_elu_window_start = fio_elu_monotonic_ns();
|
|
4733
|
+
}
|
|
4734
|
+
|
|
4560
4735
|
#if defined(__linux__)
|
|
4561
4736
|
/* a forked child may inherit the accept-queue lock while a parent thread
|
|
4562
4737
|
* held it mid-walk; that thread won't exist in the child, so reset it. */
|
data/ext/iodine/fio.h
CHANGED
|
@@ -1068,6 +1068,31 @@ void fio_signal_handler_reset(void);
|
|
|
1068
1068
|
*/
|
|
1069
1069
|
struct timespec fio_last_tick(void);
|
|
1070
1070
|
|
|
1071
|
+
/**
|
|
1072
|
+
* Enables event-loop utilization (ELU) tracking.
|
|
1073
|
+
*
|
|
1074
|
+
* Off by default; calling this more than once does nothing.
|
|
1075
|
+
* Counters start measuring from this moment. Forked workers
|
|
1076
|
+
* start fresh on their own (see `fio_on_fork`).
|
|
1077
|
+
*/
|
|
1078
|
+
void fio_elu_enable(void);
|
|
1079
|
+
|
|
1080
|
+
/** Returns non-zero once ELU tracking was enabled. */
|
|
1081
|
+
int fio_elu_is_enabled(void);
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Reads both ELU counters at a single point in time, so idle and elapsed
|
|
1085
|
+
* always belong to the same instant.
|
|
1086
|
+
*
|
|
1087
|
+
* Thread-safe to read from any thread: a wait in progress is included as a
|
|
1088
|
+
* measure in the reader, instead of being added all at once after the wait
|
|
1089
|
+
* completes.
|
|
1090
|
+
* Returns 0s unless enabled.
|
|
1091
|
+
*
|
|
1092
|
+
* ELU over an interval is `1 - Δidle / Δelapsed`.
|
|
1093
|
+
*/
|
|
1094
|
+
void fio_elu_snapshot(uint64_t *idle_ns, uint64_t *elapsed_ns);
|
|
1095
|
+
|
|
1071
1096
|
/**
|
|
1072
1097
|
* Returns a C string detailing the IO engine selected during compilation.
|
|
1073
1098
|
*
|
data/ext/iodine/iodine_perf.c
CHANGED
|
@@ -21,8 +21,47 @@ static VALUE iodine_perf_queued_connections(VALUE self) {
|
|
|
21
21
|
#endif
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Iodine::Perf.elu_enable_idle_time!
|
|
26
|
+
*
|
|
27
|
+
* Enables event loop utilization (ELU) tracking.
|
|
28
|
+
* Disabled by default.
|
|
29
|
+
*
|
|
30
|
+
* Returns true (calling it more than once does nothing).
|
|
31
|
+
*/
|
|
32
|
+
static VALUE iodine_perf_elu_enable_idle_time(VALUE self) {
|
|
33
|
+
(void)self;
|
|
34
|
+
fio_elu_enable();
|
|
35
|
+
return Qtrue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Iodine::Perf.elu_snapshot
|
|
40
|
+
*
|
|
41
|
+
* Reads both ELU counters at a single point in time, so that idle and
|
|
42
|
+
* elapsed always belong to the same instant.
|
|
43
|
+
*
|
|
44
|
+
* Returns nil unless ELU tracking was enabled; otherwise
|
|
45
|
+
* [idle_time_ns, elapsed_ns], both increasing Integer counts.
|
|
46
|
+
*/
|
|
47
|
+
static VALUE iodine_perf_elu_snapshot(VALUE self) {
|
|
48
|
+
uint64_t idle_time, elapsed_time;
|
|
49
|
+
|
|
50
|
+
(void)self;
|
|
51
|
+
if (!fio_elu_is_enabled()) {
|
|
52
|
+
return Qnil;
|
|
53
|
+
}
|
|
54
|
+
fio_elu_snapshot(&idle_time, &elapsed_time);
|
|
55
|
+
return rb_ary_new_from_args(2, ULL2NUM(idle_time), ULL2NUM(elapsed_time));
|
|
56
|
+
}
|
|
57
|
+
|
|
24
58
|
void iodine_perf_initialize(void) {
|
|
25
59
|
VALUE IodinePerfModule = rb_define_module_under(IodineModule, "Perf");
|
|
26
60
|
rb_define_module_function(IodinePerfModule, "queued_connections",
|
|
27
61
|
iodine_perf_queued_connections, 0);
|
|
62
|
+
/* The ELU (event loop utilization) group. */
|
|
63
|
+
rb_define_module_function(IodinePerfModule, "elu_enable_idle_time!",
|
|
64
|
+
iodine_perf_elu_enable_idle_time, 0);
|
|
65
|
+
rb_define_module_function(IodinePerfModule, "elu_snapshot",
|
|
66
|
+
iodine_perf_elu_snapshot, 0);
|
|
28
67
|
}
|
data/lib/iodine/version.rb
CHANGED
data/lib/iodine.rb
CHANGED