perf (tsort) : avoid reading the whole input into memory and intern strings (#9872)

* perf(tsort): avoid reading the whole input into memory and intern strings

* perf(tsort): avoid redundant check on input

* perf(tsort): switch to the Bucket interning Backend for better lookup performance
This commit is contained in:
Sylvestre Ledru
2026-01-02 13:58:08 +01:00
committed by GitHub
4 changed files with 252 additions and 156 deletions
Generated
+12
View File
@@ -2711,6 +2711,16 @@ dependencies = [
"num-traits",
]
[[package]]
name = "string-interner"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23de088478b31c349c9ba67816fa55d9355232d63c3afea8bf513e31f0f1d2c0"
dependencies = [
"hashbrown 0.15.4",
"serde",
]
[[package]]
name = "strsim"
version = "0.11.1"
@@ -4043,6 +4053,8 @@ dependencies = [
"clap",
"codspeed-divan-compat",
"fluent",
"nix",
"string-interner",
"tempfile",
"thiserror 2.0.17",
"uucore",
+2 -1
View File
@@ -1,7 +1,7 @@
# coreutils (uutils)
# * see the repository LICENSE, README, and CONTRIBUTING files for more information
# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs
# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind cfgs interner
[package]
name = "coreutils"
@@ -369,6 +369,7 @@ same-file = "1.0.6"
self_cell = "1.0.4"
# FIXME we use the exact version because the new 0.5.3 requires an MSRV of 1.88
selinux = "=0.5.2"
string-interner = "0.19.0"
signal-hook = "0.4.1"
tempfile = "3.15.0"
terminal_size = "0.4.0"
+5 -2
View File
@@ -1,3 +1,4 @@
#spell-checker:ignore (libs) interner
[package]
name = "uu_tsort"
description = "tsort ~ (uutils) topologically sort input (partially ordered) pairs"
@@ -19,9 +20,11 @@ path = "src/tsort.rs"
[dependencies]
clap = { workspace = true }
thiserror = { workspace = true }
uucore = { workspace = true }
fluent = { workspace = true }
string-interner = { workspace = true }
thiserror = { workspace = true }
nix = { workspace = true, features = ["fs"] }
uucore = { workspace = true }
[[bin]]
name = "tsort"
+233 -153
View File
File diff suppressed because it is too large Load Diff