Log config extractor fixed to make compressed bfbs
If you didn't use MergeConfiguration(), then you didn't get schemas
properly deduplicated in the resulting flatbuffer, causing you to end up
with massively oversized configs.
Change-Id: I45b5eba72d472cff357d5db0e28b72bf430d9ec7
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/log_config_extractor.cc b/aos/events/logging/log_config_extractor.cc
index b7a937d..aa2eed0 100644
--- a/aos/events/logging/log_config_extractor.cc
+++ b/aos/events/logging/log_config_extractor.cc
@@ -29,7 +29,18 @@
namespace aos {
void WriteConfig(const aos::Configuration *config, std::string output_path) {
- auto config_flatbuffer = RecursiveCopyFlatBuffer(config);
+ // In order to deduplicate the reflection schemas in the resulting config
+ // flatbuffer (and thus reduce the size of the final flatbuffer), use
+ // MergeConfiguration() rather than the more generic
+ // RecursiveCopyFlatBuffer(). RecursiveCopyFlatBuffer() is sometimes used to
+ // reduce flatbuffer memory usage, but it only does so by rearranging memory
+ // locations, not by actually deduplicating identical flatbuffers.
+ std::vector<aos::FlatbufferVector<reflection::Schema>> schemas;
+ for (const Channel *c : *config->channels()) {
+ schemas.emplace_back(RecursiveCopyFlatBuffer(c->schema()));
+ }
+ auto config_flatbuffer = configuration::MergeConfiguration(
+ RecursiveCopyFlatBuffer(config), schemas);
if (FLAGS_bfbs) {
WriteFlatbufferToFile(output_path + ".bfbs", config_flatbuffer);