Skip to content

jets: manual noun splitting instead of u3r_mean#1009

Draft
dozreg-toplud wants to merge 1 commit into
developfrom
dozreg/jets-manual-split
Draft

jets: manual noun splitting instead of u3r_mean#1009
dozreg-toplud wants to merge 1 commit into
developfrom
dozreg/jets-manual-split

Conversation

@dozreg-toplud
Copy link
Copy Markdown
Contributor

@dozreg-toplud dozreg-toplud commented May 5, 2026

@joemfb I tried replacing u3r_mean calls with explicit core splitting. Some observations:

  1. Compiler did eliminate redundant deconstructions;
  2. +ride call on Hoon source seems ~5% slower with explicit splitting.

The way I implemented it was:

  1. Define macros that take u3_noun or u3_weak and return u3_weak:
#define u3r_head_weak(SOM) ({                   \
  u3_weak _som = SOM;                           \
  ( u3_none == _som ) ? u3_none                 \
    : (_(u3ud(_som))) ? u3_none                 \
    : ( ((u3a_cell *)u3a_to_ptr(_som))->hed );  \
})

#define u3r_tail_weak(SOM) ({                   \
  u3_weak _som = SOM;                           \
  ( u3_none == _som ) ? u3_none                 \
    : (_(u3ud(_som))) ? u3_none                 \
    : ( ((u3a_cell *)u3a_to_ptr(_som))->tel );  \
})

#define u3r_head(SOM) ({                      \
  u3_noun _som = SOM;                         \
  ( _(u3ud(_som)) ) ? u3_none                 \
  : ( ((u3a_cell *)u3a_to_ptr(_som))->hed );  \
})

#define u3r_tail(SOM) ({                      \
  u3_noun _som = SOM;                         \
  ( _(u3ud(_som)) ) ? u3_none                 \
  : ( ((u3a_cell *)u3a_to_ptr(_som))->tel );  \
})
  1. Apply a generated python script to all files in /jets directory, turning u3r_mean into composition of the function-like macros defined above

Am I missing some way to make it more efficient?

@dozreg-toplud dozreg-toplud requested a review from joemfb May 5, 2026 10:48
@dozreg-toplud dozreg-toplud force-pushed the dozreg/jets-manual-split branch from efcf8a8 to 709fbad Compare May 5, 2026 11:46
@dozreg-toplud
Copy link
Copy Markdown
Contributor Author

Microbenchmarking showed order of magnitude improvement though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant