|
@@ -482,7 +482,12 @@ grpc::Status DatabaseGrpcImpl::Get(
|
|
|
if (view) {
|
|
if (view) {
|
|
|
nlohmann::json docJson = smartbotic::db::parse_to_nlohmann(protoDoc.data());
|
|
nlohmann::json docJson = smartbotic::db::parse_to_nlohmann(protoDoc.data());
|
|
|
docJson = applyProjection(docJson, view->include, view->exclude);
|
|
docJson = applyProjection(docJson, view->include, view->exclude);
|
|
|
- protoDoc.set_data(docJson.dump());
|
|
|
|
|
|
|
+ // v2.7.1 — yyjson writer, not nlohmann's. Measured on a 2.91 MB
|
|
|
|
|
+ // document: nlohmann dump() 27.5ms vs yyjson 2.5ms. Every other
|
|
|
|
|
+ // response path already goes through to_json_text (via toProto); the
|
|
|
|
|
+ // view branch was the one place still paying 11x for the same bytes.
|
|
|
|
|
+ protoDoc.set_data(smartbotic::db::doc_binary::to_json_text(
|
|
|
|
|
+ smartbotic::db::doc_binary::encode(docJson)));
|
|
|
// Preserve view name as the observed collection
|
|
// Preserve view name as the observed collection
|
|
|
protoDoc.set_collection(request->collection());
|
|
protoDoc.set_collection(request->collection());
|
|
|
}
|
|
}
|
|
@@ -1178,7 +1183,10 @@ grpc::Status DatabaseGrpcImpl::Find(
|
|
|
if (view) {
|
|
if (view) {
|
|
|
nlohmann::json docJson = smartbotic::db::parse_to_nlohmann(protoDoc.data());
|
|
nlohmann::json docJson = smartbotic::db::parse_to_nlohmann(protoDoc.data());
|
|
|
docJson = applyProjection(docJson, view->include, view->exclude);
|
|
docJson = applyProjection(docJson, view->include, view->exclude);
|
|
|
- protoDoc.set_data(docJson.dump());
|
|
|
|
|
|
|
+ // v2.7.1 — see the note on the Get path: yyjson writer is ~11x
|
|
|
|
|
+ // faster than nlohmann dump() on large documents.
|
|
|
|
|
+ protoDoc.set_data(smartbotic::db::doc_binary::to_json_text(
|
|
|
|
|
+ smartbotic::db::doc_binary::encode(docJson)));
|
|
|
// Preserve view name as the observed collection
|
|
// Preserve view name as the observed collection
|
|
|
protoDoc.set_collection(request->collection());
|
|
protoDoc.set_collection(request->collection());
|
|
|
}
|
|
}
|