Skip to content

Commit 653d43d

Browse files
committed
Batching no longer has concept of max size
This was confusing and the real performance inconsistency was caused by not starting the timer before running the batch.
1 parent fff235f commit 653d43d

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

examples/billion_checkboxes_blob/src/app/main.clj

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@
506506

507507
(comment
508508
(do (-main) nil)
509-
;; (clojure.java.browse/browse-url "http://localhost:8080/")
509+
;; (clojure.java.browse/browse-url "https://localhost:3030/")
510510

511511

512512
;; stop server
@@ -588,16 +588,17 @@
588588
(fn [_]
589589
(run!
590590
(fn [_]
591-
(wrapped-router
592-
{:headers
593-
{"accept-encoding" "br"
594-
"cookie" "__Host-sid=5SNfeDa90PhXl0expOLFGdjtrpY; __Host-csrf=3UsG62ic9wLsg9EVQhGupw"
595-
"content-type" "application/json"}
596-
:request-method :post
597-
:uri handler-check
598-
:body {:csrf "3UsG62ic9wLsg9EVQhGupw"
599-
:parentid "0"
600-
:targetid (str (rand-int 200))}}))
591+
(-> (wrapped-router
592+
{:headers
593+
{"accept-encoding" "br"
594+
"cookie" "__Host-sid=5SNfeDa90PhXl0expOLFGdjtrpY; __Host-csrf=I3AAFrMG99lxoqwi87cSpn7unri5qYqJ-Vr9DLc4-s4"
595+
"content-type" "application/json"}
596+
:request-method :post
597+
:uri handler-check
598+
:body
599+
{:csrf "I3AAFrMG99lxoqwi87cSpn7unri5qYqJ-Vr9DLc4-s4"
600+
:parentid "0"
601+
:targetid (str (rand-int 200))}})))
601602
;; 10000r/s
602603
(range 10))
603604
(Thread/sleep 1))

src/hyperlith/impl/batch.clj

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
(defn batch!
77
"Wraps side-effecting function in a queue and batch mechanism. The
8-
batch is run every X ms when not empty and/or if it reaches it's max
9-
size. Function must take a vector of items. Supports back pressure."
10-
[effect-fn & {:keys [run-every-ms max-size]
11-
:or {run-every-ms 100
12-
max-size 1000}}]
8+
batch is run every X ms when not empty. Function must take a vector of items. Supports back pressure."
9+
[effect-fn & {:keys [run-every-ms]
10+
:or {run-every-ms 100}}]
1311
(let [<in (a/chan 1000)] ;; potentially pass this channel in
1412
(util/thread
1513
(loop [<t (a/timeout run-every-ms)
@@ -21,8 +19,7 @@
2119
(recur (a/timeout run-every-ms) batch)
2220

2321
;; Run batch
24-
(or (= p <t)
25-
(and (= p <in) (>= (count batch) max-size)))
22+
(= p <t)
2623
(let [;; Timer is started before task to prevent task duration
2724
;; from affecting interval (unless it exceeds interval).
2825
<new-t (a/timeout run-every-ms)]

0 commit comments

Comments
 (0)