Goal
Lazy difficulty calculation includes the ability to calculate the timed difficulty attributes through-out the beatmap per-object, as opposed to calculating the whole beatmap at once. The API would simply provide an "enumerator" of some sorts that can only move forward. Storing past, enumerated information is the responsibility of the caller.
A significant use-case for this is "realtime" performance calculation. The feature has become relevant for discussion since the developers of tosu want to switch their difficulty and performance calculation from rosu-pp to osu-native.
Timed difficulty calculation is split up into two parts:
- Process the next hitobject
- Calculate the difficulty attributes
It is also desired to be able to skip the calculation of difficulty attributes (step 2), as this is where 99% of the computation houses. Being able to only run step 1 on a number of hitobjects allows to precisely target a certain point of time with better performance.
Problems
The primary problem at hand is that the osu!(lazer) codebase currently does not provide a way to calculate timed difficulty attributes lazily. It is only possible to calculate all timed difficulty attributes at once, which can be a costly operation.
Adding the possibility to do this to the osu!(lazer) codebase was attempted, but was put on hold because issues came up.
Another major problem is the statefulness of osu!(lazer)'s DifficultyCalculator class. This effectively means that an on-going lazy difficulty enumeration needs to lock the whole calculator instance, a mechanism that needs to be implemented on top of any of the solutions listed below.
Solutions
Integrate lazy calculation into ppy/osu
Re-attempt a PR similar to ppy/osu#36608. Might be difficult, as adding this all things considered could be seen as slightly out-of-scope for the official codebase.
Rely on reflection
This would pretty much circumvent the necessity to change the osu!(lazer) codebase in any way, but comes with a heavy maintenance and performance cost. A demo implementation (excluding "skipping" objects) can be seen here.
Another downside to this is that calculation logic would live as a duplicate, slightly altered for the "lazy" aspect, inside the osu-native codebase. While not fully out-of-scope here, it sets some kind of prescedent on what kind of functionality osu-native serves.
Expose osu!(lazer)-internals to prevent reflection
This would prevent having to rely on reflection, but the point of having duplicate logic, hosted inside the osu-native codebase, persists. A list of required symbols to be exposed is mentioned here.
Fork osu!(lazer)
Mentioning it here for the sake of completion, but this is undesired / not possible. osu-native shold target the official codebase / NuGet releases.
Goal
Lazy difficulty calculation includes the ability to calculate the timed difficulty attributes through-out the beatmap per-object, as opposed to calculating the whole beatmap at once. The API would simply provide an "enumerator" of some sorts that can only move forward. Storing past, enumerated information is the responsibility of the caller.
A significant use-case for this is "realtime" performance calculation. The feature has become relevant for discussion since the developers of tosu want to switch their difficulty and performance calculation from rosu-pp to osu-native.
Timed difficulty calculation is split up into two parts:
It is also desired to be able to skip the calculation of difficulty attributes (step 2), as this is where 99% of the computation houses. Being able to only run step 1 on a number of hitobjects allows to precisely target a certain point of time with better performance.
Problems
The primary problem at hand is that the osu!(lazer) codebase currently does not provide a way to calculate timed difficulty attributes lazily. It is only possible to calculate all timed difficulty attributes at once, which can be a costly operation.
Adding the possibility to do this to the osu!(lazer) codebase was attempted, but was put on hold because issues came up.
Another major problem is the statefulness of osu!(lazer)'s
DifficultyCalculatorclass. This effectively means that an on-going lazy difficulty enumeration needs to lock the whole calculator instance, a mechanism that needs to be implemented on top of any of the solutions listed below.Solutions
Integrate lazy calculation into ppy/osu
Re-attempt a PR similar to ppy/osu#36608. Might be difficult, as adding this all things considered could be seen as slightly out-of-scope for the official codebase.
Rely on reflection
This would pretty much circumvent the necessity to change the osu!(lazer) codebase in any way, but comes with a heavy maintenance and performance cost. A demo implementation (excluding "skipping" objects) can be seen here.
Another downside to this is that calculation logic would live as a duplicate, slightly altered for the "lazy" aspect, inside the osu-native codebase. While not fully out-of-scope here, it sets some kind of prescedent on what kind of functionality osu-native serves.
Expose osu!(lazer)-internals to prevent reflection
This would prevent having to rely on reflection, but the point of having duplicate logic, hosted inside the osu-native codebase, persists. A list of required symbols to be exposed is mentioned here.
Fork osu!(lazer)
Mentioning it here for the sake of completion, but this is undesired / not possible. osu-native shold target the official codebase / NuGet releases.