From 19cd9c4e0b153725016e6468f52302afb96a3519 Mon Sep 17 00:00:00 2001 From: Hellow Date: Thu, 24 Nov 2022 22:10:22 +0100 Subject: [PATCH] modified garbage collection to run a bit less often --- src/music_kraken.egg-info/PKG-INFO | 2 +- src/music_kraken/__init__.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/music_kraken.egg-info/PKG-INFO b/src/music_kraken.egg-info/PKG-INFO index d92fc8a..768f012 100644 --- a/src/music_kraken.egg-info/PKG-INFO +++ b/src/music_kraken.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: music-kraken -Version: 1.2.1 +Version: 1.2.2 Summary: An extensive music downloader crawling the internet. It gets its metadata from a couple metadata provider, and it scrapes the audiofiles. Home-page: https://github.com/HeIIow2/music-downloader Author: Hellow2 diff --git a/src/music_kraken/__init__.py b/src/music_kraken/__init__.py index acd624d..aebb30c 100644 --- a/src/music_kraken/__init__.py +++ b/src/music_kraken/__init__.py @@ -1,3 +1,5 @@ +import gc + from typing import List import musicbrainzngs import logging @@ -17,6 +19,20 @@ from .utils.shared import ( from .lyrics import lyrics +""" +At the start I modify the garbage collector to run a bit fewer times. +This should increase speed: +https://mkennedy.codes/posts/python-gc-settings-change-this-and-make-your-app-go-20pc-faster/ +""" +# Clean up what might be garbage so far. +gc.collect(2) + +allocs, gen1, gen2 = gc.get_threshold() +allocs = 50_000 # Start the GC sequence every 50K not 700 allocations. +gen1 = gen1 * 2 +gen2 = gen2 * 2 +gc.set_threshold(allocs, gen1, gen2) + logging.getLogger("musicbrainzngs").setLevel(logging.WARNING) musicbrainzngs.set_useragent("metadata receiver", "0.1", "https://github.com/HeIIow2/music-downloader")