Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
ambonvik
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
5 ms
·
1.
▲
by
ambonvik
7mo ago
Yes, I did actually look at Bunki as well before building this. Liked the imagery. :) What did not quite fit for my purpose was having the asymmetric coroutines as the fundamental layer, meaning that the dispatcher also is tied to that laye
2.
▲
by
ambonvik
8mo ago
I am not familiar with Mojo, so I do not know. Compared to the coroutine implementations I do know, none of them quite met what I as looking for. The «trampoline» has been mentioned. I also needed a calling convention that fit the higher-le
3.
▲
by
ambonvik
8mo ago
They probably do, but I have not used them. My approach has been "offensive programming", to put in asserts for preconditions, invariants, and postconditions wherever possible. If anything starts to smell, I'd like to stop it
4.
▲
by
ambonvik
8mo ago
It is an assembly function that does not get called from anywhere. I pre-load the stack image with its intended register content from C, including the trampoline function address as the "return address". On the first transfer to t
5.
▲
by
ambonvik
8mo ago
Good point. The profiler tells me that the context switch between coroutines is the most time-consuming part, even if I tried to keep it as light as possible, so I guess the explanation for "only" getting 45x speed improvement rat
6.
▲
by
ambonvik
8mo ago
Each coroutine is running on its own stack. They are fixed size stacks, at least for now, so that could be a tender point, but I place some sentinel values at the end to try to capture it in an assert() instead of just letting it crash. I d
7.
▲
by
ambonvik
8mo ago
Hi, it is hand-coded assembly. Pushing all necessary registers to the stack (including GS on Windows), swapping the stack pointer to/from memory, popping the registers, and off we go on the other stack. I save FPU flags, but not more F
8.
▲
by
ambonvik
8mo ago
I would be happy accepting contributions, especially for porting to additional architectures. I think the dependency is relatively well encapsulated (see src/port), but code for additional architectures needs to be well tested on the a
9.
▲
Show HN: C discrete event SIM w stackful coroutines runs 45x faster than SimPy
(github.com)
69 points
by
ambonvik
8mo ago
|
18 comments