git.delta.rocks / jrsonnet / refs/commits / a102a18fded2

difftreelog

refactor drop im-rc

tnwykoutYaroslav Bolyukin2026-05-05parent: #5eebad4.patch.diff
in: master
Not worth it. It gives some improvements in some benchmarks, but at the
cost of much complex memory layout, I do not consider that a win

5 files changed

modifiedCargo.lockdiffbeforeafterboth
162source = "registry+https://github.com/rust-lang/crates.io-index"162source = "registry+https://github.com/rust-lang/crates.io-index"
163checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"163checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
164
165[[package]]
166name = "bitmaps"
167version = "2.1.0"
168source = "registry+https://github.com/rust-lang/crates.io-index"
169checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2"
170dependencies = [
171 "typenum",
172]
173164
174[[package]]165[[package]]
175name = "block-buffer"166name = "block-buffer"
701source = "registry+https://github.com/rust-lang/crates.io-index"692source = "registry+https://github.com/rust-lang/crates.io-index"
702checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"693checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
703
704[[package]]
705name = "im-rc"
706version = "15.1.0"
707source = "registry+https://github.com/rust-lang/crates.io-index"
708checksum = "af1955a75fa080c677d3972822ec4bad316169ab1cfc6c257a942c2265dbe5fe"
709dependencies = [
710 "bitmaps",
711 "rand_core 0.6.4",
712 "rand_xoshiro",
713 "refpool",
714 "sized-chunks",
715 "typenum",
716 "version_check",
717]
718694
719[[package]]695[[package]]
720name = "indexmap"696name = "indexmap"
829 "drop_bomb",805 "drop_bomb",
830 "educe",806 "educe",
831 "hi-doc",807 "hi-doc",
832 "im-rc",
833 "insta",808 "insta",
834 "jrsonnet-gcmodule",809 "jrsonnet-gcmodule",
835 "jrsonnet-interner",810 "jrsonnet-interner",
881source = "registry+https://github.com/rust-lang/crates.io-index"856source = "registry+https://github.com/rust-lang/crates.io-index"
882checksum = "21dd97b40cbfb2043094219f95d96519858ba1aee4e8260eb048a1774832a517"857checksum = "21dd97b40cbfb2043094219f95d96519858ba1aee4e8260eb048a1774832a517"
883dependencies = [858dependencies = [
884 "im-rc",
885 "jrsonnet-gcmodule-derive",859 "jrsonnet-gcmodule-derive",
886]860]
887861
1356checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"1330checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"
1357dependencies = [1331dependencies = [
1358 "rand_chacha",1332 "rand_chacha",
1359 "rand_core 0.9.5",1333 "rand_core",
1360]1334]
13611335
1362[[package]]1336[[package]]
1366checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"1340checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
1367dependencies = [1341dependencies = [
1368 "ppv-lite86",1342 "ppv-lite86",
1369 "rand_core 0.9.5",1343 "rand_core",
1370]1344]
1371
1372[[package]]
1373name = "rand_core"
1374version = "0.6.4"
1375source = "registry+https://github.com/rust-lang/crates.io-index"
1376checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
13771345
1378[[package]]1346[[package]]
1379name = "rand_core"1347name = "rand_core"
1384 "getrandom 0.3.4",1352 "getrandom 0.3.4",
1385]1353]
1386
1387[[package]]
1388name = "rand_xoshiro"
1389version = "0.6.0"
1390source = "registry+https://github.com/rust-lang/crates.io-index"
1391checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
1392dependencies = [
1393 "rand_core 0.6.4",
1394]
13951354
1396[[package]]1355[[package]]
1397name = "random_color"1356name = "random_color"
1431 "crossbeam-utils",1390 "crossbeam-utils",
1432]1391]
1433
1434[[package]]
1435name = "refpool"
1436version = "0.4.3"
1437source = "registry+https://github.com/rust-lang/crates.io-index"
1438checksum = "369e86b80fa7dc8c561dd9613a5bf25c59d2d3073cd66c47fd9e39802f0ecb58"
14391392
1440[[package]]1393[[package]]
1441name = "regex"1394name = "regex"
1640source = "registry+https://github.com/rust-lang/crates.io-index"1593source = "registry+https://github.com/rust-lang/crates.io-index"
1641checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"1594checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
1642
1643[[package]]
1644name = "sized-chunks"
1645version = "0.6.5"
1646source = "registry+https://github.com/rust-lang/crates.io-index"
1647checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e"
1648dependencies = [
1649 "bitmaps",
1650 "refpool",
1651 "typenum",
1652]
16531595
1654[[package]]1596[[package]]
1655name = "smallvec"1597name = "smallvec"
modifiedCargo.tomldiffbeforeafterboth
22jrsonnet-cli = { path = "./crates/jrsonnet-cli", version = "0.5.0-pre98" }22jrsonnet-cli = { path = "./crates/jrsonnet-cli", version = "0.5.0-pre98" }
23jrsonnet-types = { path = "./crates/jrsonnet-types", version = "0.5.0-pre98" }23jrsonnet-types = { path = "./crates/jrsonnet-types", version = "0.5.0-pre98" }
24jrsonnet-formatter = { path = "./crates/jrsonnet-formatter", version = "0.5.0-pre98" }24jrsonnet-formatter = { path = "./crates/jrsonnet-formatter", version = "0.5.0-pre98" }
25jrsonnet-gcmodule = { version = "0.4.4", features = ["im-rc"] }25jrsonnet-gcmodule = { version = "0.4.4" }
26# Diagnostics.26# Diagnostics.
27# hi-doc is my library, which handles text formatting very well, but isn't polished enough yet27# hi-doc is my library, which handles text formatting very well, but isn't polished enough yet
28# Previous implementation was based on annotate-snippets, which I don't like for many reasons.28# Previous implementation was based on annotate-snippets, which I don't like for many reasons.
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
76 "Hash",76 "Hash",
77 "PartialEq",77 "PartialEq",
78] }78] }
79im-rc = { version = "15.1.0", features = ["pool"] }
80smallvec = "1.15.1"79smallvec = "1.15.1"
81drop_bomb.workspace = true80drop_bomb.workspace = true
8281
modifiedcrates/jrsonnet-evaluator/src/obj/mod.rsdiffbeforeafterboth
11};11};
1212
13use educe::Educe;13use educe::Educe;
14use im_rc::{Vector, vector};
15use jrsonnet_gcmodule::{Acyclic, Cc, Trace, Weak, cc_dyn};14use jrsonnet_gcmodule::{Acyclic, Cc, Trace, Weak, cc_dyn};
16use jrsonnet_interner::IStr;15use jrsonnet_interner::IStr;
17use jrsonnet_ir::Span;16use jrsonnet_ir::Span;
9796
98// 0 - add97// 0 - add
99// 12 - visibility98// 12 - visibility
100#[derive(Clone, Copy)]99#[derive(Clone, Copy, Acyclic)]
101pub struct ObjFieldFlags(u8);100pub struct ObjFieldFlags(u8);
102impl ObjFieldFlags {101impl ObjFieldFlags {
103 fn new(add: bool, visibility: Visibility) -> Self {102 fn new(add: bool, visibility: Visibility) -> Self {
136#[allow(clippy::module_name_repetitions)]135#[allow(clippy::module_name_repetitions)]
137#[derive(Debug, Trace)]136#[derive(Debug, Trace)]
138pub struct ObjMember {137pub struct ObjMember {
139 #[trace(skip)]
140 flags: ObjFieldFlags,138 flags: ObjFieldFlags,
141 original_index: FieldIndex,139 original_index: FieldIndex,
142 pub invoke: MaybeUnbound,140 pub invoke: MaybeUnbound,
240#[derive(Trace, Educe)]238#[derive(Trace, Educe)]
241#[educe(Debug)]239#[educe(Debug)]
242struct ObjValueInner {240struct ObjValueInner {
243 cores: Vector<CcObjectCore>,241 cores: Vec<CcObjectCore>,
244 assertions_ran: Cell<bool>,242 assertions_ran: Cell<bool>,
245 has_assertions: bool,243 has_assertions: bool,
246 value_cache: RefCell<FxHashMap<(IStr, CoreIdx), CacheValue>>,244 value_cache: RefCell<FxHashMap<(IStr, CoreIdx), CacheValue>>,
268266
269thread_local! {267thread_local! {
270 static EMPTY_OBJ: ObjValue = ObjValue(Cc::new(ObjValueInner {268 static EMPTY_OBJ: ObjValue = ObjValue(Cc::new(ObjValueInner {
271 cores: vector![],269 cores: vec![],
272 assertions_ran: Cell::new(true),270 assertions_ran: Cell::new(true),
273 has_assertions: false,271 has_assertions: false,
274 value_cache: RefCell::default(),272 value_cache: RefCell::default(),
495493
496 #[must_use]494 #[must_use]
497 pub fn extend_from(&self, sup: Self) -> Self {495 pub fn extend_from(&self, sup: Self) -> Self {
498 let cores = sup.0.cores.clone() + self.0.cores.clone();496 let mut cores = Vec::with_capacity(sup.0.cores.len() + self.0.cores.len());
497 cores.extend(sup.0.cores.iter().cloned());
498 cores.extend(self.0.cores.iter().cloned());
499
499 let has_assertions = sup.0.has_assertions || self.0.has_assertions;500 let has_assertions = sup.0.has_assertions || self.0.has_assertions;
500 ObjValue(Cc::new(ObjValueInner {501 ObjValue(Cc::new(ObjValueInner {
modifiedcrates/jrsonnet-evaluator/src/obj/oop.rsdiffbeforeafterboth
4 ops::ControlFlow,4 ops::ControlFlow,
5};5};
66
7use im_rc::Vector;
8use jrsonnet_gcmodule::{Cc, Trace};7use jrsonnet_gcmodule::{Cc, Trace};
9use jrsonnet_ir::IStr;8use jrsonnet_ir::IStr;
10use rustc_hash::{FxHashMap, FxHashSet};9use rustc_hash::{FxHashMap, FxHashSet};
118117
119#[allow(clippy::module_name_repetitions)]118#[allow(clippy::module_name_repetitions)]
120pub struct ObjValueBuilder {119pub struct ObjValueBuilder {
121 sup: Vector<CcObjectCore>,120 sup: Vec<CcObjectCore>,
122 has_assertions: bool,121 has_assertions: bool,
123122
124 new: OopObject,123 new: OopObject,
130 }129 }
131 pub fn with_capacity(capacity: usize) -> Self {130 pub fn with_capacity(capacity: usize) -> Self {
132 Self {131 Self {
133 sup: Vector::new(),132 sup: Vec::new(),
134 has_assertions: false,133 has_assertions: false,
135 new: OopObject::new(FxHashMap::with_capacity(capacity), None),134 new: OopObject::new(FxHashMap::with_capacity(capacity), None),
136 next_field_index: FieldIndex::default(),135 next_field_index: FieldIndex::default(),
141 }140 }
142 pub fn with_super(&mut self, super_obj: ObjValue) -> &mut Self {141 pub fn with_super(&mut self, super_obj: ObjValue) -> &mut Self {
143 self.has_assertions |= super_obj.0.has_assertions;142 self.has_assertions |= super_obj.0.has_assertions;
144 self.sup = super_obj.0.cores.clone();143 self.sup.clone_from(&super_obj.0.cores);
145 self144 self
146 }145 }
147146
178177
179 pub fn extend_with_core(&mut self, core: impl ObjectCore) {178 pub fn extend_with_core(&mut self, core: impl ObjectCore) {
180 self.commit();179 self.commit();
181 self.sup.push_back(CcObjectCore::new(core));180 self.sup.push(CcObjectCore::new(core));
182 }181 }
183182
184 fn commit(&mut self) {183 fn commit(&mut self) {
185 if !self.new.is_empty() {184 if !self.new.is_empty() {
186 self.sup185 self.sup.push(CcObjectCore::new(mem::take(&mut self.new)));
187 .push_back(CcObjectCore::new(mem::take(&mut self.new)));
188 }186 }
189 self.next_field_index = FieldIndex::default();187 self.next_field_index = FieldIndex::default();
190 }188 }
191189
192 pub fn with_fields_omitted(&mut self, omit: FxHashSet<IStr>) {190 pub fn with_fields_omitted(&mut self, omit: FxHashSet<IStr>) {
193 self.commit();191 self.commit();
194 self.sup.push_back(CcObjectCore::new(OmitFieldsCore {192 self.sup.push(CcObjectCore::new(OmitFieldsCore {
195 omit,193 omit,
196 prev_layers: self.sup.len(),194 prev_layers: self.sup.len(),
197 }));195 }));