Procházet zdrojové kódy

release(v2.7.1): paging fast path + yyjson writer on the view branch

Swaps the last nlohmann dump() on a response path (the view projection branch
in Get and Find) for doc_binary::to_json_text. Measured on a 2.91 MB document:
nlohmann 27.5ms vs yyjson 2.5ms. Every other response path already went through
to_json_text via toProto; this was the one place paying 11x for the same bytes.

CLAUDE.md records where the time actually goes, measured rather than assumed:
decode 6.25ms + write 4.27ms = 10.5ms to return one 2.91 MB document. Parsing
is not the bottleneck (yyjson does 830 MB/s), so partial decode is not worth
it; the ceiling is not round-tripping at all, since a memcpy of the stored
bytes is free.

ctest 17/17, views e2e green.
fszontagh před 1 měsícem
rodič
revize
97f950f7d3
3 změnil soubory, kde provedl 11 přidání a 3 odebrání
  1. 0 0
      CLAUDE.md
  2. 1 1
      VERSION
  3. 10 2
      service/src/database_grpc_impl.cpp

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
CLAUDE.md


+ 1 - 1
VERSION

@@ -1 +1 @@
-2.7.0
+2.7.1

+ 10 - 2
service/src/database_grpc_impl.cpp

@@ -482,7 +482,12 @@ grpc::Status DatabaseGrpcImpl::Get(
     if (view) {
         nlohmann::json docJson = smartbotic::db::parse_to_nlohmann(protoDoc.data());
         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
         protoDoc.set_collection(request->collection());
     }
@@ -1178,7 +1183,10 @@ grpc::Status DatabaseGrpcImpl::Find(
         if (view) {
             nlohmann::json docJson = smartbotic::db::parse_to_nlohmann(protoDoc.data());
             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
             protoDoc.set_collection(request->collection());
         }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů