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
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -163,15 +163,6 @@
 checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
 
 [[package]]
-name = "bitmaps"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2"
-dependencies = [
- "typenum",
-]
-
-[[package]]
 name = "block-buffer"
 version = "0.12.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -702,21 +693,6 @@
 checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
 
 [[package]]
-name = "im-rc"
-version = "15.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af1955a75fa080c677d3972822ec4bad316169ab1cfc6c257a942c2265dbe5fe"
-dependencies = [
- "bitmaps",
- "rand_core 0.6.4",
- "rand_xoshiro",
- "refpool",
- "sized-chunks",
- "typenum",
- "version_check",
-]
-
-[[package]]
 name = "indexmap"
 version = "2.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -829,7 +805,6 @@
  "drop_bomb",
  "educe",
  "hi-doc",
- "im-rc",
  "insta",
  "jrsonnet-gcmodule",
  "jrsonnet-interner",
@@ -881,7 +856,6 @@
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "21dd97b40cbfb2043094219f95d96519858ba1aee4e8260eb048a1774832a517"
 dependencies = [
- "im-rc",
  "jrsonnet-gcmodule-derive",
 ]
 
@@ -1356,7 +1330,7 @@
 checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"
 dependencies = [
  "rand_chacha",
- "rand_core 0.9.5",
+ "rand_core",
 ]
 
 [[package]]
@@ -1366,14 +1340,8 @@
 checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
 dependencies = [
  "ppv-lite86",
- "rand_core 0.9.5",
+ "rand_core",
 ]
-
-[[package]]
-name = "rand_core"
-version = "0.6.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
 
 [[package]]
 name = "rand_core"
@@ -1382,15 +1350,6 @@
 checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
 dependencies = [
  "getrandom 0.3.4",
-]
-
-[[package]]
-name = "rand_xoshiro"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
-dependencies = [
- "rand_core 0.6.4",
 ]
 
 [[package]]
@@ -1432,12 +1391,6 @@
 ]
 
 [[package]]
-name = "refpool"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "369e86b80fa7dc8c561dd9613a5bf25c59d2d3073cd66c47fd9e39802f0ecb58"
-
-[[package]]
 name = "regex"
 version = "1.12.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1639,17 +1592,6 @@
 version = "2.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
-
-[[package]]
-name = "sized-chunks"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e"
-dependencies = [
- "bitmaps",
- "refpool",
- "typenum",
-]
 
 [[package]]
 name = "smallvec"
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@
 jrsonnet-cli = { path = "./crates/jrsonnet-cli", version = "0.5.0-pre98" }
 jrsonnet-types = { path = "./crates/jrsonnet-types", version = "0.5.0-pre98" }
 jrsonnet-formatter = { path = "./crates/jrsonnet-formatter", version = "0.5.0-pre98" }
-jrsonnet-gcmodule = { version = "0.4.4", features = ["im-rc"] }
+jrsonnet-gcmodule = { version = "0.4.4" }
 # Diagnostics.
 # hi-doc is my library, which handles text formatting very well, but isn't polished enough yet
 # Previous implementation was based on annotate-snippets, which I don't like for many reasons.
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -76,7 +76,6 @@
   "Hash",
   "PartialEq",
 ] }
-im-rc = { version = "15.1.0", features = ["pool"] }
 smallvec = "1.15.1"
 drop_bomb.workspace = true
 
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
--- a/crates/jrsonnet-evaluator/src/obj/oop.rs
+++ b/crates/jrsonnet-evaluator/src/obj/oop.rs
@@ -4,7 +4,6 @@
 	ops::ControlFlow,
 };
 
-use im_rc::Vector;
 use jrsonnet_gcmodule::{Cc, Trace};
 use jrsonnet_ir::IStr;
 use rustc_hash::{FxHashMap, FxHashSet};
@@ -118,7 +117,7 @@
 
 #[allow(clippy::module_name_repetitions)]
 pub struct ObjValueBuilder {
-	sup: Vector<CcObjectCore>,
+	sup: Vec<CcObjectCore>,
 	has_assertions: bool,
 
 	new: OopObject,
@@ -130,7 +129,7 @@
 	}
 	pub fn with_capacity(capacity: usize) -> Self {
 		Self {
-			sup: Vector::new(),
+			sup: Vec::new(),
 			has_assertions: false,
 			new: OopObject::new(FxHashMap::with_capacity(capacity), None),
 			next_field_index: FieldIndex::default(),
@@ -141,7 +140,7 @@
 	}
 	pub fn with_super(&mut self, super_obj: ObjValue) -> &mut Self {
 		self.has_assertions |= super_obj.0.has_assertions;
-		self.sup = super_obj.0.cores.clone();
+		self.sup.clone_from(&super_obj.0.cores);
 		self
 	}
 
@@ -178,20 +177,19 @@
 
 	pub fn extend_with_core(&mut self, core: impl ObjectCore) {
 		self.commit();
-		self.sup.push_back(CcObjectCore::new(core));
+		self.sup.push(CcObjectCore::new(core));
 	}
 
 	fn commit(&mut self) {
 		if !self.new.is_empty() {
-			self.sup
-				.push_back(CcObjectCore::new(mem::take(&mut self.new)));
+			self.sup.push(CcObjectCore::new(mem::take(&mut self.new)));
 		}
 		self.next_field_index = FieldIndex::default();
 	}
 
 	pub fn with_fields_omitted(&mut self, omit: FxHashSet<IStr>) {
 		self.commit();
-		self.sup.push_back(CcObjectCore::new(OmitFieldsCore {
+		self.sup.push(CcObjectCore::new(OmitFieldsCore {
 			omit,
 			prev_layers: self.sup.len(),
 		}));