4 ms·
Have you tried using link-time garbage collection? The library is designed in a layered way, such that the core serialization does not depend on the "dynamic" f
by kentonv 9y ago
Have you tried using link-time garbage collection? The library is designed in a layered way, such that the core serialization does not depend on the "dynamic" features, so if you don't ever call "dynamic" features then link-time GC should be able to drop a huge chunk of the lib.
There's also "lite mode", which #ifdef's out all the dynamic stuff:
./configure --disable-reflection
Although it isn't as aggressive as it could be. We should fix that. I filed an issue:
https://github.com/capnproto/capnproto/issues/634 https://github.com/capnproto/capnproto/issues/634
There is also a C implementation of capnp which I believe is designed for small footprint, FWIW.
- elcritch 9y agoNo I didn’t but that’s good to know. I tried a few attempts but wasn’t sure about how integral the reflection portions were (or if exceptions were crucial). I’d likely just compiled the library on my dev machine and looked at the library size and tried a few flags to get a quick idea if it’d work. It’d be useful to be able to just use the serialization protocol. Currently I’m using MsgPack which works decently well to get data from embedded cores but I’d prefer typed structures. Thanks for the feedback!
- kentonv 9y ago> or if exceptions were crucial Although KJ style prefers exceptions, the library is carefully written (and tested) to work with -fno-exceptions. KJ_ASSERT/KJ_REQUIRE invocations (which normally throw exceptions) can define a fallback path to use in the case that exceptions are disabled, usually involving returning some sort of dummy value. You can also register a per-thread exception callback which will be called on all exceptions before the fallback starts (or before aborting, if there is no fallback).
- elcritch 9y agoThat’s excellent! That certainly makes it seem much more useful for many embedded environments.