Frostillicus has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
<discocaml>
<drupyog> @octachron do you have any idea ? 😦
inline has quit [Quit: Leaving]
<discocaml>
<drupyog> @octachron do you have any idea (or if I should ask somewhere) ? 😦
ygrek has joined #ocaml
<discocaml>
<contificate> It's made even more fun by the fact that calling C functions from OCaml 5 will pivot the stack (back to the system stack) - so there's 2 stacks to worry about (one being a cactus stack).
<discocaml>
<contificate> I vaguely recall some discussion before about his - concerning flame graph collection using `perf` - I can't remember the exact conclusion.
<discocaml>
<contificate> I vaguely recall some discussion before about this - concerning flame graph collection using `perf` - I can't remember the exact conclusion.
Frostillicus has joined #ocaml
Frostillicus has quit [Read error: Connection reset by peer]
humasect has joined #ocaml
Frostillicus has joined #ocaml
<discocaml>
<sim642> I remember reading that OCaml stacks are on the OCaml heap indeed. And that it effectively removes stack overflows
<discocaml>
<contificate> Yeah, that is often said in the context of dissuading people from the fun parlour trick of doing CPS conversion (as people did in OCaml 4) to make any function tail recursive (accumulating continuation closures on the heap as the stack frames)
<discocaml>
<sim642> But continuations make the notion more confusing too: performing an effect and handling it outside and then continuing back in the deep
<discocaml>
<contificate> well, the frames are never copied - so that "continuing" back/relinking of frames is adjusting a pointer
<discocaml>
<sim642> Indeed and that makes it harder to measure "the" size of "the" stack
<discocaml>
<sim642> Because there's a bunch of fragments lying around
<discocaml>
<sim642> But maybe that's irrelevant in @drupyog 's case
<discocaml>
<contificate> I don't think it makes it much harder, given that not `discontinue`ing `k` does not amount to leaking the fiber itself
<discocaml>
<contificate> in other words, there must be a way to track it all - the problem is whether random outside profiling tools expecting to basically work with `rsp` and DWARF info can cope (e.g. perf)
<discocaml>
<sim642> I think I recall that those should work still
<discocaml>
<contificate> lots of profiling tools are just sampling
<discocaml>
<contificate> so this idea of collecting many fragments isn't the default perspective
<discocaml>
<contificate> you could do such a profiler by vibecoding `perf_event_open` and sampling the register holding the domain table/caml state
<discocaml>
<sim642> Section 5.5 describes the DWARF unwinding for fibers
<discocaml>
<sim642> Section 5.5 in the effects paper describes the DWARF unwinding for fibers
<discocaml>
<contificate> then it comes down to asking which profiling tools currently work out of the box
<discocaml>
<octachron> My rough understanding is that OCaml is not using system stack, but its own stacks on the heap. Fibers (stack fragments) are then stored on the heap, with a separate cache for reusing them. But as far as I can see, stack usage is not instrumented (there is at most a GC debug event when allocating new stacks). And it seems that I might have been wrong in thinking that fibers were garbage collected.
Frostillicus has quit [Read error: Connection reset by peer]
<discocaml>
<sim642> My impression was that they would be GC-d but discontinue is more for triggering them to release external resources
Frostillicus has joined #ocaml
<discocaml>
<octachron> Seeing as my test that was just looping and raising an effect ended up OOM-killed in seconds; while adding a finalizer to a wrapper around the continuation works, this doesn't look like it is the case.
<discocaml>
<contificate> There's a telling quote from the paper
<discocaml>
<contificate> > It is also useful to note that even if the memory
<discocaml>
<contificate> > for the fiber stack is managed by the GC, we would still need
<discocaml>
<contificate> > a finalisation mechanism to unwind the stack and release
<discocaml>
<contificate> > other system resources that may be held by the continuation.
<discocaml>
<contificate> they show this `Gc.finalise` resumption thing in the paper, too
<discocaml>
<octachron> @drupyog , going back to your question adding a statmemprof events for stacks allocation/reallocation/freeing looks reasonably easy to do.
Frostillicus has quit [Read error: Connection reset by peer]
Frostillicus has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
Frostillicus has quit [Read error: Connection reset by peer]
Frostillicus has joined #ocaml
bibi_ has joined #ocaml
euphores has joined #ocaml
semarie has quit [Quit: quit]
semarie has joined #ocaml
Frostillicus has quit [Read error: Connection reset by peer]
Frostillicus has joined #ocaml
semarie has quit [Quit: quit]
semarie has joined #ocaml
Haudegen has joined #ocaml
inline has joined #ocaml
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 240 seconds]
Frostillicus has quit [Ping timeout: 248 seconds]
Frostillicus has joined #ocaml
_jbrown_ has joined #ocaml
Tuplanolla has quit [Ping timeout: 240 seconds]
itszor has quit [Ping timeout: 240 seconds]
casastorta has quit [Ping timeout: 240 seconds]
Tuplanolla has joined #ocaml
casastorta has joined #ocaml
Frostillicus has quit [Read error: Connection reset by peer]
Serpent7776 has quit [Ping timeout: 240 seconds]
Serpent7776 has joined #ocaml
Frostillicus has joined #ocaml
zor has joined #ocaml
_jbrown_ has quit [Ping timeout: 248 seconds]
<discocaml>
<drupyog> mmh, do you have pointers ?
<discocaml>
<octachron> The stack allocation functions are in runtime/fiber.c
<discocaml>
<drupyog> (also, stack overflow definitely still exists in 5.0 :p)
<discocaml>
<drupyog> ok, I will attempt something
humasect has quit [Remote host closed the connection]
inline has quit [Quit: Leaving]
<olle>
Hm why this cermony of open both Effect and Effect.Deep?
<olle>
Ah nevermind
humasect has joined #ocaml
<discocaml>
<deepspacejohn> I don’t think there’s much of a reason to open either, IMO
buoy49__ has quit [Ping timeout: 276 seconds]
buoy49__ has joined #ocaml
humasect has quit [Quit: Leaving...]
itszor has joined #ocaml
Frostillicus has quit [Read error: Connection reset by peer]
Frostillicus has joined #ocaml
zor has quit [Ping timeout: 276 seconds]
euphores has quit [Ping timeout: 240 seconds]
Frostillicus has quit [Read error: Connection reset by peer]
Frostillicus has joined #ocaml
Exagone313 has joined #ocaml
Exa has quit [Ping timeout: 276 seconds]
Exagone313 is now known as Exa
bartholin has quit [Remote host closed the connection]
ygrek has quit [Remote host closed the connection]