Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Skip the final GC on shutdown to improve restart times #10712

Merged
merged 3 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10712.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Skip final GC at shutdown to improve restart performance.
7 changes: 7 additions & 0 deletions synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# 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.
import atexit
import gc
import logging
import os
Expand Down Expand Up @@ -403,6 +404,12 @@ def run_sighup(*args, **kwargs):
gc.collect()
gc.freeze()

# Speed up shutdowns by freezing all allocated objects. This moves everything
# into the permanent generation and excludes them from the final GC.
# Unfortunately only works on Python 3.7
if platform.python_implementation() == "CPython" and sys.version_info >= (3, 7):
atexit.register(gc.freeze)


def setup_sentry(hs):
"""Enable sentry integration, if enabled in configuration
Expand Down