You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/06/25 13:42:24 UTC

[tomcat] branch 9.0.x updated (1094d17 -> e57d32d)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from 1094d17  Update Graal documentation to reflect changes
     new 61980cd  Add the plumbing to 'recycle' an HTTP/2 Stream
     new e57d32d  Reduce the memory footprint of closed HTTP/2 streams

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/coyote/http2/Stream.java          | 34 ++++++++++++++++++-----
 java/org/apache/coyote/http2/StreamProcessor.java |  3 ++
 webapps/docs/changelog.xml                        |  3 ++
 3 files changed, 33 insertions(+), 7 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Add the plumbing to 'recycle' an HTTP/2 Stream

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 61980cdfdcdada9cd023d30ab5af35010b1e084b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jun 25 11:57:58 2020 +0100

    Add the plumbing to 'recycle' an HTTP/2 Stream
---
 java/org/apache/coyote/http2/Stream.java          | 13 +++++++++++++
 java/org/apache/coyote/http2/StreamProcessor.java |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 65d636d..878fd2f 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -725,6 +725,19 @@ class Stream extends AbstractStream implements HeaderEmitter {
         } else {
             handler.closeConnection(http2Exception);
         }
+        recycle();
+    }
+
+
+    /*
+     * This method is called recycle for consistency with the rest of the Tomcat
+     * code base. Currently, it only sets references to null for the purposes of
+     * reducing memory footprint. It does not fully recycle the Stream ready for
+     * re-use since Stream objects are not re-used.
+     */
+    final void recycle() {
+        // Currently a NO-OP. This will change shortly to address the TODO for
+        // nulling out references.
     }
 
 
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java b/java/org/apache/coyote/http2/StreamProcessor.java
index 80c22ec..2b41753 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -89,6 +89,9 @@ class StreamProcessor extends AbstractProcessor {
                                         stream.getIdAsInt());
                             }
                             stream.close(se);
+                        } else {
+                            // stream.close() will call recycle so only need it here
+                            stream.recycle();
                         }
                     }
                 } catch (Exception e) {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Reduce the memory footprint of closed HTTP/2 streams

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit e57d32d8636811ad26128dab53ca06c71437aa5e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jun 25 14:40:27 2020 +0100

    Reduce the memory footprint of closed HTTP/2 streams
---
 java/org/apache/coyote/http2/Stream.java | 27 +++++++++++++++++----------
 webapps/docs/changelog.xml               |  3 +++
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 878fd2f..1ddf994 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -77,13 +77,15 @@ class Stream extends AbstractStream implements HeaderEmitter {
     // State machine would be too much overhead
     private int headerState = HEADER_STATE_START;
     private StreamException headerException = null;
-    // TODO: null these when finished to reduce memory used by closed stream
-    private final Request coyoteRequest;
-    private StringBuilder cookieHeader = null;
-    private final Response coyoteResponse = new Response();
-    private final StreamInputBuffer inputBuffer;
-    private final StreamOutputBuffer streamOutputBuffer = new StreamOutputBuffer();
-    private final Http2OutputBuffer http2OutputBuffer =
+
+    // These will be set to null once the Stream closes to reduce the memory
+    // footprint.
+    private volatile Request coyoteRequest;
+    private volatile StringBuilder cookieHeader = null;
+    private volatile Response coyoteResponse = new Response();
+    private volatile StreamInputBuffer inputBuffer;
+    private volatile StreamOutputBuffer streamOutputBuffer = new StreamOutputBuffer();
+    private volatile Http2OutputBuffer http2OutputBuffer =
             new Http2OutputBuffer(coyoteResponse, streamOutputBuffer);
 
 
@@ -733,11 +735,16 @@ class Stream extends AbstractStream implements HeaderEmitter {
      * This method is called recycle for consistency with the rest of the Tomcat
      * code base. Currently, it only sets references to null for the purposes of
      * reducing memory footprint. It does not fully recycle the Stream ready for
-     * re-use since Stream objects are not re-used.
+     * re-use since Stream objects are not re-used. This is useful because
+     * Stream instances are retained for a period after the Stream closes.
      */
     final void recycle() {
-        // Currently a NO-OP. This will change shortly to address the TODO for
-        // nulling out references.
+        coyoteRequest = null;
+        cookieHeader = null;
+        coyoteResponse = null;
+        inputBuffer = null;
+        streamOutputBuffer = null;
+        http2OutputBuffer = null;
     }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 52b1a30..dca98a2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -104,6 +104,9 @@
         Once an HTTP/2 stream has been closed, ensure that the code that cleans
         up references that are no longer required is called. (markt)
       </fix>
+      <fix>
+        Reduce the memory footprint of closed HTTP/2 streams. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Other">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org