Skip to content

Issue 2281 - #5507

Open
jurb33 wants to merge 5 commits into
yt-project:mainfrom
jurb33:issue-2281
Open

Issue 2281#5507
jurb33 wants to merge 5 commits into
yt-project:mainfrom
jurb33:issue-2281

Conversation

@jurb33

@jurb33 jurb33 commented Aug 12, 2026

Copy link
Copy Markdown

Address slow particle deposition. Currently, a deposit invokes a full octree walk no matter the previous result. By caching the last oct used for the starting traversal path of a octree walk, we can get shorter walk times. Benefits datasets where spatial locality of particles are near/same octant (RAMSES)

Updated fake_octree_ds API for usage in local timing tests. These can be kept or removed alongside existing. (Not sure about future use).

PR Summary

ParticleDepositOperation.process_octree()
Previously called OctreeContainer.get() for every particle, which always starts from the root oct.
This adds a cache of last oct a particle landed in (OctreeContainer.get_near()) that, given a starting oct,
climbs towards root, doubling it's step until the new particle is contained, then descends identically to get().
This cost scales with how many levels the new particle is from the cached, hence spatial locality wins big here.

For the implementation, OctreeContainer.get_near() needs to walk upwards, so adding a parent pointer and
updating it everywhere an Oct is allocated is nessecary.

When writing tests to build a deep octree, I uncovered the outdated fake_octree API. The fixes were as follows:

  1. Adding root_nodes to allocate_domains([max_noct]) to align with updated SparseOctreeContainer.allocate_domains

  2. The subdivide() method referenced parent.children[ii] without checking if parent.children != NULL.

  3. Useoct_handler.noctsfor a global oct count rather than then the allocation of a single domain.

Implementation was tested with an AI assisted testbench. 4 cases of clustered, spatially ordered, random and domain boundary were ran locally. For the sole purpose of verifying the speedup, these can be kept or deleted.
Checks for correct particle counts is implemented to assert correctness on some level.
At around 50M particles, I saw ~2x speedup.

Closes #2281

PR Checklist

Consult with team on keeping this test
Review implementation documentation with team
Verify speedup with team

@welcome

welcome Bot commented Aug 12, 2026

Copy link
Copy Markdown

Hi! Welcome, and thanks for opening this pull request. We have some guidelines for new pull requests, and soon you'll hear back about the results of our tests and continuous integration checks. Thank you for your contribution!

@jurb33
jurb33 marked this pull request as draft August 12, 2026 10:17
@jurb33
jurb33 marked this pull request as ready for review August 12, 2026 10:19
@jurb33
jurb33 marked this pull request as draft August 12, 2026 10:24
@jurb33
jurb33 marked this pull request as ready for review August 13, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Faster particle depositions

1 participant