Skip to content

editoast: use our custom uom unit system - #18492

Open
Tristramg wants to merge 4 commits into
devfrom
uom_custom
Open

Tristramg wants to merge 4 commits into
devfrom
uom_custom

Conversation

@Tristramg

@Tristramg Tristramg commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

There are two goals to this pull request

  1. reduce building time (we don’t drag the whole uom::si system, only quantities we need)
  2. prepare the switch to integer representation of the values

I started from the work by @Sh099078
I reduce the system to the bare minimum quantities and made the following changes:

  • use i64 everywhere, no u64 (when switching later to integers for everything, we will need negative values, and having just one type makes things easier)
  • only use Time and not the Offset type aliased created a long time ago

Build time

With cargo clean && cargo build --timings:

After:
image

Before:
image

On my computer a gain of 10% on the total compilation time (from 165 to 150 seconds)

Preparing to switch to integer representation

The last point requires to be able to change the base unit (for instance, in the SI, the acceleration is in m/s². That value as an integer won’t have enough precision as with trains we are often around 1.0

How to test

There should be no change at all

How to read

  • The first commit just defines the general unit system. It’s mostly a minimal extract from the UOM library. It doesn’t touch our existing code
  • The second commit is the definition of composed units that are used in OSRD (like Velocity that is compose of Distance and Time)
  • A technical commit to remove some macro helpers contained in uom::si
  • Switch existing units from uom::si to ours, and remove ta

AI assistance

Using opencode+GLM5.3

  • without editing: helping to find a typo in the macro, making a first review of the code change
  • with editing: adapting the test to our getter/setter

@Tristramg
Tristramg requested a review from a team as a code owner September 8, 2026 16:48
@github-actions github-actions Bot added the area:editoast Work on Editoast Service label Sep 8, 2026
@Tristramg
Tristramg marked this pull request as draft September 8, 2026 16:49
@Tristramg Tristramg self-assigned this Sep 9, 2026
@Tristramg Tristramg moved this to Awaiting merge in Board PI 21 Sep 9, 2026
@Tristramg
Tristramg force-pushed the uom_custom branch 2 times, most recently from 1408d41 to c45771d Compare September 9, 2026 14:57
@Tristramg
Tristramg marked this pull request as ready for review September 9, 2026 15:10

@woshilapin woshilapin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you got that PR back on track.

Comment thread editoast/common/src/lib.rs
Comment thread editoast/common/src/unit_system/time.rs
Comment thread editoast/common/src/unit_system/length.rs
Comment thread editoast/common/src/unit_system/acceleration.rs
Comment thread editoast/core_client/src/conflict_detection.rs Outdated
Comment thread editoast/core_client/src/simulation.rs
Comment thread editoast/common/src/unit_system.rs Outdated
Comment on lines +48 to +50
mod velocity::Velocity, // TODO switch to meter per second
mod acceleration::Acceleration, // TODO switch to meter per second squared
mod force::Force, // TODO switch to kg.m.s-2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand your response to @woshilapin's comment (which I agree with):

Suggested change
mod velocity::Velocity, // TODO switch to meter per second
mod acceleration::Acceleration, // TODO switch to meter per second squared
mod force::Force, // TODO switch to kg.m.s-2
mod velocity::Velocity, // TODO switch to millimeter per second
mod acceleration::Acceleration, // TODO switch to millimeter per second squared
mod force::Force, // TODO switch to kg.mm.s-2

Comment thread editoast/core_client/src/simulation.rs
@Tristramg
Tristramg force-pushed the uom_custom branch 5 times, most recently from a7ef009 to 0978bbc Compare September 17, 2026 11:45
Sh099078 and others added 4 commits September 23, 2026 18:21
- It has the same base units as the International System of Units (ISQ)
  but different default measurement units (ex: meter -> centimeter).
  This will allow us to use u64 as the storage type for the different
  quantities without any precision loss. For more information on the
  subject, check the [design paragraph in the uom official
  documentation](https://docs.rs/uom/latest/uom/#design) explaining the
  issue faced when using the ISQ (based on meters) to store smaller
  values (millimeters in our case) in integers.
- It allows us to own the quantity types of the units system and
  implement any trait we want on them directly without bumping into the
  orphan rule.
- The available measurements are drastically reduced for maintenability
  purposes: only the ones that are used in Editoast have been kept in
  the new system.


Signed-off-by: Loup Federico <16464925+Sh099078@users.noreply.github.com>
Add to the Editoast System of Quantities (ESQ) the different composed
units that are used in osrd.
- These units are named in a similar fashion as they are in the
  International System of Quantities.
- Keep the existing type aliases made to the SI units when they are
  known / used under a different name in the context of OSRD (example:
  the type alias `SolidFriction` for `Force`).
- Only keep the measurements used in OSRD.


Signed-off-by: Loup Federico <16464925+Sh099078@users.noreply.github.com>
This will help us later to no longer use that feature in the uom crate

Signed-off-by: Tristram Gräbener <tristram+git@tristramg.eu>
This results in a measurable compilation time 
- before 165 seconds
- after 150 seconds
as we no longer have uom’s whole SI

This will also later on to adapt the base values for each quantity
in order to store them as integers.

Signed-off-by: Tristram Gräbener <tristram+git@tristramg.eu>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:editoast Work on Editoast Service

Projects

Status: Awaiting merge

Development

Successfully merging this pull request may close these issues.

5 participants