You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "moonchen (via GitHub)" <gi...@apache.org> on 2026/06/15 20:17:46 UTC

[PR] compress: count uncompressed input bytes [trafficserver]

moonchen opened a new pull request, #13274:
URL: https://github.com/apache/trafficserver/pull/13274

   Adds proxy.process.plugin.compress.bytes_in, feeding a per-component CPU
   model that attributes plugin User CPU to its workload drivers.
   
   The compress plugin's CPU is dominated by the codec, whose cost scales
   near-linearly with the uncompressed input it is handed -- not with the
   compressed output or the request count.  The plugin runs as a transform
   (TSTransformCreate) rather than over PluginVC, so the core per-plugin byte
   counter never observes this traffic; counting upstream_length at the point
   it is fed to the codec captures it directly.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] compress: count uncompressed input bytes [trafficserver]

Posted by "moonchen (via GitHub)" <gi...@apache.org>.
moonchen closed pull request #13274: compress: count uncompressed input bytes
URL: https://github.com/apache/trafficserver/pull/13274


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] compress: count uncompressed input bytes [trafficserver]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13274:
URL: https://github.com/apache/trafficserver/pull/13274#discussion_r3416329810


##########
plugins/compress/compress.cc:
##########
@@ -349,6 +349,21 @@ compress_transform_init(TSCont contp, Data *data)
   TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
 }
 
+// CPU-model driver for the compress plugin (its CPU lands in the generic 'plugin' bucket): total
+// uncompressed input bytes fed to the codec, the near-linear driver of deflate/gzip/brotli CPU.
+// compress dispatches via TSTransformCreate (not PluginVC), so the core per-plugin byte counter
+// never sees it. Created once at plugin init.
+static int compress_stat_bytes_in = TS_ERROR;
+
+static void
+init_compress_stats()
+{
+  if (TS_ERROR == compress_stat_bytes_in) {
+    compress_stat_bytes_in =
+      TSStatCreate("proxy.process.plugin.compress.bytes_in", TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_COUNT);
+  }
+}

Review Comment:
   Stat initialization uses TSStatCreate() unconditionally with TS_RECORDDATATYPE_INT / TS_STAT_SYNC_COUNT and doesn’t attempt TSStatFindName() first. If the stat already exists (e.g., plugin loaded twice via different paths), TSStatCreate can fail and leave compress_stat_bytes_in as TS_ERROR, so the hot-path increment becomes a no-op. Also, bytes should be registered as a COUNTER with SYNC_SUM to match its semantics.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org