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
after · Cargo.toml
1[workspace]2members = ["crates/*", "bindings/jsonnet", "cmds/*", "tests", "xtask"]3default-members = ["cmds/jrsonnet"]4resolver = "2"56[workspace.package]7authors = ["Yaroslav Bolyukin <iam@lach.pw>"]8edition = "2021"9license = "MIT"10repository = "https://github.com/CertainLach/jrsonnet"11version = "0.5.0-pre98"1213[workspace.dependencies]14jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0-pre98" }15jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0-pre98" }16jrsonnet-ir = { path = "./crates/jrsonnet-ir", version = "0.5.0-pre98" }17jrsonnet-ir-parser = { path = "./crates/jrsonnet-ir-parser", version = "0.5.0-pre98" }18jrsonnet-peg-parser = { path = "./crates/jrsonnet-peg-parser", version = "0.5.0-pre98" }19jrsonnet-rowan-parser = { path = "./crates/jrsonnet-rowan-parser", version = "0.5.0-pre98" }20jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0-pre98" }21jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", 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" }24jrsonnet-formatter = { path = "./crates/jrsonnet-formatter", version = "0.5.0-pre98" }25jrsonnet-gcmodule = { version = "0.4.4" }26# Diagnostics.27# hi-doc is my library, which handles text formatting very well, but isn't polished enough yet28# Previous implementation was based on annotate-snippets, which I don't like for many reasons.29#30# I'm against using miette, because I want to reuse data between interpreter and annotations, yet miette31#   and other libraries want to handle spans etc by itself, which is okay for compiler diagnostics, but is32#   bad for interpreter, where interpreter and parser are paired much closer.33hi-doc = "0.3.0"34annotate-snippets = "0.12.11"3536# CLI37clap = "4.5"38clap_complete = "4.5"3940# Parsing, manifestification is implemented manually everywhere41serde = "1.0.228"42serde_json = "1.0.149"43serde-saphyr = { version = "0.0.25", default-features = false, features = [44  "deserialize",45] }4647# Error handling48anyhow = "1.0.101"49thiserror = "2.0.18"5051# Code formatting52dprint-core = "0.67.4"5354# Stdlib hashing functions55md5 = "0.8.0"56sha1 = "0.11.0"57sha2 = "0.11.0"58sha3 = "0.11.0"59hex = "0.4.3"6061# Source code parsing.62# Jrsonnet has two parsers for jsonnet - one is for execution, and another is for better parsing diagnostics/lints/LSP.63# First (and fast one) is based on peg, second is based on rowan.64peg = "0.8.5"65logos = "0.16.1"66ungrammar = "1.16.1"67rowan = "0.16.1"6869mimallocator = "0.1.3"70indoc = "2.0"71tempfile = "3.24"72pathdiff = "0.2.3"73hashbrown = "0.17.0"74static_assertions = "1.1"75rustc-hash = "2.1"76num-bigint = "0.4.6"77strsim = "0.11.1"78proc-macro2 = "1.0"79quote = "1.0"80syn = "2.0"81drop_bomb = "0.1.5"82base64 = "0.22.1"83indexmap = "2.13.0"84itertools = "0.14.0"85xshell = "0.2.7"8687regex = "1.12"88lru = "0.17.0"8990syn-dissect-closure = "0.1.0"9192# Tests/benchmarks93insta = { version = "1.46", features = ["glob"] }94criterion = { version = "0.8" }9596[workspace.lints.rust]97unsafe_op_in_unsafe_fn = "deny"9899# TODO: add docs everywhere100# missing_doc = "warn"101102elided_lifetimes_in_paths = "allow"103explicit_outlives_requirements = "allow"104noop_method_call = "allow"105single_use_lifetimes = "allow"106variant_size_differences = "allow"107macro_expanded_macro_exports_accessed_by_absolute_paths = "allow"108109[workspace.lints.rustdoc]110all = "warn"111112[workspace.lints.clippy]113all = { level = "warn", priority = -1 }114nursery = { level = "warn", priority = -1 }115pedantic = { level = "warn", priority = -1 }116117ptr_arg = "allow"118# Too verbose119must_use_candidate = "allow"120# A lot of functions pass around errors thrown by code121missing_errors_doc = "allow"122# A lot of pointers have interior Rc123needless_pass_by_value = "allow"124# Its fine125wildcard_imports = "allow"126enum_glob_use = "allow"127module_name_repetitions = "allow"128# False positives129# https://github.com/rust-lang/rust-clippy/issues/6902130use_self = "allow"131# https://github.com/rust-lang/rust-clippy/issues/8539132iter_with_drain = "allow"133type_repetition_in_bounds = "allow"134# ci is being run with nightly, but library should work on stable135missing_const_for_fn = "allow"136# too many false-positives with .expect() calls137missing_panics_doc = "allow"138# false positive for IStr type. There is an configuration option for139# such cases, but it doesn't work:140# https://github.com/rust-lang/rust-clippy/issues/9801141mutable_key_type = "allow"142# false positives143redundant_pub_crate = "allow"144# Sometimes code is fancier without that145manual_let_else = "allow"146# Something is broken about that lint, can't be allowed for147# codegenerated-stdlib block148similar_names = "allow"149150#[profile.test]151#opt-level = 1152153[profile.release]154opt-level = 3155lto = "fat"156codegen-units = 1157debug = 0158panic = "abort"159strip = true160161[profile.releasedebug]162inherits = "release"163debug = 2164panic = "unwind"165strip = false
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(),
 		}));