-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build with Musl libc #682
Conversation
Signed-off-by: Justin Cormack <[email protected]>
Thinking about the different ways we could approach musl support in Snabb Switch:
How about we celebrate the new year by being wild and crazy with option 1? That would be to add musl as our fourth dependency (alongside luajit, ljsyscall, and pflua) and truly ship a statically linked executable that will run on any Linux/x86-64 machine. The first step would be to send a PR that adds musl as a subtree and uses it for the build. This will probably trigger test failures e.g. I'm expecting the NFV application to have a performance regression because the inner loop depends on the libc memcpy to be optimized for packet copy workload (glibc memcpy is, musl memcpy is not). This probably should be resolved in our own code i.e. by having a suitable packet-copy routine of our own instead of depending on non-standard properties of the libc one. I have had a quick look at musl. I appreciate the coding style i.e. really focusing on short and simple code. Compilation time is about 1 minute serially but only 5 seconds in parallel (measured on chur) so we would still hit our compile time targets if we assume I believe there will be more issues e.g. that we can't use Thoughts for/against? anybody willing to take the lead on such an integration e.g. to create a branch that compiles a static executable with musl imported as a git subtree? |
A few thoughts a. A standalone statically linked executable would be really nice, I really appreciate the ease of install of for example Go projects that do this now. So I think it might still be best to split this up into a few different activities even if aim is 1. |
Sounds like a plan! Merged this PR onto next. Here is some data about the packet copy routine for us:
Question then is whether we should write a I have browsed memcpy implementations around the internet (dpdk, libc, musl, etc). The shortest path to a relatively simple and efficient one that matches our needs seems to be to take Agner Fog's design and remove the special cases that are not relevant for us. He seems to have struct a balance between performance and simplicity (well, I say that not having benchmarked it for our use case). See also memcpy odyssey threads on snabb-devel and #648 (Packet copies: Expensive or cheap?). |
Good news re: memcpy is that we do have CI coverage for this. A bad memcpy should impact the performance regression tests for forwarding packets through a DPDK VM. So if that test passes then we probably have a winner. (One weakness of that test is that it is using fixed-size power-of-2 packets. To be more confident of the memcpy we would want to vary the packet sizes. I have done this manually a few times with glibc memcpy and it seems to behave well.) |
One thing that is different is that we write the tests for special cases in Lua so they are inlineable, so we don't need to run the tests at all in a tight loop if they are static. We can also use the built in luajit memcpy (which we could change if it is non optimal). So we need a slightly different test setup. |
LuaJIT only uses its own memcpy for fixed-size objects e.g. structs or constant-size arrays. Otherwise it will emit a call to libc memcpy. (This is much like GCC behavior.) The calls that we have to libc memcpy today are actually |
Minor portability fixes that let Snabb build under Musl libc, tested on Alpine Linux.