ocaml-opam / opam-0install-solver

a solver for opam packages using 0install's solver engine
ISC License
21 stars 13 forks source link

Avoid non-domain-safe global counter #53

Closed talex5 closed 6 months ago

talex5 commented 6 months ago

Roles need to have unique IDs so they can be used as map keys. This was done for virtual roles by incrementing a global ref-cell, but this isn't safe when using multiple domains. Instead, use an empty object.

Virtual implementations (used for or-patterns in dependencies) also used this global counter to get an integer used for sorting. This is only used when reporting diagnostics. We now use a local counter for this.

This should fix the tsan warning, and might be slightly faster as different cores don't need to share the same counter.

This is an alternative to #51 that doesn't require OCaml 5.

talex5 commented 6 months ago

The output of dump.exe was the same. Times are similar (there's more variation between runs than between versions).