nrepl

ericdallo 2025-04-16T14:49:45.260909Z

What I'm doing wrong to get the time spent to handle a eval?

✅ 1
ericdallo 2025-04-16T14:50:24.933969Z

https://github.com/ericdallo/metrepl/blob/15fe50505d4f0aa257ebe80f2cd3c483387dcb84/src/metrepl/metrics.clj#L22-L24 I measure the time the handle msg op takes, but it seems it's not correct (handle-op-fn) == (handle msg) in the middleware https://github.com/ericdallo/metrepl/blob/15fe50505d4f0aa257ebe80f2cd3c483387dcb84/src/metrepl/middleware/op_metrics.clj#L25

ericdallo 2025-04-16T14:50:49.741259Z

for a code like this:

(do
  (Thread/sleep 1000)
  (+ 1 2))
I get 1 ms

ericdallo 2025-04-16T14:52:28.920509Z

I suspect the eval is done async... if so, how to measure that?

oyakushev 2025-04-16T15:26:49.921169Z

Yes, evals happen in a different thread (a "session" thread)

ericdallo 2025-04-16T15:29:20.414899Z

Do you see any way to workaround that?

oyakushev 2025-04-16T15:30:52.071309Z

• Remember start time in the middleware wrapper • Update transport to intercept responses, wait for a :done response, that's where you take the end time

ericdallo 2025-04-16T15:35:15.825049Z

Ahh that makes sense, I do something similar in other middleware and didn't realize I could wait for done, awesome

ericdallo 2025-04-16T15:35:26.438119Z

Does that happens for other ops? Like load-file?

ericdallo 2025-04-16T15:35:41.133749Z

I mean, what others should I be aware of this async behavior

oyakushev 2025-04-16T15:36:37.568659Z

Can't tell you off the top of my head, you better check for yourself. load-file is a probable one

ericdallo 2025-04-16T15:58:10.231869Z

Will do, thank you!

ericdallo 2025-04-16T16:46:34.232999Z

that worked perfectly, thanks!

👍 2