This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 07bbf4a6f410965a088bb909509e98c0e9ea6679 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Sep 23 19:59:13 2020 +0100 Reduce memory footprint of closed http/2 streams This refactoring replaces closed streams with a new RecycledStream object and changes the mechanism used to look up known streams. Initial changes to object hierarchy in preparation for further changes. --- .../apache/coyote/http2/AbstractNonZeroStream.java | 29 ++++++++++++ java/org/apache/coyote/http2/AbstractStream.java | 3 +- java/org/apache/coyote/http2/RecycledStream.java | 52 ++++++++++++++++++++++ java/org/apache/coyote/http2/Stream.java | 2 +- 4 files changed, 84 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http2/AbstractNonZeroStream.java b/java/org/apache/coyote/http2/AbstractNonZeroStream.java new file mode 100644 index 0000000..63fb5e7 --- /dev/null +++ b/java/org/apache/coyote/http2/AbstractNonZeroStream.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.coyote.http2; + + +/** + * Base class for all streams other than stream 0, the connection. Primarily + * provides functionality shared between full Stream and RecycledStream. + */ +abstract class AbstractNonZeroStream extends AbstractStream { + + AbstractNonZeroStream(Integer identifier) { + super(identifier); + } +} diff --git a/java/org/apache/coyote/http2/AbstractStream.java b/java/org/apache/coyote/http2/AbstractStream.java index 3e4ec73..9c6054e 100644 --- a/java/org/apache/coyote/http2/AbstractStream.java +++ b/java/org/apache/coyote/http2/AbstractStream.java @@ -25,7 +25,8 @@ import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.res.StringManager; /** - * Used to managed prioritisation. + * Base class for all streams including the connection (referred to as Stream 0) + * and is used primarily when managing prioritization. */ abstract class AbstractStream { diff --git a/java/org/apache/coyote/http2/RecycledStream.java b/java/org/apache/coyote/http2/RecycledStream.java new file mode 100644 index 0000000..4cd3e79 --- /dev/null +++ b/java/org/apache/coyote/http2/RecycledStream.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.coyote.http2; + +/** + * Represents a closed stream in the priority tree. Used in preference to the + * full {@link Stream} as has much lower memory usage. + */ +class RecycledStream extends AbstractNonZeroStream { + + private final String connectionId; + private int weight; + + RecycledStream(Stream stream) { + super(stream.getIdentifier()); + connectionId = stream.getConnectionId(); + weight = stream.getWeight(); + } + + + @Override + protected String getConnectionId() { + return connectionId; + } + + + @Override + protected int getWeight() { + return weight; + } + + + @Override + @Deprecated + protected synchronized void doNotifyAll() { + // NO-OP. Unused. + } +} diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java index b78d55a..d4cfa0d 100644 --- a/java/org/apache/coyote/http2/Stream.java +++ b/java/org/apache/coyote/http2/Stream.java @@ -43,7 +43,7 @@ import org.apache.tomcat.util.net.ApplicationBufferHandler; import org.apache.tomcat.util.net.WriteBuffer; import org.apache.tomcat.util.res.StringManager; -public class Stream extends AbstractStream implements HeaderEmitter { +public class Stream extends AbstractNonZeroStream implements HeaderEmitter { private static final Log log = LogFactory.getLog(Stream.class); private static final StringManager sm = StringManager.getManager(Stream.class); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org