Skip to content

Commit 3101297

Browse files
kitchensink: Add 'unused' symbols
The idea is to have symbols that we derive Facet for, but that we don't use the shape of, because we're not serializing/deserializing anything using them. This ends up showing that removing `#[used]` in facet-rs/facet#788 does result in savings in terms of symbol sizes (and LLVM lines).
1 parent fcc5838 commit 3101297

File tree

4 files changed

+281
-0
lines changed

4 files changed

+281
-0
lines changed

β€Žkitchensink/ks-types/src/lib.rsβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use facet::Facet;
66
#[cfg(feature = "serde")]
77
use serde::{Deserialize, Serialize};
88

9+
pub mod unused;
10+
911
/// The root struct representing the catalog of everything.
1012
#[cfg_attr(feature = "facet", derive(Facet))]
1113
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
use chrono::{self, NaiveDate, NaiveDateTime};
2+
use uuid::{self, Uuid};
3+
4+
#[cfg(feature = "facet")]
5+
use facet::Facet;
6+
#[cfg(feature = "serde")]
7+
use serde::{Deserialize, Serialize};
8+
9+
/// The root struct representing the inventory of everything.
10+
#[cfg_attr(feature = "facet", derive(Facet))]
11+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12+
#[derive(Clone, Debug)]
13+
pub struct Inventory {
14+
pub id: Uuid,
15+
pub companies: Vec<Company>,
16+
pub created_at: NaiveDateTime,
17+
pub metadata: InventoryMetadata,
18+
}
19+
20+
#[cfg_attr(feature = "facet", derive(Facet))]
21+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
22+
#[derive(Clone, Debug)]
23+
pub struct InventoryMetadata {
24+
pub version: String,
25+
pub region: String,
26+
}
27+
28+
/// A company represented in the inventory.
29+
#[cfg_attr(feature = "facet", derive(Facet))]
30+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31+
#[derive(Clone, Debug)]
32+
pub struct Company {
33+
pub id: Uuid,
34+
pub name: String,
35+
pub address: Location,
36+
pub proprietor: CompanyProprietor,
37+
pub members: Vec<CompanyMember>,
38+
pub offices: Vec<Office>,
39+
pub goods: Vec<Item>,
40+
pub created_at: NaiveDateTime,
41+
}
42+
43+
#[cfg_attr(feature = "facet", derive(Facet))]
44+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
45+
#[derive(Clone, Debug)]
46+
pub struct CompanyProprietor {
47+
pub person: Person,
48+
pub ownership_percent: f32,
49+
}
50+
51+
#[cfg_attr(feature = "facet", derive(Facet))]
52+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
53+
#[derive(Clone, Debug)]
54+
pub struct Office {
55+
pub id: Uuid,
56+
pub name: String,
57+
pub address: Location,
58+
pub staff: Vec<CompanyMember>,
59+
pub stock: Vec<OfficeStock>,
60+
pub open: bool,
61+
}
62+
63+
#[cfg_attr(feature = "facet", derive(Facet))]
64+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
65+
#[derive(Clone, Debug)]
66+
pub struct OfficeStock {
67+
pub item: Item,
68+
pub quantity: u32,
69+
pub location_code: Option<String>,
70+
}
71+
72+
/// A member of the company
73+
#[cfg_attr(feature = "facet", derive(Facet))]
74+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
75+
#[derive(Clone, Debug)]
76+
pub struct CompanyMember {
77+
pub person: Person,
78+
pub roles: Vec<Position>,
79+
pub is_active: bool,
80+
pub created_at: NaiveDateTime,
81+
}
82+
83+
#[cfg_attr(feature = "facet", derive(Facet))]
84+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
85+
#[derive(Clone, Debug)]
86+
pub struct Person {
87+
pub id: Uuid,
88+
pub username: String,
89+
pub email: String,
90+
pub created_at: NaiveDateTime,
91+
pub updated_at: NaiveDateTime,
92+
pub profile: PersonProfile,
93+
pub preferences: Preferences,
94+
}
95+
96+
#[cfg_attr(feature = "facet", derive(Facet))]
97+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
98+
#[derive(Clone, Debug)]
99+
pub struct PersonProfile {
100+
pub first_name: String,
101+
pub last_name: String,
102+
pub date_of_birth: NaiveDate,
103+
pub gender: Sex,
104+
pub bio: Option<String>,
105+
pub avatar_url: Option<String>,
106+
pub home_address: Location,
107+
}
108+
109+
#[cfg_attr(feature = "facet", derive(Facet))]
110+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
111+
#[derive(Clone, Debug)]
112+
pub struct Location {
113+
pub street: String,
114+
pub city: String,
115+
pub state: String,
116+
pub postal_code: String,
117+
pub country: String,
118+
pub geo: Option<Coordinates>,
119+
}
120+
121+
#[cfg_attr(feature = "facet", derive(Facet))]
122+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
123+
#[derive(Clone, Debug)]
124+
pub struct Coordinates {
125+
pub latitude: f64,
126+
pub longitude: f64,
127+
}
128+
129+
#[cfg_attr(feature = "facet", derive(Facet))]
130+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
131+
#[derive(Clone, Debug)]
132+
#[repr(u8)]
133+
pub enum Sex {
134+
Male,
135+
Female,
136+
Other,
137+
PreferNotToSay,
138+
}
139+
140+
#[cfg_attr(feature = "facet", derive(Facet))]
141+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
142+
#[derive(Clone, Debug)]
143+
pub struct Item {
144+
pub id: Uuid,
145+
pub name: String,
146+
pub description: Option<String>,
147+
pub price_cents: u64,
148+
pub currency: String,
149+
pub available: bool,
150+
pub metadata: Option<ItemMetadata>,
151+
pub reviews: Vec<ItemReview>,
152+
pub categories: Vec<Group>,
153+
}
154+
155+
#[cfg_attr(feature = "facet", derive(Facet))]
156+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
157+
#[derive(Clone, Debug)]
158+
pub struct ItemMetadata {
159+
pub sku: Option<String>,
160+
pub categories: Vec<String>,
161+
pub weight_grams: Option<u32>,
162+
pub dimensions: Option<ItemDimensions>,
163+
}
164+
165+
#[cfg_attr(feature = "facet", derive(Facet))]
166+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
167+
#[derive(Clone, Debug)]
168+
pub struct ItemDimensions {
169+
pub length_mm: Option<f32>,
170+
pub width_mm: Option<f32>,
171+
pub height_mm: Option<f32>,
172+
}
173+
174+
#[cfg_attr(feature = "facet", derive(Facet))]
175+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
176+
#[derive(Clone, Debug)]
177+
pub struct ItemReview {
178+
pub id: Uuid,
179+
pub reviewer: PersonSummary,
180+
pub rating: u8,
181+
pub text: Option<String>,
182+
pub created_at: NaiveDateTime,
183+
}
184+
185+
#[cfg_attr(feature = "facet", derive(Facet))]
186+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
187+
#[derive(Clone, Debug)]
188+
pub struct Group {
189+
pub id: Uuid,
190+
pub name: String,
191+
pub description: Option<String>,
192+
pub parent: Option<Box<Group>>,
193+
}
194+
195+
/// Brief person reference (for lists)
196+
#[cfg_attr(feature = "facet", derive(Facet))]
197+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
198+
#[derive(Clone, Debug)]
199+
pub struct PersonSummary {
200+
pub id: Uuid,
201+
pub username: String,
202+
pub avatar_url: Option<String>,
203+
}
204+
205+
#[cfg_attr(feature = "facet", derive(Facet))]
206+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
207+
#[derive(Clone, Debug)]
208+
pub struct Position {
209+
pub id: Uuid,
210+
pub name: String,
211+
pub description: Option<String>,
212+
pub permissions: Vec<Right>,
213+
}
214+
215+
#[cfg_attr(feature = "facet", derive(Facet))]
216+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
217+
#[derive(Clone, Debug)]
218+
pub struct Right {
219+
pub id: Uuid,
220+
pub name: String,
221+
pub description: Option<String>,
222+
}
223+
224+
#[cfg_attr(feature = "facet", derive(Facet))]
225+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
226+
#[derive(Clone, Debug)]
227+
pub struct Preferences {
228+
pub person_id: Uuid,
229+
pub email_notifications: bool,
230+
pub push_notifications: bool,
231+
pub theme: Style,
232+
pub language: String,
233+
}
234+
235+
#[cfg_attr(feature = "facet", derive(Facet))]
236+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
237+
#[derive(Clone, Debug)]
238+
#[repr(u8)]
239+
pub enum Style {
240+
Light,
241+
Dark,
242+
System,
243+
}

β€Žlimpid/src/git.rsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub fn create_worktree(
5757
cmd.args([
5858
"worktree",
5959
"add",
60+
"--force",
6061
"--detach",
6162
worktree_path.as_str(),
6263
branch,

β€Žlimpid/src/report.rsβ€Ž

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,41 @@ pub(crate) fn generate_reports(
592592
md!("\n");
593593
}
594594

595+
// Compare total build time (wall_duration)
596+
let baseline_secs = baseline.wall_duration.as_secs_f64();
597+
let current_secs = current.wall_duration.as_secs_f64();
598+
599+
fn fmt_duration(secs: f64) -> String {
600+
if secs < 60.0 {
601+
format!("{:.2} s", secs)
602+
} else if secs < 3600.0 {
603+
let m = (secs / 60.0).floor();
604+
let s = secs % 60.0;
605+
format!("{:.0}m {:.1}s", m, s)
606+
} else {
607+
let h = (secs / 3600.0).floor();
608+
let m = ((secs % 3600.0) / 60.0).floor();
609+
let s = secs % 60.0;
610+
format!("{:.0}h {:.0}m {:.0}s", h, m, s)
611+
}
612+
}
613+
614+
tx!("Wall duration: {}", fmt_duration(current_secs).magenta());
615+
md!("Wall duration: {}", fmt_duration(current_secs));
616+
let diff = current_secs - baseline_secs;
617+
if diff > 0.01 {
618+
tx!("{}", format!(" (πŸ“ˆ +{:.2} s)", diff).green());
619+
md!(" (πŸ“ˆ +{:.2} s)", diff);
620+
} else if diff < -0.01 {
621+
tx!("{}", format!(" (πŸ“‰ {:.2} s)", diff).red());
622+
md!(" (πŸ“‰ {:.2} s)", diff);
623+
} else {
624+
tx!("{}", " (βž– no change)".dimmed());
625+
md!(" (βž– no change)");
626+
}
627+
tx!("\n");
628+
md!(" \n");
629+
595630
Ok(())
596631
}
597632

0 commit comments

Comments
Β (0)