Skip to content

jets: manual noun splitting instead of u3r_mean - #1009

Merged
pkova merged 2 commits into
developfrom
dozreg/jets-manual-split
Jul 15, 2026
Merged

jets: manual noun splitting instead of u3r_mean#1009
pkova merged 2 commits into
developfrom
dozreg/jets-manual-split

Conversation

@dozreg-toplud

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

Copy link
Copy Markdown
Contributor

@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

@dozreg-toplud
dozreg-toplud force-pushed the dozreg/jets-manual-split branch from 709fbad to ce3eda4 Compare July 14, 2026 11:07
@dozreg-toplud

Copy link
Copy Markdown
Contributor Author

New rewrite plus some manual changes/review after the discussion. This time hoon.hoon compilation is ~1.5% faster it seems.

@dozreg-toplud
dozreg-toplud marked this pull request as ready for review July 14, 2026 11:08
@dozreg-toplud
dozreg-toplud requested a review from a team as a code owner July 14, 2026 11:08
Comment thread pkg/noun/jets/e/ed_veri.c Outdated
@pkova
pkova merged commit 4e14d1b into develop Jul 15, 2026
2 checks passed
@pkova
pkova deleted the dozreg/jets-manual-split branch July 15, 2026 16:26
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.

3 participants