envoyproxy / envoyproxy/envoy

Host metadata take up a lot of memory

オープン
#9,532 コメント 13 件 リアクション 0 件 担当者 1 名 @zyfjeff が担当を希望しています GitHub で見る
area/perf area/xds help wanted
主要言語
C++
スター
28.9k
フォーク
5.6k
平均マージ
1日 22時間
マージ済み PR(30日)
430

説明

*Title*: *Host metadata take up a lot of memory*

*Description*:
>Currently, our host metadata use `map` type, because of the use of `google.protobuf.struct`, which contains a lot of type reflection information, which takes up more memory space. Even without any metadata information, an empty object would take up 144 bytes.

The following code is my test

```c++

message Metadata {
// Key is the reverse DNS filter name, e.g. com.acme.widget. The envoy.*
// namespace is reserved for Envoy's built-in filters.
map filter_metadata = 1;
}

tutorial::Metadata meta;
google::protobuf::Struct struct_obj;
auto& fields_map = *struct_obj.mutable_fields();
fields_map["test_key"] = stringValue("test_value");
google::protobuf::Struct struct_inner;
(*struct_inner.mutable_fields())["inner_key"] = stringValue("inner_value");
google::protobuf::Value val;
*val.mutable_struct_value() = struct_inner;
fields_map["test_obj"] = val;
(*meta.mutable_filter_metadata())["com.test"] = struct_obj;

std::cout << meta.SpaceUsedLong() << std::endl;

tutorial::Metadata meta1;
std::cout << "empty:" << meta1.SpaceUsedLong() << std::endl;
```

Output:

```
720
empty:144
```

Is it possible to use a Map instead of a Struct, or to use Any nested Struct instead? In addition, we can actually optimize the default values so that we don't have to build Metadata objects when we don't have any metadata information.

@mattklein123

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。