On Saturday, 16 August 2025 at 14:51:45 UTC, Dmitry Olshansky
wrote:
On Saturday, 16 August 2025 at 09:43:02 UTC, GL wrote:
On Wednesday, 13 August 2025 at 13:28:26 UTC, Dmitry Olshansky
wrote:
I need to think a little more about it but I would likely
ship it in the next release. Soonish :)
Thank you!
I will wait with great impatience...
With new version v0.12.2 basic ZeroMQd example runs fine. Of
other things HTTP server finally scales very well up to 48
cores and is faster than anything I've tried. (see photon-http
0.5.4)
Actually that should be 0.5.5 :)
And v0.13.0 brings new feature - offload to run compute intensive
tasks outside of scheduler. Certain syscalls are automatically
routed through it to avoid blocking fibers such as file I/O. Here
is simple example using goOnSameThread to make sure we are
actually sharing just a single eventloop thread out of many and
yet it doesn't block.
import photon;
double gauss(double a, double b, double function(double) f,
double step) {
double sum = 0.0;
for (double x = a; x < b; x += step) {
sum += (f(x+step) + f(x))/2 * step;
}
return sum;
}
void boom() {
throw new Exception("Boom!");
}
long fib(long n) {
if (n <= 2) return 1;
else {
return offload(() => fib(n-1)) + offload(() => fib(n-2));
}
}
void main() {
startloop();
go({
goOnSameThread({
writeln("Blocking computation");
writeln("Integral:", gauss(0.0, 10.0, x => x*x,
1e-7));
});
goOnSameThread({
writeln("Blocking computation");
writeln("Integral:", gauss(0.0, 10.0, x => x*x,
1e-7));
});
goOnSameThread({
writeln("Nonblocking computation");
writeln("Integral: ", offload(() => gauss(0.0, 10.0,
x => x*x, 1e-7)));
});
goOnSameThread({
writeln("Nonblocking computation");
writeln("Integral: ", offload(() => gauss(0.0, 10.0,
x => x*x, 1e-7)));
});
goOnSameThread({
writeln("Catching exception from offloaded
computation");
try {
offload(&boom);
assert(0);
} catch(Exception e) {
assert(e.msg == "Boom!");
}
});
goOnSameThread({
writeln("Recursive offload");
writeln("Fib(15):", offload(() => fib(15)));
});
});
runFibers();
}
Other photon examples:
https://github.com/DmitryOlshansky/photon/tree/master