Concurrency in LazyLoadedTimeScales


I’ve written logic that propagates many spacecrafts concurrently with a custom detector that calls JPLCelestialBody.getPVCoordinates (for the Sun, Moon, Earth). This calls LazyLoadedTimeScales.getTT/getTDB which ends up blocking due to the synchronized block. I’d like to better understand the need to synchronize these functions and brainstorm concurrency optimizations. Please link me to any relevant documentation or prior discussions - the closest I’ve found is]

I’m using Orekit 11.3.2.

"pool-1-thread-6" - Thread t@69
   java.lang.Thread.State: BLOCKED
        at app//org.orekit.time.LazyLoadedTimeScales.getTT(
        - waiting to lock <389e72d3> (a org.orekit.time.LazyLoadedTimeScales) owned by "pool-1-thread-14" t@77
        at app//org.orekit.time.AbstractTimeScales.getJ2000Epoch(
        at app//org.orekit.bodies.PredefinedIAUPoles.t(
        at app//org.orekit.bodies.PredefinedIAUPoles$Moon.getPole(
        at app//org.orekit.bodies.JPLCelestialBody$InertiallyOriented$1.getTransform(
        at app//org.orekit.frames.Frame.lambda$getTransformTo$0(
        at app//org.orekit.frames.Frame$$Lambda$629/0x00007f4e2014e9f8.apply(Unknown Source)
        at app//org.orekit.frames.Frame.getTransformTo(
        at app//org.orekit.frames.Frame.getTransformTo(
        at app//org.orekit.bodies.JPLCelestialBody.getPVCoordinates(

Thanks for the help

You are right, we could probably do better here, perhaps using AtomicReference.
Could you open an issue for this?

Could you check if the following patch solves the issue?
LazyLoadedTimeScales.patch (9.0 KB)

Thanks for the quick response, Luc. The patch looks good to me!

I will build it and give it a try.

Ok, as a Release Candidate 2 was decided before releasing 12.0, we will include the fix in the very soon to be published 12.0. It was a close call!

1 Like

That’s great to hear. I tested the change multiple times yesterday and my code was able to utilize all of its CPU allocation without running into any other obvious concurrency-based blocking.

Looking forward to upgrading to 12.0!