Budgets, Lifetimes, and Errors#
This page describes the limits an instance enforces, how operations and objects end, and the status codes that calls return.
Budgets#
The instance holds every limit, and no limit grows on its own. The instance description sets them in these fields:
Field |
Meaning |
Python Default |
|---|---|---|
Live operations at once. An operation holds an entry until it is destroyed. |
8 |
|
Asynchronous CPU jobs running at once. More jobs wait in a queue. There is no hidden worker pool. |
2 |
|
Host memory for versions, plans, and results. |
64 MiB |
|
One byte budget per CUDA device. No entry means no CUDA work. |
none |
Work that would exceed a limit is refused when it is submitted, with OPERATION_CAPACITY,
RESULT_CAPACITY, HOST_BUDGET, or DEVICE_BUDGET, and changes nothing. An exact CPU query also
charges its working memory, which depends on the geometry it reaches, while it runs. A synchronous
query that does not fit returns HOST_BUDGET; an asynchronous batch ends with OPERATION_FAILED.
ovspatialquery_get_instance_memory_usage() reports what is in use.
The first exact query that reaches a triangle mesh builds the mesh’s query structure. The call that adds the mesh, a registration or a publication, charges the structure’s memory in advance, along with the memory the build needs while it runs. The structure keeps about 32 bytes per triangle and 16 per vertex, and a build needs up to about 192 bytes per triangle more. Meshes not yet built share that build charge, sized for the largest of them. A 131,072-triangle mesh therefore needs about 37 MiB of host budget to register, and about 12 MiB once a query has built it. While it runs, an exact query against a mesh can need 4 bytes per triangle of the mesh, and a sweep through a mesh of more than 4,096 triangles always reserves them: 512 KiB for that mesh.
Operations#
Registrations, publications, batch launches, and pair advances are asynchronous. Each returns an operation ID, and these calls manage the operation:
wait_opwaits up to a timeout. A timeout only means that the work is still running. Nothing is canceled, and nothing can be.query_op_statusreports the state, the final status, and progress without consuming anything.destroy_opreleases the operation and everything it kept alive: its version, its borrowed inputs, and its result slot. It returnsBUSYwhile the work is still running, or until a wait, status call, or fetch has observed that it finished.
Each input column declares who keeps its data alive:
Inputs passed as
BORROWED_UNTIL_TERMINALmust stay valid and unchanged until the operation finishes.Inputs passed as
COPIED_ON_SUBMISSIONare copied before the call returns.
Destruction#
You destroy every object explicitly. A destroy call returns BUSY instead of waiting while
something still uses the object, as in these cases:
A population, while a view, plan, reporter, or operation uses it.
A plan, while an operation owns one of its slots.
The instance, while anything it created is alive.
Destroy objects in reverse order of creation.
In Python, operations, populations, views, plans, and reporters are context managers, and the instance owns everything created through it. Leaving the instance’s block closes what is still open, operations first and the instance last. If the block raised, that exception is the one you see, with any teardown failure added to it as a note. Leaving an operation’s block waits for it and closes it.
Important
Retire a CUDA operation with close_after_cuda() before its block ends, because only the
caller knows which streams read its results.
Convex Hulls#
The library builds a convex hull from the points of a convex definition that you register and of
a mesh that you publish with physics:approximation = "convexHull". It builds one of two hulls:
Hull |
Used For |
What It Is |
|---|---|---|
The points’ own hull |
A registration with |
Its vertices are points, and every point lies inside it within |
The hull a PhysX simulation collides with |
A registration with |
The hull PhysX cooks for a |
Note
When the points’ own hull has more vertices than the limit, PhysX fits an oriented box around the points and cuts it with planes of their hull until another cut would exceed the limit. Corners of the box that no cut removes stay in the hull. For points on a sphere, those corners lie up to about 65 percent of the radius outside the points at limits 8 and 16, and about 20 percent at 32. At 64 the vertices lie on the points. At every limit, points can lie up to about 12 percent of the radius outside the hull.
The points’ own hull is refused when it exceeds its limits, or when the points lie so nearly in one plane that no hull of their own encloses them. The diagnostic names the definition and, for enclosure, how far outside the farthest point lies. A mesh or definition for which PhysX cooks no hull is refused too. The two sources then answer differently:
Source |
A hull that cannot be built |
|---|---|
ovstage |
The mesh is excluded as |
Explicit |
The registration returns |
The library never replaces such a convex with its bounding box. A convex whose hull cannot be built is refused, or excluded, and a query never reports hits on a box that stands in for it. If your program needs a box as a fallback, register a box definition yourself.
Important
Known limitation: the hull builder can fail to return for very thin point clouds. A registration or a publication that reaches one never returns and keeps one CPU core busy on the calling thread. In a random sample, about 3 percent of the slabs 3e-6 to 1e-4 of their extent thick hung (77 of 2,304), and every one had 16 or more points. Thicker shapes, such as spheres, cylinders, and rotated boxes, never did, and nearly all flatter slabs are refused because their points lie too nearly in one plane. No thickness separates the clouds that hang from the clouds that register.
To avoid it, register such a shape as a triangle mesh, or as a box or another primitive, instead
of a convex. You can also register it with a hull_vertex_limit, which cooks it as a PhysX
simulation does. None of 336 such slabs hung that way.
Status Codes#
Every C call returns an ovspatialquery_result_t with a status. ovspatialquery_get_last_error()
describes the last failure on the calling thread, and ovspatialquery_get_last_op_error() the
failure of an operation that is still alive. The Python package raises ApiError with the status
and that description.
A status is one of these values:
Status |
Meaning |
|---|---|
The call did what it says. |
|
A failure with no more specific status. |
|
A wait saw the work still running. |
|
Malformed input, or a value outside the input domain. |
|
A zero, unknown, or wrong-kind handle, or one from another instance. A handle from another loaded copy of the library is not detected. Refer to Several Copies in One Process. |
|
The object is in the wrong state for the call, such as a second first publication. |
|
The combination is not available, such as CUDA work without CUDA. |
|
The result is not there yet, or a population has no head. |
|
Something still uses the object, or its work is still running. |
|
A pair advance that moves neither endpoint. |
|
A publication’s base is not the head, or two endpoints in one population disagree. |
|
The requested ordinal is neither the head nor retained. |
|
A pair advance to an older ordinal. |
|
No free operation entry. |
|
No free result slot in the plan or reporter. |
|
The work would exceed the memory budget. |
|
Admitted asynchronous work failed. |
|
An allocation failed outside the budgets. |
|
An internal check failed; no partial state was published. |
|
The CUDA device was lost during admitted work. |
Note
Stage content is never an error. A prim that an ovstage population cannot publish is left out and listed in the publication result, as Excluded Prims describes.