Logs: liberachat/#haskell
| 2025-09-24 19:00:46 | → | caconym74787 joins (~caconym@user/caconym) |
| 2025-09-24 19:02:56 | × | jaror quits (~jaror@5070ACC7.static.ziggozakelijk.nl) (Quit: The Lounge - https://thelounge.chat) |
| 2025-09-24 19:04:39 | → | jaror3 joins (~jaror@5070ACC7.static.ziggozakelijk.nl) |
| 2025-09-24 19:04:52 | <[exa]> | tomsmeding: "which layer of the RTS" :D |
| 2025-09-24 19:05:03 | <tomsmeding> | I dunno lol |
| 2025-09-24 19:05:22 | <tomsmeding> | colleague gave few details, but they seemed happy with what int-e linked |
| 2025-09-24 19:06:51 | <[exa]> | tomsmeding: ah ok... feel free to link that uskel nonsense of mine in case they want a lowlevel demo |
| 2025-09-24 19:07:07 | <[exa]> | it's not STG per se but imagining the spine stack next to it isn't hard |
| 2025-09-24 19:08:32 | <[exa]> | also the general other part of RTS is "how does the IO eventloop work with threads and GC" and tbh that is seriously dark magic for me |
| 2025-09-24 19:09:35 | <tomsmeding> | right, when I think of "RTS" I think scheduler, IO loop, GC, etc. |
| 2025-09-24 19:09:41 | <tomsmeding> | STG to me is compilation and codegen |
| 2025-09-24 19:10:19 | <tomsmeding> | the fact that there happens to be an STG interpreter in the RTS (which TIL) is just because... for some reason a compiled haskell executable has ghci in it? |
| 2025-09-24 19:10:23 | <tomsmeding> | is that really true? |
| 2025-09-24 19:10:38 | × | leah2 quits (~leah@vuxu.org) (Ping timeout: 256 seconds) |
| 2025-09-24 19:11:01 | <tomsmeding> | [exa]: https://tomsmeding.com/ss/get/tomsmeding/aGJuCc |
| 2025-09-24 19:12:35 | <[exa]> | well the compiled haskell code is the STG interpreter, implicitly. I'm not OK with the "has ghci in it" part, see no reason for that, but it might be a ghc-specific thing nowadays |
| 2025-09-24 19:12:53 | <[exa]> | tomsmeding: https://git.e-x-a.org/exa/uskel |
| 2025-09-24 19:13:27 | <tomsmeding> | oof |
| 2025-09-24 19:14:57 | <tomsmeding> | I thought I was cool in having written a micro netcat clone in assembly like 10 years go |
| 2025-09-24 19:14:59 | <tomsmeding> | *ago |
| 2025-09-24 19:15:44 | × | Googulator quits (~Googulato@80-95-93-255.pool.digikabel.hu) (Quit: Client closed) |
| 2025-09-24 19:15:47 | → | Googulator37 joins (~Googulato@2a01-036d-0106-0744-4151-2ee3-78cb-4ad2.pool6.digikabel.hu) |
| 2025-09-24 19:16:36 | <[exa]> | tbh the netcat in assembly is probably harder, the stupidest part of this is that you need to encode the STG operations in the assembly macros |
| 2025-09-24 19:17:14 | <[exa]> | and then you basically have haskell without the typesystem |
| 2025-09-24 19:17:16 | <tomsmeding> | that just makes it better |
| 2025-09-24 19:17:25 | <tomsmeding> | if you want pain, you can have pain |
| 2025-09-24 19:17:28 | → | vanishingideal joins (~vanishing@user/vanishingideal) |
| 2025-09-24 19:18:39 | × | machinedgod quits (~machinedg@d75-159-126-101.abhsia.telus.net) (Ping timeout: 244 seconds) |
| 2025-09-24 19:20:54 | <[exa]> | e.g. this thing: https://git.e-x-a.org/exa/uskel/src/branch/master/fibs.s#L40-L44 -- if you read it from below, it essentially encodes thunks for AST `print(list_int_index(int(20), fibs0))`, and starts evaluating it it with continuation going into main_exit |
| 2025-09-24 19:21:58 | <[exa]> | `thunkto %r11, $list_int_index, $2, %r11, %r12` reads "make a thunk and save its address to r11, the thunk will be evaluated by list_int_index, it has 2 arguments and they are at addresses from r11 and r12" |
| 2025-09-24 19:22:19 | <tomsmeding> | I figured that out about 3 seconds before you posted |
| 2025-09-24 19:22:23 | <[exa]> | <3 |
| 2025-09-24 19:22:59 | <tomsmeding> | I was like, what's that $2 doing... there's a $20 before but oh that's an immediate... oh there is $0 at fibs0... oh wait |
| 2025-09-24 19:23:24 | <[exa]> | yeah fibs0 is a starter, in haskell it would be `fibs0 = fibs 0 1` |
| 2025-09-24 19:23:32 | → | leah2 joins (~leah@vuxu.org) |
| 2025-09-24 19:23:49 | <tomsmeding> | does %rsi have a special meaning? |
| 2025-09-24 19:23:51 | <[exa]> | TECHNICALLY I could make gnu as macros that simply parse haskell code into this, but man, so lazy |
| 2025-09-24 19:23:52 | → | merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl) |
| 2025-09-24 19:23:58 | <tomsmeding> | I don't see it used or referenced above |
| 2025-09-24 19:24:00 | <[exa]> | yeah %rsi in this case is a continuation pointer |
| 2025-09-24 19:24:22 | <tomsmeding> | ah so if the thunk being entered has been evaluated to whnf, %rsi is entered? |
| 2025-09-24 19:24:38 | → | annamalai joins (~annamalai@157.33.214.216) |
| 2025-09-24 19:25:02 | <[exa]> | %rbp always points to the thunk that's currently evaluated, %rsi is "where it should send the result" (aka address of continuation), and %rsp points funnily to the small haskell heap, (this ignores the C stack entirely) |
| 2025-09-24 19:25:11 | <[exa]> | reason: I can write thunks with a series of pushq |
| 2025-09-24 19:25:33 | <tomsmeding> | "I have 1-instruction bump allocator" |
| 2025-09-24 19:25:45 | <tomsmeding> | one word at a time |
| 2025-09-24 19:25:59 | <[exa]> | the needs_alloc at the top of each thunk is checking if there's enough memory and triggers gc if not |
| 2025-09-24 19:26:13 | <tomsmeding> | cool |
| 2025-09-24 19:26:14 | <[exa]> | yeah the gc is probably the smartest part |
| 2025-09-24 19:26:32 | <[exa]> | it has to fit into like 5 registers because the thunks need other registers to be able to compute their evacuation |
| 2025-09-24 19:26:45 | <tomsmeding> | interesting |
| 2025-09-24 19:26:57 | <tomsmeding> | you're using all of the x64 registers? |
| 2025-09-24 19:27:22 | <[exa]> | and there's some oversmartness that is able to actually increase the amount of memory allocated IF it seems that the GC runs don't really help much |
| 2025-09-24 19:27:43 | <tomsmeding> | increase nursery size, you mean? |
| 2025-09-24 19:27:51 | <[exa]> | not really, in the "normal" evaluation only the 3 above are "important" |
| 2025-09-24 19:28:14 | <[exa]> | during gc I think I use all "general" registers, ie %r8 to %r15 |
| 2025-09-24 19:28:24 | × | olivial quits (~benjaminl@user/benjaminl) (Ping timeout: 260 seconds) |
| 2025-09-24 19:28:43 | <[exa]> | the whole gc is registers-only, it only has a tiny global blob where it stores some extra info |
| 2025-09-24 19:28:54 | <[exa]> | "nursery size" --- there's only nursery |
| 2025-09-24 19:28:59 | <tomsmeding> | right |
| 2025-09-24 19:28:59 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds) |
| 2025-09-24 19:29:18 | <tomsmeding> | I find it funny that hand-written assembly code tends to use registers so differently from generated code |
| 2025-09-24 19:29:21 | <[exa]> | like if someone added an extra gc layer on top of this, it's actually going to be fast |
| 2025-09-24 19:29:48 | <[exa]> | well lemme point to code a bit |
| 2025-09-24 19:29:53 | <tomsmeding> | as fast as it can be if everything ever is boxed, right? |
| 2025-09-24 19:30:35 | <[exa]> | these are the allocator globals: https://git.e-x-a.org/exa/uskel/src/branch/master/include/gc.s#L5 |
| 2025-09-24 19:30:39 | → | Googulator84 joins (~Googulato@2a01-036d-0106-0744-4151-2ee3-78cb-4ad2.pool6.digikabel.hu) |
| 2025-09-24 19:30:48 | <[exa]> | well no one says you need to box your stuff |
| 2025-09-24 19:30:49 | × | Googulator37 quits (~Googulato@2a01-036d-0106-0744-4151-2ee3-78cb-4ad2.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-09-24 19:30:54 | → | target_i joins (~target_i@user/target-i/x-6023099) |
| 2025-09-24 19:31:01 | <tomsmeding> | :p |
| 2025-09-24 19:31:06 | <tomsmeding> | that's fair |
| 2025-09-24 19:31:29 | <tomsmeding> | `call` reserves a single word of space with the parameter as value? |
| 2025-09-24 19:31:32 | <[exa]> | as in, you can perfectly do a thunk that contains `fibs, $2, $0, $1` |
| 2025-09-24 19:31:54 | <tomsmeding> | but what will the GC do with a thunk that contains things that are not themselves thunks |
| 2025-09-24 19:32:05 | × | tt12310978324354 quits (~tt1231@2603:6010:8700:4a81:a4f6:acff:fe95:3803) (Quit: The Lounge - https://thelounge.chat) |
| 2025-09-24 19:32:30 | <tomsmeding> | s/`call`/`cell`/ what a dumb typo |
| 2025-09-24 19:32:30 | <[exa]> | nothing, it doesn't know it. You need to make sure the thunk you have there is aware how to clean itself |
| 2025-09-24 19:33:09 | trickard__ | is now known as trickard |
| 2025-09-24 19:33:12 | <[exa]> | I think haskell had at some point a few "types" of thunks based on combination of boxedness of stuff stored in them, e.g. there was 2-param thunk for UU, then BB, UB, BU |
| 2025-09-24 19:33:22 | → | tt12310978324354 joins (~tt1231@2603:6010:8700:4a81:a4f6:acff:fe95:3803) |
| 2025-09-24 19:33:46 | <[exa]> | e.g. this is the object type definition for integers: https://git.e-x-a.org/exa/uskel/src/branch/master/include/data.s#L32-L48 |
| 2025-09-24 19:34:10 | <tomsmeding> | oh I see |
| 2025-09-24 19:34:31 | <tomsmeding> | thunks contain a type tag and each thunk type has a corresponding GC callback ("evacuate") that does the cleanup |
| 2025-09-24 19:34:55 | <tomsmeding> | right, infotables |
| 2025-09-24 19:35:29 | <tomsmeding> | any particular reason why you built this? :p |
| 2025-09-24 19:35:31 | → | olivial joins (~benjaminl@user/benjaminl) |
| 2025-09-24 19:35:32 | <[exa]> | it contains a single unboxed number, evacuate just copies both to the new location (pushq this time), and scavenge doesn't do anything because it doesn't point |
| 2025-09-24 19:35:38 | <[exa]> | lol |
| 2025-09-24 19:35:42 | <[exa]> | no idea |
| 2025-09-24 19:35:51 | → | Googulator20 joins (~Googulato@2a01-036d-0106-0744-4151-2ee3-78cb-4ad2.pool6.digikabel.hu) |
| 2025-09-24 19:35:58 | <[exa]> | ah yeah I made a stupid small prolog before so I wanted to check if this would work |
| 2025-09-24 19:36:16 | <tomsmeding> | sounds like a very good motivation |
| 2025-09-24 19:36:17 | × | Googulator84 quits (~Googulato@2a01-036d-0106-0744-4151-2ee3-78cb-4ad2.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-09-24 19:36:21 | <[exa]> | if bored https://gitea.blesmrt.net/exa/prlg/ |
| 2025-09-24 19:36:35 | <tomsmeding> | why different forge |
| 2025-09-24 19:36:44 | <[exa]> | ah that's the old one |
| 2025-09-24 19:36:45 | <tomsmeding> | p r l g https://gitea.blesmrt.net/exa/prlg/commit/3bfa127cbccbc77bb1b993153d6a6a2db2ec3ee4 |
| 2025-09-24 19:36:48 | <[exa]> | it should be on the new one as well |
| 2025-09-24 19:37:32 | <[exa]> | anyway if you are SUPER BORED |
All times are in UTC.