perf: throttle OG image generation — nice 19 + 50ms sleep between renders
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
@@ -102,6 +103,7 @@ def _site_rebuild_worker() -> None:
|
|||||||
"--www-root", _webroot],
|
"--www-root", _webroot],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
preexec_fn=lambda: os.nice(19),
|
||||||
)
|
)
|
||||||
if og.returncode != 0:
|
if og.returncode != 0:
|
||||||
log.error("site-rebuild: og-images failed (rc=%d):\n%s\n%s",
|
log.error("site-rebuild: og-images failed (rc=%d):\n%s\n%s",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from __future__ import annotations
|
|||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ def generate_all(data_dir: Path, www_root: Path) -> None:
|
|||||||
out_path.write_bytes(png)
|
out_path.write_bytes(png)
|
||||||
generated += 1
|
generated += 1
|
||||||
u_gen += 1
|
u_gen += 1
|
||||||
|
time.sleep(0.05)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
errors += 1
|
errors += 1
|
||||||
u_err += 1
|
u_err += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user