Skip to content

Commit b709b9a

Browse files
committed
Don't reduce remaining quota in current
`Fiber.current ()` can be very performance critical. So, it is perhaps better not to make it any more expensive than necessary.
1 parent 7802d2b commit b709b9a

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

lib/picos_fifos/picos_fifos.ml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ let[@inline never] quota_non_positive () = invalid_arg "quota must be positive"
66
more memory than values of this type. *)
77
type ready =
88
| Spawn of Fiber.t * (Fiber.t -> unit)
9-
| Current of Fiber.t * (Fiber.t, unit) Effect.Deep.continuation
109
| Continue of Fiber.t * (unit, unit) Effect.Deep.continuation
1110
| Resume of Fiber.t * (Exn_bt.t option, unit) Effect.Deep.continuation
1211
| Return of Fiber.t * (unit, unit) Effect.Deep.continuation
@@ -38,10 +37,6 @@ let rec next t =
3837
t.fiber <- Fiber.Maybe.of_fiber fiber;
3938
t.remaining_quota <- t.quota;
4039
Effect.Deep.match_with main fiber t.handler
41-
| Current (fiber, k) ->
42-
t.fiber <- Fiber.Maybe.of_fiber fiber;
43-
t.remaining_quota <- t.quota;
44-
Effect.Deep.continue k fiber
4540
| Return (fiber, k) ->
4641
t.fiber <- Fiber.Maybe.of_fiber fiber;
4742
t.remaining_quota <- t.quota;
@@ -112,16 +107,8 @@ let run_fiber ?quota ?fatal_exn_handler:(exnc : _ = raise) fiber main =
112107
later. *)
113108
Some
114109
(fun k ->
115-
let remaining_quota = t.remaining_quota - 1 in
116110
let fiber = Fiber.Maybe.to_fiber t.fiber in
117-
if 0 < remaining_quota then begin
118-
t.remaining_quota <- remaining_quota;
119-
Effect.Deep.continue k fiber
120-
end
121-
else begin
122-
Picos_mpscq.push t.ready (Current (fiber, k));
123-
next t
124-
end)
111+
Effect.Deep.continue k fiber)
125112
and yield =
126113
Some
127114
(fun k ->

0 commit comments

Comments
 (0)