Good Morning!
Good morning!
Morning
morning
was thinking about the overhead of hashes last night, as you do
What kinds of hash do you have problems with @raymcdermott?
(doseq [_ (range 5)]
(time (let [sha (MessageDigest/getInstance "SHA-256")]
(count (map (fn [x]
(->> x (.digest sha)))
(take 1000000 (repeatedly #(.getBytes (str "HASH" (rand-int Integer/MAX_VALUE))))))))))
"Elapsed time: 380.187311 msecs"
"Elapsed time: 376.734624 msecs"
"Elapsed time: 377.796685 msecs"
"Elapsed time: 378.096179 msecs"
"Elapsed time: 377.964661 msecs"
=> nil
(doseq [_ (range 5)]
(time (let [sha (MessageDigest/getInstance "SHA-256")]
(count (map (fn [x]
(->> x (.getBytes) (.digest sha)))
(take 1000000 (repeatedly #(str "HASH" (rand-int Integer/MAX_VALUE)))))))))
"Elapsed time: 1509.481255 msecs"
"Elapsed time: 1510.545895 msecs"
"Elapsed time: 1476.821262 msecs"
"Elapsed time: 1480.023988 msecs"
"Elapsed time: 1469.693934 msecs"
placement of .getBytes
makes a huge performance difference
1m hashes in 380ms or 1500ms
thoughts?
but also, I see your πΏ joke there @dominicm ...
@val_waeselynck re nginx from the other day ... using a cache like Varnish is often better if you have static assets cos then you don't need to split up your thinking between static and dynamic processing
I think of like memoize
at a system level
mogge
could it be reflection kicking in? maybe try a few type hints?
morning
and/or https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/*warn-on-reflection*
@raymcdermott As @ben.hammond suggested, type hints solves the problem:
(doseq [_ (range 5)]
(time (let [sha (MessageDigest/getInstance "SHA-256")]
(count (map (fn [^String x]
(->> x (.getBytes) (.digest sha)))
(take 1000000 (repeatedly #(str "HASH" (rand-int Integer/MAX_VALUE)))))))))
you're right, type hints FTW - it could see it after str
but not in the function. Great spot - thanks!
yes
great spot @ben.hammond
and a :face_palm::skin-tone-3: for me π
BTW, WTF were you doing replying in a thread @raymcdermott?
it's Ben, he gets a pass
also I allow myself to be inconsistent and hypocritical
oh? are threads contraversial?
Yeah, we don't like 'em round here. They unravel too easily.
Too many clicks for my liking but no rules
I like threadsβ¦ π
Threads vs No Threads reminds me of the noble tradition of Spaces vs Tabs and Emacs vs Vim π
hunter-gatherers vs farmer-herders
Threads are the type system of Slack
If you review the Richligious texts, you'll see he's very clearly against all forms of braiding. That includes threads!!!!!!!one!
@dominicm Keeping different discussions in different threads is clearly more decomplected than mixing all the topics together in the channel :P
To be fair, threads don't accurately mirror conversation. They mimic it, like a child playing with a toy oven. Conversations do more than simply splinter. They repeatedly splinter, and then they converge. They're far more like a git commit history.
Oh Jesus
Good hello!
morning
morni
Since you were discussing threads, I thought I would put in some multi-threaded printing. ng.
yep, my dumb logging does that (if I don't use tap>)
apropos threads: the first person to say fractal is gonna get it, right between the parens
why the fractal hate?
oops
is it really pretty in an unexpectedly mathematical way?
this feels like a real problem given your status
may the parens of β€οΈ protect us all from hate π
( hehe )