[GH-ISSUE #1] perf: test on performance with logging #1

Closed
opened 2026-10-14 09:52:32 +00:00 by allankoech · 5 comments
Owner

Originally created by @allankoechke on GitHub (Jun 19, 2026).
Original GitHub issue: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/issues/1

Current branch uses print statements for logging messages to the MaxScript listener. The print statements are bit too noisy but relevant in debugging process, as such, there's need to evaluate different options for logging these messages and the corresponding perfomance penalty.

Base case: No print statements
Evaluate:

  • writing to /dev/null
  • logging library in Python
  • default sys.stdout for Python
  • etc.

Research Findings

Research conducted: 2026-06-19 | Branch: 1-logging-perf-eval | Commit: 40415ee

Summary

The plugin currently uses 30 print() calls in Python/explode_geometry.py (duplicated in Bundle2/Contents/python/explode_geometry.py). These scale linearly with face count — a 1,000-face mesh triggers ~7,000 print calls, each writing synchronously to the MaxScript Listener (a Scintilla GUI widget on the main thread). The GUI repaint overhead per write is likely 10-100x worse than a plain console print().

Replacing print() with the Python logging module set to WARNING in production reduces per-call cost from ~2.66 us+ (plus GUI repaint) to ~14 ns (a ~190x improvement at minimum, likely 1000x+ when accounting for Listener overhead). This is the recommended approach.

Current State: Print Statement Analysis

Distribution (30 print statements in Python/explode_geometry.py)

Category Location Count Frequency
Header/config dump do_explode() L156-163 8 Once per explode
Error handling do_explode() L167 1 Conditional
Per-object lifecycle do_explode() L173-195 7 O(objects)
Per-face processing (TriMesh) convert_to_triangle_faces() L217-238 5 O(faces)
Per-face processing (MNMesh) convert_to_mnmesh_faces() L242-261 5 O(faces)
Per-face settings applySettings() L265-283 5 O(faces)

Scaling Formula

For S selected objects, each with F faces (all options enabled):

  • Fixed prints: ~10 per operation
  • Per-object prints: ~5 x S
  • Per-face prints: ~7 x S x F
Scenario Print calls Est. overhead (Listener)
1 obj x 100 faces ~710 noticeable lag
1 obj x 1,000 faces ~7,015 multi-second delay likely
5 obj x 1,000 faces ~35,035 severe UI blocking

Hottest Print Statement

Line 227-228 is the most expensive individual print — it formats 11 arguments including 9 float values with {:.2f} precision:

print("[ExplodeGeometry] [TriMesh] Face {}/{}: verts=({:.2f},{:.2f},{:.2f}) ({:.2f},{:.2f},{:.2f}) ({:.2f},{:.2f},{:.2f})".format(
    face_idx, num_faces, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z))

Performance Benchmarks

Per-Call Cost Comparison

Method Per-call cost Relative to print() Notes
print() to console ~2,660 ns 1.0x (baseline) Measured on plain terminal
print() to MaxScript Listener ~2,660 ns + GUI repaint >>1.0x Scintilla widget update, main thread sync
sys.stdout.write() to console ~563 ns 0.21x No newline/sep handling
logging.info() — emitted, handler writes ~600 ns 0.23x Full LogRecord + handler dispatch
logging.debug() — filtered out ~14 ns 0.005x Level-check short-circuit via cached isEnabledFor()
No-op function ~50-80 ns 0.02-0.03x Pure function call overhead
if __debug__: with -O flag ~0 ns 0x Compiled out of bytecode entirely

Lazy vs. Eager Formatting (When Filtered)

Pattern Cost when filtered Why
logger.debug("msg %s", val) (lazy %) ~500 ns String formatting deferred
logger.debug(f"msg {val}") (eager f-string) ~2,200 ns f-string evaluated before level check
logger.debug("msg {}".format(val)) (eager .format()) ~2,200 ns .format() evaluated before level check

With expensive arguments (e.g., computing vertex coords), the difference is 287x between lazy and eager formatting.

3ds Max Specific Considerations

Python print() in 3ds Max

  • sys.stdout is redirected to the MaxScript Listener window (Scintilla-based text control)
  • sys.stderr also goes to the Listener but renders in red text
  • Each print() call is synchronous on the main thread — no buffering/batching
  • Printing from non-main threads crashes 3ds Max (documented by Autodesk)
  • The MacroRecorder (same Scintilla infrastructure) is known to slow down 3ds Max

pymxs.print_() vs Python print()

Aspect print() pymxs.print_()
Output destination sys.stdout (Listener by default) Always to Listener
Affected by stdout redirect Yes No — always goes through MaxScript runtime
Use case General logging When MaxScript print behavior is needed

Python Versions in 3ds Max

3ds Max Python PySide
2025 3.11.4 PySide6 6.5.3
2026 3.11.9 PySide6
2027 3.13.9 PySide6 6.8.3

All versions support the logging module's isEnabledFor() cache optimization (present since Python 3.7+).

Evaluated Approaches (Ranked by Recommendation)

Pattern:

import logging
logger = logging.getLogger("ExplodeGeometry")

# In production: set to WARNING — filtered debug() costs ~14 ns/call
logger.setLevel(logging.WARNING)

# In development: set to DEBUG
# logger.setLevel(logging.DEBUG)

Pros:

  • Near-zero cost when filtered (~14 ns vs ~2,660 ns+ for print)
  • Built-in level filtering (DEBUG, INFO, WARNING, ERROR)
  • Lazy % formatting defers string construction
  • Can route to file handler, Listener, or both
  • Industry standard for Python applications
  • Dual handler: INFO and below to stdout (normal Listener text), WARNING+ to stderr (red Listener text)

Cons:

  • Slight refactoring effort (30 print -> logger calls)
  • Eager .format() calls must be converted to lazy % style

Key implementation note: Use logger.debug("msg %s", arg) not logger.debug(f"msg {arg}") to get the lazy formatting benefit.

2. Write to os.devnull (NUL on Windows)

Pattern:

import sys, os
sys.stdout = open(os.devnull, "w")

Pros:

  • No code changes to print statements
  • Eliminates Listener GUI overhead

Cons:

  • All-or-nothing — no log level filtering
  • Still pays string formatting cost (~2,200 ns with .format())
  • Still pays function call overhead
  • Loses all output including errors
  • No way to selectively enable debug output

3. sys.stdout.write() Directly

Pattern: Replace print(msg) with sys.stdout.write(msg + "\n")

Pros:

  • ~4.7x faster than print() (563 ns vs 2,660 ns)
  • Minimal code changes

Cons:

  • Still writes to Listener (GUI repaint overhead unchanged)
  • Still pays string formatting cost
  • No level filtering
  • Marginal improvement compared to logging approach

4. Module-Level Debug Flag

Pattern:

_DEBUG = False  # Toggle for development

def convert_to_triangle_faces(...):
    if _DEBUG:
        print("[ExplodeGeometry] ...")

Pros:

  • Simple boolean check (~50 ns)
  • Entire print + formatting skipped when False
  • No new dependencies

Cons:

  • Requires manual toggling (no runtime level control)
  • Binary on/off — no level granularity
  • Not standard Python practice

5. if __debug__: Guards with -O Flag

Pattern:

if __debug__:
    logger.debug("Face %d/%d: verts=...", face_idx, num_faces, ...)

Pros:

  • Zero runtime cost — compiled out of bytecode with -O
  • Best possible performance when disabled

Cons:

  • 3ds Max controls the embedded Python interpreter — no documented way to pass -O
  • Not practical for this environment

Files Requiring Changes

File Lines Change
Python/explode_geometry.py 1-295 Replace 30 print() calls with logging module; add logger setup
Bundle2/Contents/python/explode_geometry.py 1-295 Same changes (identical file)
Python/explode_geometry_classic.py 176, 273 Optional: only 2 print statements (legacy MaxPlus, Python 2 syntax)

Implementation Sketch

import logging
import sys

logger = logging.getLogger("ExplodeGeometry")

if not logger.handlers:
    fmt = logging.Formatter("[%(name)s] %(message)s")

    # INFO and below -> stdout -> normal (white) text in Listener
    stdout_handler = logging.StreamHandler(sys.stdout)
    stdout_handler.setLevel(logging.DEBUG)
    stdout_handler.addFilter(lambda r: r.levelno < logging.WARNING)
    stdout_handler.setFormatter(fmt)

    # WARNING and above -> stderr -> red text in Listener
    stderr_handler = logging.StreamHandler(sys.stderr)
    stderr_handler.setLevel(logging.WARNING)
    stderr_handler.setFormatter(fmt)

    logger.addHandler(stdout_handler)
    logger.addHandler(stderr_handler)
    logger.setLevel(logging.WARNING)  # change to DEBUG during development

# Then replace:
#   print("[ExplodeGeometry] [TriMesh] Face {}/{}: ...".format(...))
# With:
#   logger.debug("[TriMesh] Face %d/%d: verts=(%.2f,%.2f,%.2f) ...", face_idx, num_faces, ...)

Benchmark Plan

To get real-world timings inside 3ds Max (not theoretical benchmarks), a perf/ folder will be created containing logging-variant copies of the explode script and a runner that measures wall-clock time end-to-end.

perf/ Folder Structure

perf/
  runner.py                          # orchestrates all variants, reports results
  explode_geometry_print.py          # current state: all 30 print() calls as-is
  explode_geometry_errors_only.py    # base case: only the error print kept (L167), all others removed
  explode_geometry_devnull.py        # sys.stdout redirected to os.devnull
  explode_geometry_logger_all.py     # logging module, level=DEBUG (all messages emitted)
  explode_geometry_logger_info.py    # logging module, level=INFO (debug filtered out)
  explode_geometry_noprint.py        # absolute floor: zero print statements

explode_geometry_errors_only.py retains only the single error-path print at L167:

print("[ExplodeGeometry] ERROR: {}".format(msg))

All 29 debug/info prints are removed. This represents the practical minimum — a shipped plugin that stays silent during normal operation but still surfaces errors to the Listener.

Runner Script Behaviour (runner.py)

For each variant file, the runner:

  1. Clears the scene — rt.resetMaxFile(noPrompt=True) or rt.delete rt.objects
  2. Creates a large cone — enough faces to make logging overhead measurable (e.g., radius1=50, radius2=0, height=100, heightsegs=10, capsegs=5, sides=32)
  3. Runs TriMesh explode with: shell modifier outerAmount=4, delete original=True
  4. Measures wall-clock time — time.perf_counter() before and after the explode call
  5. Clears scene again, recreates cone
  6. Runs MNMesh explode with the same settings and measures time
  7. Repeats steps 1-6 for every variant file

Output Format

| Script variant                  | Explode type | Time (s) |
|---------------------------------|--------------|----------|
| explode_geometry_print          | TriMesh      | x.xxx    |
| explode_geometry_print          | MNMesh       | x.xxx    |
| explode_geometry_errors_only    | TriMesh      | x.xxx    |  <- base case
| explode_geometry_errors_only    | MNMesh       | x.xxx    |  <- base case
| explode_geometry_devnull        | TriMesh      | x.xxx    |
| explode_geometry_devnull        | MNMesh       | x.xxx    |
| explode_geometry_logger_all     | TriMesh      | x.xxx    |
| explode_geometry_logger_all     | MNMesh       | x.xxx    |
| explode_geometry_logger_info    | TriMesh      | x.xxx    |
| explode_geometry_logger_info    | MNMesh       | x.xxx    |
| explode_geometry_noprint        | TriMesh      | x.xxx    |
| explode_geometry_noprint        | MNMesh       | x.xxx    |

Sources


Logging Performance Evaluation Implementation Plan

Overview

Replace the 30 synchronous print() calls in the Explode Geometry plugin with Python's logging module (level=WARNING in production), and run real-world benchmarks inside 3ds Max across all evaluated approaches to validate the expected ~190x-1000x speedup on per-face-count-scaling workloads.

Current State Analysis

Key Discoveries:

  • Python/explode_geometry.py:156-283 — 30 print() calls across 4 functions; all use .format() (eager), meaning string construction happens even if output is discarded
  • Bundle2/Contents/python/explode_geometry.py — identical file; must receive identical changes
  • Python/explode_geometry_classic.py:176,273 — legacy MaxPlus/Python 2 file with only 2 prints; out of scope (Python 2 syntax, max 2021 only)
  • Per-face hotspot at convert_to_triangle_faces():227-228 formats 11 arguments including 9 floats — this single call scales as O(faces) and is the dominant cost driver
  • 3ds Max redirects sys.stdout to the MaxScript Listener (Scintilla GUI widget), making each print() synchronous and blocking on the main thread with GUI repaint overhead
  • logger.debug("msg %s", arg) with level=WARNING costs ~14 ns/call (level-check short-circuit), versus ~2,660 ns+ per print() to Listener — ~190x improvement floor, 1000x+ with GUI overhead factored in
  • Lazy % formatting is essential: logger.debug(f"...") or logger.debug("...".format(...)) still evaluates the string before the level check, negating the benefit

Desired End State

After this branch is complete:

  1. perf/ folder exists with 6 variant scripts and a runner.py that can be executed inside 3ds Max to produce a timing table
  2. Python/explode_geometry.py and Bundle2/Contents/python/explode_geometry.py use the logging module with level=WARNING in production, lazy % formatting, and dual handlers (stdout for INFO and below, stderr for WARNING+)
  3. Benchmark results are recorded (as a comment or in a perf/RESULTS.md) showing measured wall-clock times for each variant on a standardized test mesh

Verification: Running runner.py inside 3ds Max produces a complete timing table with no errors. The logging variant scripts do not emit any output to the MaxScript Listener during normal (non-error) operation.

What We're NOT Doing

  • Modifying Python/explode_geometry_classic.py — legacy MaxPlus/Python 2 file, not used in Max 2022+
  • Adding any UI controls to toggle log level at runtime
  • Redirecting logs to a file on disk (stdout/stderr handlers to the Listener is sufficient)
  • Changing any business logic or geometry processing code
  • Addressing performance issues unrelated to logging

Implementation Approach

Selected approach from research: Python logging module with:

  • Module-level logger: logger = logging.getLogger("ExplodeGeometry")
  • Dual handlers: sys.stdout for DEBUG/INFO (white Listener text), sys.stderr for WARNING+ (red Listener text)
  • Production level: logging.WARNING — all debug/info calls cost ~14 ns (level-check only)
  • All .format() calls converted to lazy % style on debug/info log lines

Benchmarking first (TASK 1) establishes the baseline before modifying production code, so results reflect the actual before/after difference.


IMPORTANT: Checkboxes are for implementation steps only. Steps requiring manual human verification (browser testing, manual QA, visual inspection, staging verification, human review) MUST NOT be checkboxes — place them in the numbered "Manual Testing Steps" section at the bottom of the plan instead.

TASK 1: Create perf/ Benchmarking Folder [HIGH PRIORITY]

Status: NOT STARTED
Milestone: perf/ folder exists with all 6 variant scripts and a working runner.py that can be executed inside 3ds Max to produce a timing comparison table

  • Create perf/ directory at the repository root
  • Create perf/explode_geometry_print.py — copy of the current Python/explode_geometry.py with all 30 print() calls unchanged; this is the "before" baseline
  • Create perf/explode_geometry_errors_only.py — remove all 29 debug/info prints, retain only the single error print at L167 (print("[ExplodeGeometry] ERROR: {}".format(msg))); this is the practical production minimum
  • Create perf/explode_geometry_devnull.py — add import os and redirect sys.stdout = open(os.devnull, "w") at module level before any print calls; all 30 prints remain unchanged
  • Create perf/explode_geometry_logger_all.py — full logging module setup (dual handlers as per the implementation sketch), logger.setLevel(logging.DEBUG) so all 30 messages are emitted; convert all .format() to lazy %
  • Create perf/explode_geometry_logger_info.py — same as logger_all but logger.setLevel(logging.INFO); the per-face debug calls (the O(faces) hotspot) are filtered out, config/lifecycle messages still emitted
  • Create perf/explode_geometry_noprint.py — remove all 30 print statements entirely; no logging setup; this is the theoretical performance floor
  • Create perf/runner.py with the following structure:
    • Import each variant module (using importlib.import_module or exec(open(...).read()) since they share function names)
    • For each variant: (1) clear scene with rt.resetMaxFile(noPrompt=True), (2) create a standard test cone (rt.Cone(radius1=50, radius2=0, height=100, heightsegs=10, capsegs=5, sides=32)), (3) select it with rt.select(cone), (4) call time.perf_counter() before and after the variant's convert_to_triangle_faces() function directly (bypassing GUI), (5) clear scene, recreate cone, (6) repeat for convert_to_mnmesh_faces()
    • Print results as a markdown table: | variant | explode type | time (s) |
    • Use import time for perf_counter()

Validation: Running runner.py inside the 3ds Max Python listener (e.g., via pasting into the listener) produces a complete table with 12 data rows and no import errors.

Requirements from spec:

  • Cover all evaluated options: print (baseline), errors_only, devnull, logger_all, logger_info, noprint
  • Measure both TriMesh and MNMesh paths for each variant
  • Use wall-clock time (time.perf_counter()) on a standardized test mesh inside 3ds Max

Files to Create:

  • perf/runner.py — orchestrator that imports each variant and runs timing measurements
  • perf/explode_geometry_print.py — baseline: all 30 prints as-is
  • perf/explode_geometry_errors_only.py — 29 prints removed, 1 error print retained
  • perf/explode_geometry_devnull.py — stdout redirected to os.devnull, prints unchanged
  • perf/explode_geometry_logger_all.py — logging module, level=DEBUG, all messages emitted
  • perf/explode_geometry_logger_info.py — logging module, level=INFO, per-face debug filtered
  • perf/explode_geometry_noprint.py — zero prints, no logging

TASK 2: Migrate Python/explode_geometry.py to logging module [HIGH PRIORITY]

Status: NOT STARTED
Milestone: All 30 print() calls replaced with logger.*() calls using lazy % formatting; logger setup at module level with dual handlers; production level set to WARNING

  • Add import logging and import sys to the imports section (after the existing import random at L12)
  • Add the logger setup block after rt = pymxs.runtime (around L13), using an if not logger.handlers: guard to prevent duplicate handlers on script reload:
    • Create logger = logging.getLogger("ExplodeGeometry")
    • Add stdout handler for DEBUG/INFO (white Listener text) with addFilter(lambda r: r.levelno < logging.WARNING)
    • Add stderr handler for WARNING+ (red Listener text)
    • Set logger.setLevel(logging.WARNING) for production
  • Replace L156-163 (8 header/config prints in do_explode()) with logger.debug() calls using %s lazy formatting
  • Replace L167 (error print) with logger.warning("ERROR: %s", msg) so it routes to stderr (red Listener text)
  • Replace L173 (Processing N object(s)) with logger.debug("[TriMesh] Processing %d object(s)", len(transformation_set))
  • Replace L175 (Object i/N: name) with logger.debug("[TriMesh] Object %d/%d: %s", i, len(transformation_set), n.name)
  • Replace L180 (Deleting original) with logger.debug("[TriMesh] Deleting original %s", n.name)
  • Replace L185 ([MNMesh] Processing) with logger.debug("[MNMesh] Processing %d object(s)", len(transformation_set))
  • Replace L187 ([MNMesh] Object i/N) with logger.debug("[MNMesh] Object %d/%d: %s", i, len(transformation_set), node.name)
  • Replace L192 ([MNMesh] Deleting) with logger.debug("[MNMesh] Deleting original %s", node.name)
  • Replace L195 (Done. Redrawing views.) with logger.info("Done. Redrawing views.")
  • Replace L217 (Converting to mesh) with logger.debug("[TriMesh] Converting %s to mesh...", node.name)
  • Replace L221 (has N face(s)) with logger.debug("[TriMesh] %s has %d face(s) to explode", node.name, num_faces)
  • Replace L227-228 (hottest per-face print with 11 args including 9 floats) with logger.debug("[TriMesh] Face %d/%d: verts=(%.2f,%.2f,%.2f) (%.2f,%.2f,%.2f) (%.2f,%.2f,%.2f)", face_idx, num_faces, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z) — lazy % means vertex coords are NOT read/formatted when level=WARNING
  • Replace L234 (Created piece) with logger.debug("[TriMesh] Created piece %s for face %d", new_node.name, face_idx)
  • Replace L238 (Finished exploding) with logger.debug("[TriMesh] Finished exploding %s", node.name)
  • Replace L242 ([Poly] Converting) with logger.debug("[Poly] Converting %s to poly...", node.name)
  • Replace L245 ([Poly] has N face(s)) with logger.debug("[Poly] %s has %d face(s) to explode", node.name, num_faces)
  • Replace L251 (Detaching face) with logger.debug("[Poly] Detaching face %d/%d", face_idx, num_faces)
  • Replace L256 (WARNING: Could not find detached node) with logger.warning("[Poly] WARNING: Could not find detached node for face %d", face_idx) — routes to stderr (red text)
  • Replace L259 (Created piece) with logger.debug("[Poly] Created piece %s for face %d", new_node.name, face_idx)
  • Replace L261 (Finished exploding) with logger.debug("[Poly] Finished exploding %s", node.name)
  • Replace L265-266 (applySettings summary) with logger.debug("applySettings on %s: shell=%s (amt=%s) editMesh=%s collapse=%s centerPivot=%s", n.name, addShell, shell_amount, addEditMesh, collapseNode, centerPivot)
  • Replace L268 (Adding Shell modifier) with logger.debug("Adding Shell modifier (outerAmount=%s)", shell_amount)
  • Replace L274 (Adding Edit Mesh modifier) with logger.debug("Adding Edit Mesh modifier")
  • Replace L279 (Collapsing modifier stack) with logger.debug("Collapsing modifier stack")
  • Replace L283 (Centering pivot) with logger.debug("Centering pivot")

Validation: After editing, grep -c "print(" Python/explode_geometry.py returns 0. The file parses cleanly: python -c "import ast; ast.parse(open('Python/explode_geometry.py').read()); print('OK')" returns OK.

Requirements from spec:

  • All 30 print() calls converted — none may remain
  • Use lazy % formatting (not f-strings or .format()) on all logger calls
  • WARNING-level calls use logger.warning() to route to stderr (red Listener text)
  • Logger setup must be idempotent (use if not logger.handlers: guard) to survive script reload in 3ds Max
  • Production level must be logging.WARNING so normal operation emits nothing to the Listener

Files to Modify:

  • Python/explode_geometry.py — add logger setup, replace all 30 print() calls

TASK 3: Sync Bundle2/Contents/python/explode_geometry.py [MEDIUM PRIORITY]

Status: NOT STARTED
Milestone: Bundle2/Contents/python/explode_geometry.py is identical to the updated Python/explode_geometry.py

  • Apply all identical changes from TASK 2 to Bundle2/Contents/python/explode_geometry.py (the file is currently identical to Python/explode_geometry.py, so the same set of edits applies line-for-line)
  • Verify the two files are identical after edits: diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py should produce no output

Validation: diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py exits 0 with no output.

Requirements from spec:

  • Both distribution paths must be kept in sync
  • No functional differences between the two files

Files to Modify:

  • Bundle2/Contents/python/explode_geometry.py — identical changes as TASK 2

TASK 4: Run Benchmarks and Record Results [MEDIUM PRIORITY]

Status: NOT STARTED
Milestone: Real benchmark results from inside 3ds Max are documented, confirming the logging module approach shows the expected performance improvement

  • Load perf/runner.py in 3ds Max (e.g., drag-drop into viewport or paste into the Python listener: exec(open(r"perf/runner.py").read()))
  • Capture the output timing table from the MaxScript Listener
  • Create perf/RESULTS.md with the captured table, the test mesh parameters (cone: radius1=50, radius2=0, height=100, heightsegs=10, capsegs=5, sides=32), and the 3ds Max version used
  • Verify explode_geometry_logger_info and explode_geometry_noprint show meaningfully faster times than explode_geometry_print for both TriMesh and MNMesh paths

Validation: perf/RESULTS.md exists and contains a 12-row table. The logger_info and noprint variants show measurably faster times than the print baseline for TriMesh on the standard test mesh.

Requirements from spec:

  • Cover TriMesh and MNMesh for all 6 variants
  • Run inside 3ds Max (not a plain terminal) to capture real Listener overhead
  • Record the 3ds Max version and test mesh geometry for reproducibility

Files to Create:

  • perf/RESULTS.md — captured timing table with test environment details

Testing Strategy

Unit Tests:

  • python -c "import ast; ast.parse(open('Python/explode_geometry.py').read()); print('OK')" — syntax validation
  • grep -c "print(" Python/explode_geometry.py must return 0
  • grep -c "print(" Bundle2/Contents/python/explode_geometry.py must return 0
  • diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py must return no diff

Integration Tests:

  • All 6 perf variant scripts parse without error (ast.parse on each)
  • runner.py executes inside 3ds Max without exceptions and prints a complete 12-row table

Manual Testing Steps:

  1. Open 3ds Max, create a cone with ~200 faces, run the Explode Geometry plugin with the updated Python/explode_geometry.py — verify the MaxScript Listener shows NO output during a successful explode (production level=WARNING filters all debug/info)
  2. Temporarily set logger.setLevel(logging.DEBUG) in the script, re-run — verify all the familiar debug messages appear in white text in the Listener (confirming the handler wiring is correct)
  3. Select nothing and click Explode — verify the error message appears in red text in the Listener (confirms WARNING routes to stderr handler)
  4. Run perf/runner.py inside 3ds Max and verify the table is printed with 12 rows covering all 6 variants x 2 mesh types, with no exceptions

Performance Considerations

  • The primary goal of this branch is to measure and document the performance difference — the perf variant scripts should faithfully reproduce each approach without optimization tricks that would skew results
  • For the production logging migration (TASKs 2 & 3), the key invariant is lazy % formatting on every logger.debug() call — eager f-strings or .format() on filtered calls would eliminate the ~190x speedup and revert to near-print() cost
  • The if not logger.handlers: guard is critical in 3ds Max since scripts are often re-executed in the same Python session; without it, each reload doubles the handler count and doubles Listener writes
Originally created by @allankoechke on GitHub (Jun 19, 2026). Original GitHub issue: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/issues/1 Current branch uses print statements for logging messages to the MaxScript listener. The print statements are bit too noisy but relevant in debugging process, as such, there's need to evaluate different options for logging these messages and the corresponding perfomance penalty. Base case: No print statements Evaluate: - writing to `/dev/null` - `logging` library in Python - default `sys.stdout` for Python - etc. --- <details> <summary><h2>Research Findings</h2></summary> _Research conducted: 2026-06-19 | Branch: `1-logging-perf-eval` | Commit: `40415ee`_ ### Summary The plugin currently uses **30 `print()` calls** in `Python/explode_geometry.py` (duplicated in `Bundle2/Contents/python/explode_geometry.py`). These scale linearly with face count — a 1,000-face mesh triggers **~7,000 print calls**, each writing synchronously to the MaxScript Listener (a Scintilla GUI widget on the main thread). The GUI repaint overhead per write is likely 10-100x worse than a plain console `print()`. Replacing `print()` with the Python `logging` module set to `WARNING` in production reduces per-call cost from **~2.66 us+ (plus GUI repaint)** to **~14 ns** (a ~190x improvement at minimum, likely 1000x+ when accounting for Listener overhead). This is the recommended approach. ### Current State: Print Statement Analysis #### Distribution (30 print statements in `Python/explode_geometry.py`) | Category | Location | Count | Frequency | |----------|----------|-------|-----------| | Header/config dump | `do_explode()` L156-163 | 8 | Once per explode | | Error handling | `do_explode()` L167 | 1 | Conditional | | Per-object lifecycle | `do_explode()` L173-195 | 7 | O(objects) | | Per-face processing (TriMesh) | `convert_to_triangle_faces()` L217-238 | 5 | O(faces) | | Per-face processing (MNMesh) | `convert_to_mnmesh_faces()` L242-261 | 5 | O(faces) | | Per-face settings | `applySettings()` L265-283 | 5 | O(faces) | #### Scaling Formula For **S** selected objects, each with **F** faces (all options enabled): - **Fixed prints**: ~10 per operation - **Per-object prints**: ~5 x S - **Per-face prints**: ~7 x S x F | Scenario | Print calls | Est. overhead (Listener) | |----------|-------------|--------------------------| | 1 obj x 100 faces | ~710 | noticeable lag | | 1 obj x 1,000 faces | ~7,015 | multi-second delay likely | | 5 obj x 1,000 faces | ~35,035 | severe UI blocking | #### Hottest Print Statement Line 227-228 is the most expensive individual print — it formats **11 arguments** including **9 float values** with `{:.2f}` precision: ```python print("[ExplodeGeometry] [TriMesh] Face {}/{}: verts=({:.2f},{:.2f},{:.2f}) ({:.2f},{:.2f},{:.2f}) ({:.2f},{:.2f},{:.2f})".format( face_idx, num_faces, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z)) ``` ### Performance Benchmarks #### Per-Call Cost Comparison | Method | Per-call cost | Relative to print() | Notes | |--------|--------------|---------------------|-------| | `print()` to console | ~2,660 ns | 1.0x (baseline) | Measured on plain terminal | | `print()` to MaxScript Listener | ~2,660 ns **+ GUI repaint** | **>>1.0x** | Scintilla widget update, main thread sync | | `sys.stdout.write()` to console | ~563 ns | 0.21x | No newline/sep handling | | `logging.info()` — emitted, handler writes | ~600 ns | 0.23x | Full LogRecord + handler dispatch | | `logging.debug()` — **filtered out** | **~14 ns** | **0.005x** | Level-check short-circuit via cached `isEnabledFor()` | | No-op function | ~50-80 ns | 0.02-0.03x | Pure function call overhead | | `if __debug__:` with `-O` flag | **~0 ns** | **0x** | Compiled out of bytecode entirely | #### Lazy vs. Eager Formatting (When Filtered) | Pattern | Cost when filtered | Why | |---------|-------------------|-----| | `logger.debug("msg %s", val)` (lazy %) | ~500 ns | String formatting deferred | | `logger.debug(f"msg {val}")` (eager f-string) | ~2,200 ns | f-string evaluated **before** level check | | `logger.debug("msg {}".format(val))` (eager .format()) | ~2,200 ns | .format() evaluated **before** level check | **With expensive arguments** (e.g., computing vertex coords), the difference is **287x** between lazy and eager formatting. ### 3ds Max Specific Considerations #### Python `print()` in 3ds Max - `sys.stdout` is redirected to the MaxScript Listener window (Scintilla-based text control) - `sys.stderr` also goes to the Listener but renders in **red text** - Each `print()` call is **synchronous on the main thread** — no buffering/batching - Printing from non-main threads **crashes 3ds Max** (documented by Autodesk) - The MacroRecorder (same Scintilla infrastructure) is known to slow down 3ds Max #### `pymxs.print_()` vs Python `print()` | Aspect | `print()` | `pymxs.print_()` | |--------|-----------|-------------------| | Output destination | `sys.stdout` (Listener by default) | Always to Listener | | Affected by stdout redirect | Yes | **No** — always goes through MaxScript runtime | | Use case | General logging | When MaxScript print behavior is needed | #### Python Versions in 3ds Max | 3ds Max | Python | PySide | |---------|--------|--------| | 2025 | 3.11.4 | PySide6 6.5.3 | | 2026 | 3.11.9 | PySide6 | | 2027 | 3.13.9 | PySide6 6.8.3 | All versions support the `logging` module's `isEnabledFor()` cache optimization (present since Python 3.7+). ### Evaluated Approaches (Ranked by Recommendation) #### 1. Python `logging` Module (Recommended) **Pattern:** ```python import logging logger = logging.getLogger("ExplodeGeometry") # In production: set to WARNING — filtered debug() costs ~14 ns/call logger.setLevel(logging.WARNING) # In development: set to DEBUG # logger.setLevel(logging.DEBUG) ``` **Pros:** - Near-zero cost when filtered (~14 ns vs ~2,660 ns+ for print) - Built-in level filtering (DEBUG, INFO, WARNING, ERROR) - Lazy `%` formatting defers string construction - Can route to file handler, Listener, or both - Industry standard for Python applications - Dual handler: INFO and below to stdout (normal Listener text), WARNING+ to stderr (red Listener text) **Cons:** - Slight refactoring effort (30 print -> logger calls) - Eager `.format()` calls must be converted to lazy `%` style **Key implementation note:** Use `logger.debug("msg %s", arg)` not `logger.debug(f"msg {arg}")` to get the lazy formatting benefit. #### 2. Write to `os.devnull` (NUL on Windows) **Pattern:** ```python import sys, os sys.stdout = open(os.devnull, "w") ``` **Pros:** - No code changes to print statements - Eliminates Listener GUI overhead **Cons:** - All-or-nothing — no log level filtering - Still pays string formatting cost (~2,200 ns with .format()) - Still pays function call overhead - Loses all output including errors - No way to selectively enable debug output #### 3. `sys.stdout.write()` Directly **Pattern:** Replace `print(msg)` with `sys.stdout.write(msg + "\n")` **Pros:** - ~4.7x faster than print() (563 ns vs 2,660 ns) - Minimal code changes **Cons:** - Still writes to Listener (GUI repaint overhead unchanged) - Still pays string formatting cost - No level filtering - Marginal improvement compared to logging approach #### 4. Module-Level Debug Flag **Pattern:** ```python _DEBUG = False # Toggle for development def convert_to_triangle_faces(...): if _DEBUG: print("[ExplodeGeometry] ...") ``` **Pros:** - Simple boolean check (~50 ns) - Entire print + formatting skipped when False - No new dependencies **Cons:** - Requires manual toggling (no runtime level control) - Binary on/off — no level granularity - Not standard Python practice #### 5. `if __debug__:` Guards with `-O` Flag **Pattern:** ```python if __debug__: logger.debug("Face %d/%d: verts=...", face_idx, num_faces, ...) ``` **Pros:** - **Zero runtime cost** — compiled out of bytecode with `-O` - Best possible performance when disabled **Cons:** - 3ds Max controls the embedded Python interpreter — **no documented way to pass `-O`** - Not practical for this environment ### Files Requiring Changes | File | Lines | Change | |------|-------|--------| | `Python/explode_geometry.py` | 1-295 | Replace 30 `print()` calls with `logging` module; add logger setup | | `Bundle2/Contents/python/explode_geometry.py` | 1-295 | Same changes (identical file) | | `Python/explode_geometry_classic.py` | 176, 273 | Optional: only 2 `print` statements (legacy MaxPlus, Python 2 syntax) | ### Implementation Sketch ```python import logging import sys logger = logging.getLogger("ExplodeGeometry") if not logger.handlers: fmt = logging.Formatter("[%(name)s] %(message)s") # INFO and below -> stdout -> normal (white) text in Listener stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler.setLevel(logging.DEBUG) stdout_handler.addFilter(lambda r: r.levelno < logging.WARNING) stdout_handler.setFormatter(fmt) # WARNING and above -> stderr -> red text in Listener stderr_handler = logging.StreamHandler(sys.stderr) stderr_handler.setLevel(logging.WARNING) stderr_handler.setFormatter(fmt) logger.addHandler(stdout_handler) logger.addHandler(stderr_handler) logger.setLevel(logging.WARNING) # change to DEBUG during development # Then replace: # print("[ExplodeGeometry] [TriMesh] Face {}/{}: ...".format(...)) # With: # logger.debug("[TriMesh] Face %d/%d: verts=(%.2f,%.2f,%.2f) ...", face_idx, num_faces, ...) ``` ### Benchmark Plan To get real-world timings inside 3ds Max (not theoretical benchmarks), a `perf/` folder will be created containing logging-variant copies of the explode script and a runner that measures wall-clock time end-to-end. #### `perf/` Folder Structure ``` perf/ runner.py # orchestrates all variants, reports results explode_geometry_print.py # current state: all 30 print() calls as-is explode_geometry_errors_only.py # base case: only the error print kept (L167), all others removed explode_geometry_devnull.py # sys.stdout redirected to os.devnull explode_geometry_logger_all.py # logging module, level=DEBUG (all messages emitted) explode_geometry_logger_info.py # logging module, level=INFO (debug filtered out) explode_geometry_noprint.py # absolute floor: zero print statements ``` `explode_geometry_errors_only.py` retains only the single error-path print at L167: ```python print("[ExplodeGeometry] ERROR: {}".format(msg)) ``` All 29 debug/info prints are removed. This represents the practical minimum — a shipped plugin that stays silent during normal operation but still surfaces errors to the Listener. #### Runner Script Behaviour (`runner.py`) For each variant file, the runner: 1. **Clears the scene** — `rt.resetMaxFile(noPrompt=True)` or `rt.delete rt.objects` 2. **Creates a large cone** — enough faces to make logging overhead measurable (e.g., radius1=50, radius2=0, height=100, heightsegs=10, capsegs=5, sides=32) 3. **Runs TriMesh explode** with: shell modifier `outerAmount=4`, delete original=True 4. **Measures wall-clock time** — `time.perf_counter()` before and after the explode call 5. **Clears scene again**, recreates cone 6. **Runs MNMesh explode** with the same settings and measures time 7. **Repeats steps 1-6** for every variant file #### Output Format ``` | Script variant | Explode type | Time (s) | |---------------------------------|--------------|----------| | explode_geometry_print | TriMesh | x.xxx | | explode_geometry_print | MNMesh | x.xxx | | explode_geometry_errors_only | TriMesh | x.xxx | <- base case | explode_geometry_errors_only | MNMesh | x.xxx | <- base case | explode_geometry_devnull | TriMesh | x.xxx | | explode_geometry_devnull | MNMesh | x.xxx | | explode_geometry_logger_all | TriMesh | x.xxx | | explode_geometry_logger_all | MNMesh | x.xxx | | explode_geometry_logger_info | TriMesh | x.xxx | | explode_geometry_logger_info | MNMesh | x.xxx | | explode_geometry_noprint | TriMesh | x.xxx | | explode_geometry_noprint | MNMesh | x.xxx | ``` ### Sources - [Autodesk: What's New in 3ds Max Python](https://help.autodesk.com/cloudhelp/2027/ENU/MAXDEV-Python/files/MAXDEV_Python_what_s_new_in_3ds_max_python_api_html.html) - [Autodesk: Python API Introduction — stdout/stderr redirection](https://help.autodesk.com/cloudhelp/2016/ENU/Max-Python-API/files/GUID-B3FF3632-F177-4A90-AE3D-D36603B7A2F3.htm) - [Autodesk: MAXScript Listener Window (Scintilla-based)](https://help.autodesk.com/view/MAXDEV/2024/ENU/?guid=GUID-81403EB7-94F8-4EAA-8026-1A495343AE06) - [Microsoft picologging benchmarks](https://github.com/microsoft/picologging) — stdlib per-call timings - [ParselTongue: print vs sys.stdout.write](https://parseltongue.co.in/print-vs-sysstdoutwrite/) — 1M iteration comparison - [Python Logging Benchmark (rmsol.de)](https://rmsol.de/2019/09/08/Logging-Benchmark/) — formatting style comparison - [CPython logging source](https://github.com/python/cpython/blob/main/Lib/logging/__init__.py) — isEnabledFor() cache - [ShotGrid tk-3dsmax engine.py](https://github.com/shotgunsoftware/tk-3dsmax/blob/master/engine.py) — production logging pattern </details> --- <!-- kiln:plan --> # Logging Performance Evaluation Implementation Plan ## Overview Replace the 30 synchronous `print()` calls in the Explode Geometry plugin with Python's `logging` module (level=WARNING in production), and run real-world benchmarks inside 3ds Max across all evaluated approaches to validate the expected ~190x-1000x speedup on per-face-count-scaling workloads. ## Current State Analysis ### Key Discoveries: - `Python/explode_geometry.py:156-283` — 30 `print()` calls across 4 functions; all use `.format()` (eager), meaning string construction happens even if output is discarded - `Bundle2/Contents/python/explode_geometry.py` — identical file; must receive identical changes - `Python/explode_geometry_classic.py:176,273` — legacy MaxPlus/Python 2 file with only 2 prints; out of scope (Python 2 syntax, max 2021 only) - Per-face hotspot at `convert_to_triangle_faces():227-228` formats 11 arguments including 9 floats — this single call scales as O(faces) and is the dominant cost driver - 3ds Max redirects `sys.stdout` to the MaxScript Listener (Scintilla GUI widget), making each `print()` synchronous and blocking on the main thread with GUI repaint overhead - `logger.debug("msg %s", arg)` with level=WARNING costs ~14 ns/call (level-check short-circuit), versus ~2,660 ns+ per `print()` to Listener — ~190x improvement floor, 1000x+ with GUI overhead factored in - Lazy `%` formatting is essential: `logger.debug(f"...")` or `logger.debug("...".format(...))` still evaluates the string before the level check, negating the benefit ## Desired End State After this branch is complete: 1. `perf/` folder exists with 6 variant scripts and a `runner.py` that can be executed inside 3ds Max to produce a timing table 2. `Python/explode_geometry.py` and `Bundle2/Contents/python/explode_geometry.py` use the `logging` module with level=WARNING in production, lazy `%` formatting, and dual handlers (stdout for INFO and below, stderr for WARNING+) 3. Benchmark results are recorded (as a comment or in a `perf/RESULTS.md`) showing measured wall-clock times for each variant on a standardized test mesh **Verification**: Running `runner.py` inside 3ds Max produces a complete timing table with no errors. The logging variant scripts do not emit any output to the MaxScript Listener during normal (non-error) operation. ## What We're NOT Doing - Modifying `Python/explode_geometry_classic.py` — legacy MaxPlus/Python 2 file, not used in Max 2022+ - Adding any UI controls to toggle log level at runtime - Redirecting logs to a file on disk (stdout/stderr handlers to the Listener is sufficient) - Changing any business logic or geometry processing code - Addressing performance issues unrelated to logging ## Implementation Approach **Selected approach from research**: Python `logging` module with: - Module-level logger: `logger = logging.getLogger("ExplodeGeometry")` - Dual handlers: `sys.stdout` for DEBUG/INFO (white Listener text), `sys.stderr` for WARNING+ (red Listener text) - Production level: `logging.WARNING` — all debug/info calls cost ~14 ns (level-check only) - All `.format()` calls converted to lazy `%` style on debug/info log lines Benchmarking first (TASK 1) establishes the baseline before modifying production code, so results reflect the actual before/after difference. --- **IMPORTANT: Checkboxes are for implementation steps only.** Steps requiring manual human verification (browser testing, manual QA, visual inspection, staging verification, human review) MUST NOT be checkboxes — place them in the numbered "Manual Testing Steps" section at the bottom of the plan instead. ### TASK 1: Create perf/ Benchmarking Folder [HIGH PRIORITY] **Status:** NOT STARTED **Milestone:** `perf/` folder exists with all 6 variant scripts and a working `runner.py` that can be executed inside 3ds Max to produce a timing comparison table - [ ] Create `perf/` directory at the repository root - [ ] Create `perf/explode_geometry_print.py` — copy of the current `Python/explode_geometry.py` with all 30 `print()` calls unchanged; this is the "before" baseline - [ ] Create `perf/explode_geometry_errors_only.py` — remove all 29 debug/info prints, retain only the single error print at L167 (`print("[ExplodeGeometry] ERROR: {}".format(msg))`); this is the practical production minimum - [ ] Create `perf/explode_geometry_devnull.py` — add `import os` and redirect `sys.stdout = open(os.devnull, "w")` at module level before any print calls; all 30 prints remain unchanged - [ ] Create `perf/explode_geometry_logger_all.py` — full `logging` module setup (dual handlers as per the implementation sketch), `logger.setLevel(logging.DEBUG)` so all 30 messages are emitted; convert all `.format()` to lazy `%` - [ ] Create `perf/explode_geometry_logger_info.py` — same as logger_all but `logger.setLevel(logging.INFO)`; the per-face debug calls (the O(faces) hotspot) are filtered out, config/lifecycle messages still emitted - [ ] Create `perf/explode_geometry_noprint.py` — remove all 30 print statements entirely; no logging setup; this is the theoretical performance floor - [ ] Create `perf/runner.py` with the following structure: - Import each variant module (using `importlib.import_module` or `exec(open(...).read())` since they share function names) - For each variant: (1) clear scene with `rt.resetMaxFile(noPrompt=True)`, (2) create a standard test cone (`rt.Cone(radius1=50, radius2=0, height=100, heightsegs=10, capsegs=5, sides=32)`), (3) select it with `rt.select(cone)`, (4) call `time.perf_counter()` before and after the variant's `convert_to_triangle_faces()` function directly (bypassing GUI), (5) clear scene, recreate cone, (6) repeat for `convert_to_mnmesh_faces()` - Print results as a markdown table: `| variant | explode type | time (s) |` - Use `import time` for `perf_counter()` **Validation:** Running `runner.py` inside the 3ds Max Python listener (e.g., via pasting into the listener) produces a complete table with 12 data rows and no import errors. **Requirements from spec:** - Cover all evaluated options: print (baseline), errors_only, devnull, logger_all, logger_info, noprint - Measure both TriMesh and MNMesh paths for each variant - Use wall-clock time (`time.perf_counter()`) on a standardized test mesh inside 3ds Max **Files to Create:** - `perf/runner.py` — orchestrator that imports each variant and runs timing measurements - `perf/explode_geometry_print.py` — baseline: all 30 prints as-is - `perf/explode_geometry_errors_only.py` — 29 prints removed, 1 error print retained - `perf/explode_geometry_devnull.py` — stdout redirected to os.devnull, prints unchanged - `perf/explode_geometry_logger_all.py` — logging module, level=DEBUG, all messages emitted - `perf/explode_geometry_logger_info.py` — logging module, level=INFO, per-face debug filtered - `perf/explode_geometry_noprint.py` — zero prints, no logging --- ### TASK 2: Migrate Python/explode_geometry.py to logging module [HIGH PRIORITY] **Status:** NOT STARTED **Milestone:** All 30 `print()` calls replaced with `logger.*()` calls using lazy `%` formatting; logger setup at module level with dual handlers; production level set to WARNING - [ ] Add `import logging` and `import sys` to the imports section (after the existing `import random` at L12) - [ ] Add the logger setup block after `rt = pymxs.runtime` (around L13), using an `if not logger.handlers:` guard to prevent duplicate handlers on script reload: - Create `logger = logging.getLogger("ExplodeGeometry")` - Add stdout handler for DEBUG/INFO (white Listener text) with `addFilter(lambda r: r.levelno < logging.WARNING)` - Add stderr handler for WARNING+ (red Listener text) - Set `logger.setLevel(logging.WARNING)` for production - [ ] Replace L156-163 (8 header/config prints in `do_explode()`) with `logger.debug()` calls using `%s` lazy formatting - [ ] Replace L167 (error print) with `logger.warning("ERROR: %s", msg)` so it routes to stderr (red Listener text) - [ ] Replace L173 (`Processing N object(s)`) with `logger.debug("[TriMesh] Processing %d object(s)", len(transformation_set))` - [ ] Replace L175 (`Object i/N: name`) with `logger.debug("[TriMesh] Object %d/%d: %s", i, len(transformation_set), n.name)` - [ ] Replace L180 (`Deleting original`) with `logger.debug("[TriMesh] Deleting original %s", n.name)` - [ ] Replace L185 (`[MNMesh] Processing`) with `logger.debug("[MNMesh] Processing %d object(s)", len(transformation_set))` - [ ] Replace L187 (`[MNMesh] Object i/N`) with `logger.debug("[MNMesh] Object %d/%d: %s", i, len(transformation_set), node.name)` - [ ] Replace L192 (`[MNMesh] Deleting`) with `logger.debug("[MNMesh] Deleting original %s", node.name)` - [ ] Replace L195 (`Done. Redrawing views.`) with `logger.info("Done. Redrawing views.")` - [ ] Replace L217 (`Converting to mesh`) with `logger.debug("[TriMesh] Converting %s to mesh...", node.name)` - [ ] Replace L221 (`has N face(s)`) with `logger.debug("[TriMesh] %s has %d face(s) to explode", node.name, num_faces)` - [ ] Replace L227-228 (hottest per-face print with 11 args including 9 floats) with `logger.debug("[TriMesh] Face %d/%d: verts=(%.2f,%.2f,%.2f) (%.2f,%.2f,%.2f) (%.2f,%.2f,%.2f)", face_idx, num_faces, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z)` — lazy `%` means vertex coords are NOT read/formatted when level=WARNING - [ ] Replace L234 (`Created piece`) with `logger.debug("[TriMesh] Created piece %s for face %d", new_node.name, face_idx)` - [ ] Replace L238 (`Finished exploding`) with `logger.debug("[TriMesh] Finished exploding %s", node.name)` - [ ] Replace L242 (`[Poly] Converting`) with `logger.debug("[Poly] Converting %s to poly...", node.name)` - [ ] Replace L245 (`[Poly] has N face(s)`) with `logger.debug("[Poly] %s has %d face(s) to explode", node.name, num_faces)` - [ ] Replace L251 (`Detaching face`) with `logger.debug("[Poly] Detaching face %d/%d", face_idx, num_faces)` - [ ] Replace L256 (`WARNING: Could not find detached node`) with `logger.warning("[Poly] WARNING: Could not find detached node for face %d", face_idx)` — routes to stderr (red text) - [ ] Replace L259 (`Created piece`) with `logger.debug("[Poly] Created piece %s for face %d", new_node.name, face_idx)` - [ ] Replace L261 (`Finished exploding`) with `logger.debug("[Poly] Finished exploding %s", node.name)` - [ ] Replace L265-266 (`applySettings` summary) with `logger.debug("applySettings on %s: shell=%s (amt=%s) editMesh=%s collapse=%s centerPivot=%s", n.name, addShell, shell_amount, addEditMesh, collapseNode, centerPivot)` - [ ] Replace L268 (`Adding Shell modifier`) with `logger.debug("Adding Shell modifier (outerAmount=%s)", shell_amount)` - [ ] Replace L274 (`Adding Edit Mesh modifier`) with `logger.debug("Adding Edit Mesh modifier")` - [ ] Replace L279 (`Collapsing modifier stack`) with `logger.debug("Collapsing modifier stack")` - [ ] Replace L283 (`Centering pivot`) with `logger.debug("Centering pivot")` **Validation:** After editing, `grep -c "print(" Python/explode_geometry.py` returns 0. The file parses cleanly: `python -c "import ast; ast.parse(open('Python/explode_geometry.py').read()); print('OK')"` returns OK. **Requirements from spec:** - All 30 print() calls converted — none may remain - Use lazy `%` formatting (not f-strings or `.format()`) on all logger calls - WARNING-level calls use `logger.warning()` to route to stderr (red Listener text) - Logger setup must be idempotent (use `if not logger.handlers:` guard) to survive script reload in 3ds Max - Production level must be `logging.WARNING` so normal operation emits nothing to the Listener **Files to Modify:** - `Python/explode_geometry.py` — add logger setup, replace all 30 print() calls --- ### TASK 3: Sync Bundle2/Contents/python/explode_geometry.py [MEDIUM PRIORITY] **Status:** NOT STARTED **Milestone:** `Bundle2/Contents/python/explode_geometry.py` is identical to the updated `Python/explode_geometry.py` - [ ] Apply all identical changes from TASK 2 to `Bundle2/Contents/python/explode_geometry.py` (the file is currently identical to `Python/explode_geometry.py`, so the same set of edits applies line-for-line) - [ ] Verify the two files are identical after edits: `diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py` should produce no output **Validation:** `diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py` exits 0 with no output. **Requirements from spec:** - Both distribution paths must be kept in sync - No functional differences between the two files **Files to Modify:** - `Bundle2/Contents/python/explode_geometry.py` — identical changes as TASK 2 --- ### TASK 4: Run Benchmarks and Record Results [MEDIUM PRIORITY] **Status:** NOT STARTED **Milestone:** Real benchmark results from inside 3ds Max are documented, confirming the logging module approach shows the expected performance improvement - [ ] Load `perf/runner.py` in 3ds Max (e.g., drag-drop into viewport or paste into the Python listener: `exec(open(r"perf/runner.py").read())`) - [ ] Capture the output timing table from the MaxScript Listener - [ ] Create `perf/RESULTS.md` with the captured table, the test mesh parameters (cone: radius1=50, radius2=0, height=100, heightsegs=10, capsegs=5, sides=32), and the 3ds Max version used - [ ] Verify `explode_geometry_logger_info` and `explode_geometry_noprint` show meaningfully faster times than `explode_geometry_print` for both TriMesh and MNMesh paths **Validation:** `perf/RESULTS.md` exists and contains a 12-row table. The logger_info and noprint variants show measurably faster times than the print baseline for TriMesh on the standard test mesh. **Requirements from spec:** - Cover TriMesh and MNMesh for all 6 variants - Run inside 3ds Max (not a plain terminal) to capture real Listener overhead - Record the 3ds Max version and test mesh geometry for reproducibility **Files to Create:** - `perf/RESULTS.md` — captured timing table with test environment details --- ## Testing Strategy ### Unit Tests: - `python -c "import ast; ast.parse(open('Python/explode_geometry.py').read()); print('OK')"` — syntax validation - `grep -c "print(" Python/explode_geometry.py` must return 0 - `grep -c "print(" Bundle2/Contents/python/explode_geometry.py` must return 0 - `diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py` must return no diff ### Integration Tests: - All 6 perf variant scripts parse without error (`ast.parse` on each) - `runner.py` executes inside 3ds Max without exceptions and prints a complete 12-row table ### Manual Testing Steps: 1. Open 3ds Max, create a cone with ~200 faces, run the Explode Geometry plugin with the updated `Python/explode_geometry.py` — verify the MaxScript Listener shows NO output during a successful explode (production level=WARNING filters all debug/info) 2. Temporarily set `logger.setLevel(logging.DEBUG)` in the script, re-run — verify all the familiar debug messages appear in white text in the Listener (confirming the handler wiring is correct) 3. Select nothing and click Explode — verify the error message appears in red text in the Listener (confirms WARNING routes to stderr handler) 4. Run `perf/runner.py` inside 3ds Max and verify the table is printed with 12 rows covering all 6 variants x 2 mesh types, with no exceptions ## Performance Considerations - The primary goal of this branch is to measure and document the performance difference — the perf variant scripts should faithfully reproduce each approach without optimization tricks that would skew results - For the production logging migration (TASKs 2 & 3), the key invariant is lazy `%` formatting on every `logger.debug()` call — eager f-strings or `.format()` on filtered calls would eliminate the ~190x speedup and revert to near-print() cost - The `if not logger.handlers:` guard is critical in 3ds Max since scripts are often re-executed in the same Python session; without it, each reload doubles the handler count and doubles Listener writes <!-- /kiln:plan -->
allankoech added the
kiln
plan_ready
research_ready
pr_ready
cleaned_up
labels 2026-10-14 09:52:32 +00:00
Author
Owner

@allankoechke commented on GitHub (Jun 19, 2026):

Listener buffer limits: No documentation found on whether the MaxScript Listener has a maximum buffer size or auto-truncation. Very large output volumes may have additional undocumented behavior. NO documentation for this

Actual Listener overhead: No official Autodesk benchmark exists for per-write Listener cost. The GUI repaint overhead on top of Python's print() overhead is inferred from architecture but not quantified. NO docs on this

PYTHONOPTIMIZE in 3ds Max: Whether setting this environment variable before launching 3ds Max works (and what side effects it has) needs testing. No need

Benchmark in 3ds Max: A microbenchmark running inside 3ds Max (e.g., 10,000 print calls vs logging calls) would provide real-world numbers for the Listener overhead specifically. This could be done as part of the implementation PR.NO need

Dual handler pattern: Should INFO and below go to stdout (normal text) and WARNING+ go to stderr (red text) in the Listener? This is a UX decision. YES


Here's the plan:

  • Generate a runner script that will clear the scene, create a big cone, invoke the explode methods (first with tri object then polyobject) with shell modifier added of size 4 and original object deleted after the operation.
  • this script should measure time from when we start to end of the explode cycle
  • the script runs on each logging type, see below
  • finally, printout the log time for each type (script log type and explode type [tri/mnmesh])

For the scripts to implement the logging types, create a new folder perf/, in which we'll copy the explode geometry file for every log type we need to test out. That is,

-> for print statments as is, the file stays as is
-> for logging library logger, have explode_geometry_logger.py in which the print statements have been converted to logging calls. This needs to be run twice, once with logging level permitting all and next with logging level only allowing info and above calls
-> etc.

<!-- gh-comment-id:4752499039 --> @allankoechke commented on GitHub (Jun 19, 2026): Listener buffer limits: No documentation found on whether the MaxScript Listener has a maximum buffer size or auto-truncation. Very large output volumes may have additional undocumented behavior. NO documentation for this Actual Listener overhead: No official Autodesk benchmark exists for per-write Listener cost. The GUI repaint overhead on top of Python's print() overhead is inferred from architecture but not quantified. NO docs on this PYTHONOPTIMIZE in 3ds Max: Whether setting this environment variable before launching 3ds Max works (and what side effects it has) needs testing. No need Benchmark in 3ds Max: A microbenchmark running inside 3ds Max (e.g., 10,000 print calls vs logging calls) would provide real-world numbers for the Listener overhead specifically. This could be done as part of the implementation PR.NO need Dual handler pattern: Should INFO and below go to stdout (normal text) and WARNING+ go to stderr (red text) in the Listener? This is a UX decision. YES ---------------------------------- Here's the plan: - Generate a runner script that will clear the scene, create a big cone, invoke the explode methods (first with tri object then polyobject) with shell modifier added of size 4 and original object deleted after the operation. - this script should measure time from when we start to end of the explode cycle - the script runs on each logging type, see below - finally, printout the log time for each type (script log type and explode type [tri/mnmesh]) For the scripts to implement the logging types, create a new folder `perf/`, in which we'll copy the explode geometry file for every log type we need to test out. That is, -> for print statments as is, the file stays as is -> for logging library logger, have explode_geometry_logger.py in which the print statements have been converted to logging calls. This needs to be run twice, once with logging level permitting all and next with logging level only allowing info and above calls -> etc.
Author
Owner

@allankoechke commented on GitHub (Jun 19, 2026):

Applied changes to research:

Diff
@@ -116,7 +116,7 @@
 - Lazy `%` formatting defers string construction
 - Can route to file handler, Listener, or both
 - Industry standard for Python applications
-- stderr handler -> red text in Listener for warnings/errors
+- Dual handler: INFO and below to stdout (normal Listener text), WARN
+ING+ to stderr (red Listener text)
 
 **Cons:**
 - Slight refactoring effort (30 print -> logger calls)
@@ -192,7 +192,6 @@
 
 **Cons:**
 - 3ds Max controls the embedded Python interpreter — **no documente
 d way to pass `-O`**
-- Setting `PYTHONOPTIMIZE=1` env var before launching Max is untested
- and may break Max internals (removes all `assert` statements)
 - Not practical for this environment
 
 ### Files Requiring Changes
@@ -207,30 +206,79 @@
 
 ```python
 import logging
+import sys
 
 logger = logging.getLogger("ExplodeGeometry")
 
-# Default to WARNING in production (filtered debug costs ~14 ns)
 if not logger.handlers:
-    handler = logging.StreamHandler()  # -> Listener via sys.stderr (
-red for warnings)
-    handler.setFormatter(logging.Formatter("[%(name)s] %(message)s"))
-    logger.addHandler(handler)
-    logger.setLevel(logging.WARNING)
+    fmt = logging.Formatter("[%(name)s] %(message)s")
 
+    # INFO and below -> stdout -> normal (white) text in Listener
+    stdout_handler = logging.StreamHandler(sys.stdout)
+    stdout_handler.setLevel(logging.DEBUG)
+    stdout_handler.addFilter(lambda r: r.levelno < logging.WARNING)
+    stdout_handler.setFormatter(fmt)
+
+    # WARNING and above -> stderr -> red text in Listener
+    stderr_handler = logging.StreamHandler(sys.stderr)
+    stderr_handler.setLevel(logging.WARNING)
+    stderr_handler.setFormatter(fmt)
+
+    logger.addHandler(stdout_handler)
+    logger.addHandler(stderr_handler)
+    logger.setLevel(logging.WARNING)  # change to DEBUG during develo
+pment
+
 # Then replace:
 #   print("[ExplodeGeometry] [TriMesh] Face {}/{}: ...".format(...))
 # With:
 #   logger.debug("[TriMesh] Face %d/%d: verts=(%.2f,%.2f,%.2f) ...", 
 face_idx, num_faces, ...)
 ```
 
-### Open Questions
+### Benchmark Plan
 
-1. **Listener buffer limits**: No documentation found on whether the 
-MaxScript Listener has a maximum buffer size or auto-truncation. Very
- large output volumes may have additional undocumented behavior.
-2. **Actual Listener overhead**: No official Autodesk benchmark exist
-s for per-write Listener cost. The GUI repaint overhead on top of Pyt
-hon's print() overhead is inferred from architecture but not quantifi
-ed.
-3. **`PYTHONOPTIMIZE` in 3ds Max**: Whether setting this environment 
-variable before launching 3ds Max works (and what side effects it has
-) needs testing.
-4. **Benchmark in 3ds Max**: A microbenchmark running inside 3ds Max 
-(e.g., 10,000 print calls vs logging calls) would provide real-world 
-numbers for the Listener overhead specifically. This could be done as
- part of the implementation PR.
-5. **Dual handler pattern**: Should INFO and below go to stdout (norm
-al text) and WARNING+ go to stderr (red text) in the Listener? This i
-s a UX decision.
+To get real-world timings inside 3ds Max (not theoretical benchmarks)
+, a `perf/` folder will be created containing logging-variant copies 
+of the explode script and a runner that measures wall-clock time end-
+to-end.
 
+#### `perf/` Folder Structure
+
+```
+perf/
+  runner.py                        # orchestrates all variants, repor
+ts results
+  explode_geometry_print.py        # base case: print() as-is
+  explode_geometry_devnull.py      # sys.stdout redirected to os.devn
+ull
+  explode_geometry_logger_all.py   # logging module, level=DEBUG (all
+ messages emitted)
+  explode_geometry_logger_info.py  # logging module, level=INFO (debu
+g filtered out)
+  explode_geometry_noprint.py      # base case: no print statements a
+t all
+```
+
+#### Runner Script Behaviour (`runner.py`)
+
+For each variant file, the runner:
+
+1. **Clears the scene** — `rt.resetMaxFile(noPrompt=True)` or `rt.d
+elete rt.objects`
+2. **Creates a large cone** — enough faces to make logging overhead
+ measurable (e.g., radius1=50, radius2=0, height=100, heightsegs=10, 
+capsegs=5, sides=32)
+3. **Runs TriMesh explode** with: shell modifier `outerAmount=4`, del
+ete original=True
+4. **Measures wall-clock time** — `time.perf_counter()` before and 
+after the explode call
+5. **Clears scene again**, recreates cone
+6. **Runs MNMesh explode** with the same settings and measures time
+7. **Repeats steps 1-6** for every variant file
+
+#### Output Format
+
+```
+| Script variant              | Explode type | Time (s) |
+|-----------------------------|--------------|----------|
+| explode_geometry_print      | TriMesh      | x.xxx    |
+| explode_geometry_print      | MNMesh       | x.xxx    |
+| explode_geometry_devnull    | TriMesh      | x.xxx    |
+| explode_geometry_devnull    | MNMesh       | x.xxx    |
+| explode_geometry_logger_all | TriMesh      | x.xxx    |
+| explode_geometry_logger_all | MNMesh       | x.xxx    |
+| explode_geometry_logger_info| TriMesh      | x.xxx    |
+| explode_geometry_logger_info| MNMesh       | x.xxx    |
+| explode_geometry_noprint    | TriMesh      | x.xxx    |
+| explode_geometry_noprint    | MNMesh       | x.xxx    |
+```
+
 ### Sources
 
 - [Autodesk: What's New in 3ds Max Python](https://help.autodesk.com/
 cloudhelp/2027/ENU/MAXDEV-Python/files/MAXDEV_Python_what_s_new_in_3d
 s_max_python_api_html.html)
<!-- gh-comment-id:4752518963 --> @allankoechke commented on GitHub (Jun 19, 2026): <!-- kiln:response --> Applied changes to **research**: <details> <summary>Diff</summary> <pre lang="diff"> @@ -116,7 +116,7 @@ - Lazy `%` formatting defers string construction - Can route to file handler, Listener, or both - Industry standard for Python applications -- stderr handler -&gt; red text in Listener for warnings/errors +- Dual handler: INFO and below to stdout (normal Listener text), WARN +ING+ to stderr (red Listener text) **Cons:** - Slight refactoring effort (30 print -&gt; logger calls) @@ -192,7 +192,6 @@ **Cons:** - 3ds Max controls the embedded Python interpreter — **no documente d way to pass `-O`** -- Setting `PYTHONOPTIMIZE=1` env var before launching Max is untested - and may break Max internals (removes all `assert` statements) - Not practical for this environment ### Files Requiring Changes @@ -207,30 +206,79 @@ ```python import logging +import sys logger = logging.getLogger(&#34;ExplodeGeometry&#34;) -# Default to WARNING in production (filtered debug costs ~14 ns) if not logger.handlers: - handler = logging.StreamHandler() # -&gt; Listener via sys.stderr ( -red for warnings) - handler.setFormatter(logging.Formatter(&#34;[%(name)s] %(message)s&#34;)) - logger.addHandler(handler) - logger.setLevel(logging.WARNING) + fmt = logging.Formatter(&#34;[%(name)s] %(message)s&#34;) + # INFO and below -&gt; stdout -&gt; normal (white) text in Listener + stdout_handler = logging.StreamHandler(sys.stdout) + stdout_handler.setLevel(logging.DEBUG) + stdout_handler.addFilter(lambda r: r.levelno &lt; logging.WARNING) + stdout_handler.setFormatter(fmt) + + # WARNING and above -&gt; stderr -&gt; red text in Listener + stderr_handler = logging.StreamHandler(sys.stderr) + stderr_handler.setLevel(logging.WARNING) + stderr_handler.setFormatter(fmt) + + logger.addHandler(stdout_handler) + logger.addHandler(stderr_handler) + logger.setLevel(logging.WARNING) # change to DEBUG during develo +pment + # Then replace: # print(&#34;[ExplodeGeometry] [TriMesh] Face {}/{}: ...&#34;.format(...)) # With: # logger.debug(&#34;[TriMesh] Face %d/%d: verts=(%.2f,%.2f,%.2f) ...&#34;, face_idx, num_faces, ...) ``` -### Open Questions +### Benchmark Plan -1. **Listener buffer limits**: No documentation found on whether the -MaxScript Listener has a maximum buffer size or auto-truncation. Very - large output volumes may have additional undocumented behavior. -2. **Actual Listener overhead**: No official Autodesk benchmark exist -s for per-write Listener cost. The GUI repaint overhead on top of Pyt -hon&#39;s print() overhead is inferred from architecture but not quantifi -ed. -3. **`PYTHONOPTIMIZE` in 3ds Max**: Whether setting this environment -variable before launching 3ds Max works (and what side effects it has -) needs testing. -4. **Benchmark in 3ds Max**: A microbenchmark running inside 3ds Max -(e.g., 10,000 print calls vs logging calls) would provide real-world -numbers for the Listener overhead specifically. This could be done as - part of the implementation PR. -5. **Dual handler pattern**: Should INFO and below go to stdout (norm -al text) and WARNING+ go to stderr (red text) in the Listener? This i -s a UX decision. +To get real-world timings inside 3ds Max (not theoretical benchmarks) +, a `perf/` folder will be created containing logging-variant copies +of the explode script and a runner that measures wall-clock time end- +to-end. +#### `perf/` Folder Structure + +``` +perf/ + runner.py # orchestrates all variants, repor +ts results + explode_geometry_print.py # base case: print() as-is + explode_geometry_devnull.py # sys.stdout redirected to os.devn +ull + explode_geometry_logger_all.py # logging module, level=DEBUG (all + messages emitted) + explode_geometry_logger_info.py # logging module, level=INFO (debu +g filtered out) + explode_geometry_noprint.py # base case: no print statements a +t all +``` + +#### Runner Script Behaviour (`runner.py`) + +For each variant file, the runner: + +1. **Clears the scene** — `rt.resetMaxFile(noPrompt=True)` or `rt.d +elete rt.objects` +2. **Creates a large cone** — enough faces to make logging overhead + measurable (e.g., radius1=50, radius2=0, height=100, heightsegs=10, +capsegs=5, sides=32) +3. **Runs TriMesh explode** with: shell modifier `outerAmount=4`, del +ete original=True +4. **Measures wall-clock time** — `time.perf_counter()` before and +after the explode call +5. **Clears scene again**, recreates cone +6. **Runs MNMesh explode** with the same settings and measures time +7. **Repeats steps 1-6** for every variant file + +#### Output Format + +``` +| Script variant | Explode type | Time (s) | +|-----------------------------|--------------|----------| +| explode_geometry_print | TriMesh | x.xxx | +| explode_geometry_print | MNMesh | x.xxx | +| explode_geometry_devnull | TriMesh | x.xxx | +| explode_geometry_devnull | MNMesh | x.xxx | +| explode_geometry_logger_all | TriMesh | x.xxx | +| explode_geometry_logger_all | MNMesh | x.xxx | +| explode_geometry_logger_info| TriMesh | x.xxx | +| explode_geometry_logger_info| MNMesh | x.xxx | +| explode_geometry_noprint | TriMesh | x.xxx | +| explode_geometry_noprint | MNMesh | x.xxx | +``` + ### Sources - [Autodesk: What&#39;s New in 3ds Max Python](https://help.autodesk.com/ cloudhelp/2027/ENU/MAXDEV-Python/files/MAXDEV_Python_what_s_new_in_3d s_max_python_api_html.html) </pre> </details> <!-- /kiln:response -->
Author
Owner

@allankoechke commented on GitHub (Jun 19, 2026):

Add an instance where there are no print statements unless for erros, this could be our base case

<!-- gh-comment-id:4752596711 --> @allankoechke commented on GitHub (Jun 19, 2026): Add an instance where there are no print statements unless for erros, this could be our base case
Author
Owner

@allankoechke commented on GitHub (Jun 19, 2026):

Applied changes to research:

Diff
@@ -242,14 +242,21 @@
 
 ```
 perf/
-  runner.py                        # orchestrates all variants, repor
-ts results
-  explode_geometry_print.py        # base case: print() as-is
-  explode_geometry_devnull.py      # sys.stdout redirected to os.devn
-ull
-  explode_geometry_logger_all.py   # logging module, level=DEBUG (all
- messages emitted)
-  explode_geometry_logger_info.py  # logging module, level=INFO (debu
-g filtered out)
-  explode_geometry_noprint.py      # base case: no print statements a
-t all
+  runner.py                          # orchestrates all variants, rep
+orts results
+  explode_geometry_print.py          # current state: all 30 print() 
+calls as-is
+  explode_geometry_errors_only.py    # base case: only the error prin
+t kept (L167), all others removed
+  explode_geometry_devnull.py        # sys.stdout redirected to os.de
+vnull
+  explode_geometry_logger_all.py     # logging module, level=DEBUG (a
+ll messages emitted)
+  explode_geometry_logger_info.py    # logging module, level=INFO (de
+bug filtered out)
+  explode_geometry_noprint.py        # absolute floor: zero print sta
+tements
 ```
 
+`explode_geometry_errors_only.py` retains only the single error-path 
+print at L167:
+```python
+print("[ExplodeGeometry] ERROR: {}".format(msg))
+```
+All 29 debug/info prints are removed. This represents the practical m
+inimum — a shipped plugin that stays silent during normal operation
+ but still surfaces errors to the Listener.
+
 #### Runner Script Behaviour (`runner.py`)
 
 For each variant file, the runner:
@@ -265,18 +272,20 @@
 #### Output Format
 
 ```
-| Script variant              | Explode type | Time (s) |
-|-----------------------------|--------------|----------|
-| explode_geometry_print      | TriMesh      | x.xxx    |
-| explode_geometry_print      | MNMesh       | x.xxx    |
-| explode_geometry_devnull    | TriMesh      | x.xxx    |
-| explode_geometry_devnull    | MNMesh       | x.xxx    |
-| explode_geometry_logger_all | TriMesh      | x.xxx    |
-| explode_geometry_logger_all | MNMesh       | x.xxx    |
-| explode_geometry_logger_info| TriMesh      | x.xxx    |
-| explode_geometry_logger_info| MNMesh       | x.xxx    |
-| explode_geometry_noprint    | TriMesh      | x.xxx    |
-| explode_geometry_noprint    | MNMesh       | x.xxx    |
+| Script variant                  | Explode type | Time (s) |
+|---------------------------------|--------------|----------|
+| explode_geometry_print          | TriMesh      | x.xxx    |
+| explode_geometry_print          | MNMesh       | x.xxx    |
+| explode_geometry_errors_only    | TriMesh      | x.xxx    |  <- bas
+e case
+| explode_geometry_errors_only    | MNMesh       | x.xxx    |  <- bas
+e case
+| explode_geometry_devnull        | TriMesh      | x.xxx    |
+| explode_geometry_devnull        | MNMesh       | x.xxx    |
+| explode_geometry_logger_all     | TriMesh      | x.xxx    |
+| explode_geometry_logger_all     | MNMesh       | x.xxx    |
+| explode_geometry_logger_info    | TriMesh      | x.xxx    |
+| explode_geometry_logger_info    | MNMesh       | x.xxx    |
+| explode_geometry_noprint        | TriMesh      | x.xxx    |
+| explode_geometry_noprint        | MNMesh       | x.xxx    |
 ```
 
 ### Sources
<!-- gh-comment-id:4752660304 --> @allankoechke commented on GitHub (Jun 19, 2026): <!-- kiln:response --> Applied changes to **research**: <details> <summary>Diff</summary> <pre lang="diff"> @@ -242,14 +242,21 @@ ``` perf/ - runner.py # orchestrates all variants, repor -ts results - explode_geometry_print.py # base case: print() as-is - explode_geometry_devnull.py # sys.stdout redirected to os.devn -ull - explode_geometry_logger_all.py # logging module, level=DEBUG (all - messages emitted) - explode_geometry_logger_info.py # logging module, level=INFO (debu -g filtered out) - explode_geometry_noprint.py # base case: no print statements a -t all + runner.py # orchestrates all variants, rep +orts results + explode_geometry_print.py # current state: all 30 print() +calls as-is + explode_geometry_errors_only.py # base case: only the error prin +t kept (L167), all others removed + explode_geometry_devnull.py # sys.stdout redirected to os.de +vnull + explode_geometry_logger_all.py # logging module, level=DEBUG (a +ll messages emitted) + explode_geometry_logger_info.py # logging module, level=INFO (de +bug filtered out) + explode_geometry_noprint.py # absolute floor: zero print sta +tements ``` +`explode_geometry_errors_only.py` retains only the single error-path +print at L167: +```python +print(&#34;[ExplodeGeometry] ERROR: {}&#34;.format(msg)) +``` +All 29 debug/info prints are removed. This represents the practical m +inimum — a shipped plugin that stays silent during normal operation + but still surfaces errors to the Listener. + #### Runner Script Behaviour (`runner.py`) For each variant file, the runner: @@ -265,18 +272,20 @@ #### Output Format ``` -| Script variant | Explode type | Time (s) | -|-----------------------------|--------------|----------| -| explode_geometry_print | TriMesh | x.xxx | -| explode_geometry_print | MNMesh | x.xxx | -| explode_geometry_devnull | TriMesh | x.xxx | -| explode_geometry_devnull | MNMesh | x.xxx | -| explode_geometry_logger_all | TriMesh | x.xxx | -| explode_geometry_logger_all | MNMesh | x.xxx | -| explode_geometry_logger_info| TriMesh | x.xxx | -| explode_geometry_logger_info| MNMesh | x.xxx | -| explode_geometry_noprint | TriMesh | x.xxx | -| explode_geometry_noprint | MNMesh | x.xxx | +| Script variant | Explode type | Time (s) | +|---------------------------------|--------------|----------| +| explode_geometry_print | TriMesh | x.xxx | +| explode_geometry_print | MNMesh | x.xxx | +| explode_geometry_errors_only | TriMesh | x.xxx | &lt;- bas +e case +| explode_geometry_errors_only | MNMesh | x.xxx | &lt;- bas +e case +| explode_geometry_devnull | TriMesh | x.xxx | +| explode_geometry_devnull | MNMesh | x.xxx | +| explode_geometry_logger_all | TriMesh | x.xxx | +| explode_geometry_logger_all | MNMesh | x.xxx | +| explode_geometry_logger_info | TriMesh | x.xxx | +| explode_geometry_logger_info | MNMesh | x.xxx | +| explode_geometry_noprint | TriMesh | x.xxx | +| explode_geometry_noprint | MNMesh | x.xxx | ``` ### Sources </pre> </details> <!-- /kiln:response -->
Author
Owner

@allankoechke commented on GitHub (Jun 19, 2026):

Implementation complete! PR ready for review: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/pull/2

<!-- gh-comment-id:4752871919 --> @allankoechke commented on GitHub (Jun 19, 2026): <!-- kiln:log --> Implementation complete! PR ready for review: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/pull/2 <!-- /kiln:log -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: allankoech/ADN-3dsMax-Explode-Geometry#1
No description provided.