From 4d2022edfbe876efad7e18a32045e35c69f253f9 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 5 Dec 2023 13:05:51 +0000 Subject: [PATCH 1/3] CI : Update to GafferHQ/dependencies 8.0.0a1 --- .github/workflows/main/installDependencies.py | 2 +- Changes.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main/installDependencies.py b/.github/workflows/main/installDependencies.py index 52b69e46bc2..c4dcaa0953a 100755 --- a/.github/workflows/main/installDependencies.py +++ b/.github/workflows/main/installDependencies.py @@ -48,7 +48,7 @@ # Determine default archive URL. -defaultURL = "https://github.com/ImageEngine/cortex/releases/download/10.5.4.2/cortex-10.5.4.2-{platform}-python3.{extension}".format( +defaultURL = "https://github.com/GafferHQ/dependencies/releases/download/8.0.0a1/gafferDependencies-8.0.0a1-{platform}.{extension}".format( platform = { "darwin" : "osx", "win32" : "windows" }.get( sys.platform, "linux" ), extension = "tar.gz" if sys.platform != "win32" else "zip" ) diff --git a/Changes.md b/Changes.md index 7cf68dbe041..a05060b7038 100644 --- a/Changes.md +++ b/Changes.md @@ -28,6 +28,11 @@ Breaking Changes - Windows launch script : Removed the hardcoded `/debugexe` switch used when `GAFFER_DEBUG` is enabled, making it possible to use debuggers other than Visual Studio. Debug switches can be added to the `GAFFER_DEBUGGER` environment variable instead. - Enums : Replaced `IECore.Enum` types with standard Python types from the `enum` module. +Build +----- + +- PsUtil : Added version 5.9.6. + 1.3.x.x (relative to 1.3.8.0) ======= From 358b7b5b6a0fe759cf496f01b3eef4e3cb7f841a Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 5 Dec 2023 17:37:59 +0000 Subject: [PATCH 2/3] Cache config : Reimplement using `psutil` This means we can also limit usage to 75% of total RAM on Windows. --- startup/Gaffer/cache.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/startup/Gaffer/cache.py b/startup/Gaffer/cache.py index 54065277fd6..238d9fc63ee 100644 --- a/startup/Gaffer/cache.py +++ b/startup/Gaffer/cache.py @@ -34,21 +34,13 @@ # ########################################################################## -import os +import psutil + import Gaffer # Set cache memory limit to 8 gigs, capped at 3/4 of the total # physical memory. -cacheLimit = 1024**3 * 8 # 8 Gigs - -if os.name != "nt" : - physicalMemory = os.sysconf( "SC_PAGE_SIZE" ) * os.sysconf( "SC_PHYS_PAGES" ) - cacheLimit = min( cacheLimit, physicalMemory * 3 // 4 ) -else : - # No native Python API for querying physical memory on Windows. - # And surely nobody is brave enough to use Windows with less - # than 8 gigs ;) - pass - -Gaffer.ValuePlug.setCacheMemoryLimit( cacheLimit ) +Gaffer.ValuePlug.setCacheMemoryLimit( + min( 1024**3 * 8, psutil.virtual_memory().total * 3 // 4 ) +) From ef57c631e696b4054099fd7bff90afffc5814490 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 6 Dec 2023 11:24:57 +0000 Subject: [PATCH 3/3] Stats app : Replace Windows subprocess with `psutil` --- apps/stats/stats-1.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/stats/stats-1.py b/apps/stats/stats-1.py index 0a2fa417476..24c2101cc6f 100644 --- a/apps/stats/stats-1.py +++ b/apps/stats/stats-1.py @@ -45,7 +45,7 @@ if sys.platform != "win32": import resource else: - import subprocess + import psutil import IECore @@ -746,8 +746,7 @@ def maxRSS( cls ) : if sys.platform == "darwin" : return cls( resource.getrusage( resource.RUSAGE_SELF ).ru_maxrss ) elif sys.platform == "win32" : - result = subprocess.check_output( ["wmic", "process", "where", "processid={}".format(os.getpid()), "get", "PeakWorkingSetSize"] ) - return cls( int( result.split()[1] ) * 1024 ) + return cls( psutil.Process().memory_info().peak_wset ) else : return cls( resource.getrusage( resource.RUSAGE_SELF ).ru_maxrss * 1024 )