Hacker News new | past | comments | ask | show | jobs | submit login

No, for example Python subprocess lets you talk to the subprocess on stdin and stdout. Lua popen only gives you one of those two things.

This means that the proposed work sharing model at https://benchmarksgame-team.pages.debian.net/benchmarksgame/... cannot be used, because it requires workers to submit results to be aggregated and accept new chunks of work.




Does it mean that none of the other Lua programs could be written to use multicore? spectral-norm?


No, it does not mean that. I'll submit my multicore pfannkuchen-redux and reverse-compliment when I get around to it, and look at other problems after that.

The pfannkuchen-redux is just a bit hampered by uneven work sharing.

For reverse-compliment, it's a bit more trouble to work around the lack of 2-way communication. My implementation writes the entire input to stdout, then workers use fseek on stdout, which only works if you are piping the output of the command to a file. That is, it generates correct output if you run "lua blah.lua > out" but not if you run "lua blah.lua | cat > out" Additionally, since there's no pwrite and no way of getting a new open file description for stdout, I must cobble together a mutual exclusion mechanism to prevent workers from seeking while another worker tries to write.


Just curious, hasn't multicore been enough of an opportunity for this to be addressed by the Lua community?


A design objective of PUC-Rio Lua is to be pure ANSI C. I'm not certain, but my impression is that this imposes some unreasonable restrictions on the implementation. An additional design objective is to be small.

I think people don't usually write Lua programs intending to run them inside the binary you get when you build PUC-Rio Lua without any additional C libraries. Libraries like LPeg and lua-gumbo are Lua wrappers around C code. For C libraries that do not have Lua wrappers, people can more or less paste the preprocessed C header file into their Lua source file and use Luajit's FFI to use the library. This last approach is similar to how the Python regex program mentioned elsewhere in these comments works :). It's also common to use frameworks like Openresty or Love2d that provide the innards of some complex threaded program to user Lua code.

Outside of benchmark games and work, I'm working on some code that uses threads and channels, but the threads and channels are provided by liblove.

So I guess I can say, it has been addressed, but it won't be addressed in the standard library.


> For reverse-compliment…

I hope you're doing that because you think it's fun.


It's a little fun, but mostly I'm doing it because I don't know when to give up.


That's how I feel too. I was kind-of hoping the hardware would fail :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: