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
before · Cargo.lock
233 packageslockfile v4
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
--- a/crates/jrsonnet-evaluator/src/obj/mod.rs
+++ b/crates/jrsonnet-evaluator/src/obj/mod.rs
@@ -11,7 +11,6 @@
 };
 
 use educe::Educe;
-use im_rc::{Vector, vector};
 use jrsonnet_gcmodule::{Acyclic, Cc, Trace, Weak, cc_dyn};
 use jrsonnet_interner::IStr;
 use jrsonnet_ir::Span;
@@ -97,7 +96,7 @@
 
 // 0 - add
 //  12 - visibility
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Acyclic)]
 pub struct ObjFieldFlags(u8);
 impl ObjFieldFlags {
 	fn new(add: bool, visibility: Visibility) -> Self {
@@ -136,7 +135,6 @@
 #[allow(clippy::module_name_repetitions)]
 #[derive(Debug, Trace)]
 pub struct ObjMember {
-	#[trace(skip)]
 	flags: ObjFieldFlags,
 	original_index: FieldIndex,
 	pub invoke: MaybeUnbound,
@@ -240,7 +238,7 @@
 #[derive(Trace, Educe)]
 #[educe(Debug)]
 struct ObjValueInner {
-	cores: Vector<CcObjectCore>,
+	cores: Vec<CcObjectCore>,
 	assertions_ran: Cell<bool>,
 	has_assertions: bool,
 	value_cache: RefCell<FxHashMap<(IStr, CoreIdx), CacheValue>>,
@@ -268,7 +266,7 @@
 
 thread_local! {
 	static EMPTY_OBJ: ObjValue = ObjValue(Cc::new(ObjValueInner {
-		cores: vector![],
+		cores: vec![],
 		assertions_ran: Cell::new(true),
 		has_assertions: false,
 		value_cache: RefCell::default(),
@@ -495,7 +493,10 @@
 
 	#[must_use]
 	pub fn extend_from(&self, sup: Self) -> Self {
-		let cores = sup.0.cores.clone() + self.0.cores.clone();
+		let mut cores = Vec::with_capacity(sup.0.cores.len() + self.0.cores.len());
+		cores.extend(sup.0.cores.iter().cloned());
+		cores.extend(self.0.cores.iter().cloned());
+
 		let has_assertions = sup.0.has_assertions || self.0.has_assertions;
 		ObjValue(Cc::new(ObjValueInner {
 			cores,
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(),
 		}));