On Monday, 3 June 2013 at 18:51:45 UTC, Vladimir Panteleev wrote:
On Monday, 3 June 2013 at 18:07:57 UTC, Diggory wrote:
Great talk! Would love to see the improvements to phobos
suggested.
An idea for the virtual address space problem on 32-bit:
- Assuming each stack has a marker page at the end to prevent
overflow, by simply exchanging the stack memory with a
separate block of memory you can reduce the number of marker
pages saving up to one page per fiber
- Could use some fast compression method to save a not
recently used stack in memory
- As a last resort can save stack to a file and read it in
again when it is required. Since events are queued the event
loop can easily peek ahead in the queue and start loading in a
stack early so that it is ready by the time that event gets to
the front.
Thanks!
One of the main advantages of fibers over threads is the low
overhead for switching - basically you save registers and
change ESP. By comparison, switching to another thread requires
an OS kernel system call. Copying entire stacks might negate
this performance benefit. It's worth noting that it looks like
the average stack size will grow for D programs in the future,
as the push is made to minimize heap allocations throughout
Phobos and use the stack more.
Yes, although it would theoretically be possible to swap the
stack by swapping the mappings rather than the memory itself,
although I doubt many OSes would support that kind of
functionality...
I guess it's not too much to ask to use a 64-bit OS for when
1000s of connections need to be handled!