Randomizer based Replicator code gets slower every frame

Thank you for providing help on this topic. The issue where the rendering slows down is currently not a problem for me because I do not have to render that many images at once. However I am curious if this bug is related to the problem I mentioned in here:

Maybe there is a better way of achieving the following:

  1. Instantiate a bunch of Parts (Given by USD-Path)
  2. Modify the semantics of the parts (1 semantic class for each USD-Path)
  3. Randomize the rotation around the z-axis of the part
  4. Scatter it over a plane

Currently my implementation looks like this:

# region Randomizer methods
# Randomize Part Position and Rotatation
def random_Parts():
    # Retrieve the prims of the instances
    instances = rep.get.prims(
        semantics=[('class', 'cube'), ('class', 'capsule'), ('class', 'cone'), ('class', 'cylinder'), ('class', 'sphere'), ('class', 'torus')]
    )

    with instances:
        # Randomize the rotation of the parts
        rep.randomizer.rotation(
            min_angle=(0, 0, -180),
            max_angle=(1, 1, 180)
        )

        # Scatter it across the plane
        rep.randomizer.scatter_2d(
            surface_prims=spawnplane,
            check_for_collisions=True,
        )
    return instances.node

# Instantiate a random number of parts
def instantiate_Parts(file_path, classes, sample_size):
    # Instantiates a number of parts (size specifies the number of instances per part)
    # The distribution of the instances over all is random
    instances = rep.randomizer.instantiate(
        paths=file_path,
        size=sample_size,
        mode='reference'
    )

    with instances:
        # Label each part
        rep.modify.semantics([('class', classes)])

        # Randomize the parts material
        rep.randomizer.materials(
            materials=rep.get.material(path_pattern="/Looks/Parts/*")
        )

# Randomize the floor material
def random_Floor_Material():
    floor_material = rep.randomizer.materials(
        materials=rep.get.material(path_pattern="/Looks/Floor/*"),
        input_prims=floor
    )
    return floor_material.node

# Randomize Dome Light
def dome_Light():
    lights = rep.create.light(
        light_type="Dome",
        position=(0, 0, 0),
        rotation=rep.distribution.uniform((0, 0, -180), (0, 0, 180)),
        scale=(1, 1, 1),
        name='HDRI',
        texture=rep.distribution.choice([
            'https://omniverse-content-production.s3.us-west-2.amazonaws.com/Assets/Skies/2022_1/Skies/Indoor/autoshop_01.hdr',
            'https://omniverse-content-production.s3.us-west-2.amazonaws.com/Assets/Skies/2022_1/Skies/Indoor/small_hangar_01.hdr',
            'http://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/Skies/Indoor/ZetoCGcom_ExhibitionHall_Interior1.hdr',
            'https://omniverse-content-production.s3.us-west-2.amazonaws.com/Assets/Skies/2022_1/Skies/Indoor/adams_place_bridge.hdr'
            ])
        )
    return lights.node

# Randomize the Focus Distance of the camera
def random_Focus_Distance(camera, MinFocusDistance, MaxFocusDistance):
    with camera:
        rep.modify.attribute(
            name='focusDistance',
            value=rep.distribution.uniform(MinFocusDistance, MaxFocusDistance)
        )
    return camera.node

# Register Randomizers
rep.randomizer.register(random_Parts)
rep.randomizer.register(instantiate_Parts)
rep.randomizer.register(random_Floor_Material)
rep.randomizer.register(dome_Light)
rep.randomizer.register(random_Focus_Distance)
# endregion
  # Instatiate all the parts
  for classes, path in PARTS.items():
      rep.randomizer.instantiate_Parts(path, classes, 3)
  
  # Trigger the randomizer at each frame
  with rep.trigger.on_frame(num_frames=num):
      rep.randomizer.random_Parts()
      rep.randomizer.random_Floor_Material()
      rep.randomizer.dome_Light()
      rep.randomizer.random_Focus_Distance(topview, 1200, 1600)

Thank you for your efforts!
Julian