poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Branches, exceptions, fast and slow paths


From: Luca Saiu
Subject: Branches, exceptions, fast and slow paths
Date: Mon, 20 Dec 2021 23:13:47 +0100
User-agent: Gnus (Gnus v5.13), GNU Emacs 28.0.50, x86_64-pc-linux-gnu

Hello.  This is the IRC log we were talking about

<mnabipoor> lucasaiu: Hi. PVM has "branching" instructions that raises 
exceptions directly. It seems (as you told) that's not a good idea. There's 
entry in `etc/poke.rec` that you wrote, and you talked about something called 
"subsections". What are those?
                                                  [19:22]
<mnabipoor> Isn't adding a `?f` arg to the instructions good enough? Like what 
you said here: 
https://lists.gnu.org/archive/html/epsilon-devel/2019-05/msg00000.html
<mnabipoor> If instruction fails, it fast branches to a label. And there we 
raise an exception (actually using the `raise` insn)
                                                  [19:24]
*** Kubu (~naourr@arennes-651-1-314-16.w2-12.abo.wanadoo.fr) has quit: Quit: 
Leaving.
                                                  [21:26]
*** xaid (~xaid@68.183.195.183) has quit: Quit: leaving
                                                  [21:45]
*** xaid (~xaid@68.183.195.183) has joined channel #poke

[Tue Dec 14 2021]
*** You have joined channel #poke  [01:14]
*** Topic for #poke: GNU poke - http://www.jemarch.net/poke | Pokology - 
http://www.pokology.org | GNU poke 1.4 released - 
http://www.jemarch.net/poke-1.4-relnotes.html
*** #poke: topic set by jemarch!~user@fencepost.gnu.org, 2021-12-03 00:01:44
*** Users on #poke: lucasaiu xaid bhaible ams siriusfox jyelloz sergiodj 
SAL9000 meowray jemarch V vodkra darnir mnabipoor vancz sjas Dark-Star kitzman
*** #poke modes: +nt  [01:15]
*** #poke was created on 2021-05-19 16:54:44
<jemarch> re  [05:11]
<lucasaiu> Hello everybody  [10:37]
<lucasaiu> I am seeing mnabipoor's message only now.  I unfortunately have to 
reply quickly.  [10:38]
<lucasaiu> mnabipoor: adding a fast label and fast-branching past the slow path 
is enough.  [10:45]
<lucasaiu> (sorry, I was called)
<lucasaiu> However, even if correct, branching past the slow past is not ideal: 
because the branch will be taken in the common case.
                                                                                
                              [10:46]
<lucasaiu> A non-taken branch is faster than a taken branch on modern machines. 
 And it is has also better locality for L1i.
<lucasaiu> So the alternatives are:
<lucasaiu> # fast path straight line  [10:49]
<lucasaiu>    branch-on-rare-condition $rare
<lucasaiu> $fast-path:
<lucasaiu>    ...
<lucasaiu> 
<lucasaiu> $rare:
<lucasaiu>   do the slow thing
<lucasaiu>   branch $fast-path
<lucasaiu> 
<lucasaiu> 
<lucasaiu> # fast path non-straight-line
<lucasaiu>    branch-on-common-condition $after
<lucasaiu>    do the slow thing
<lucasaiu> $after:
<lucasaiu> 
<lucasaiu> The "fast path straight line" version is faster than the "fast path 
non-straight-line" version.  [10:50]
<lucasaiu> Even if "fast path non-straight-line" might be easier to generate in 
the compiler.
<lucasaiu> This is a general pattern: it is a choice you have to make every 
time there is a two-way conditional.  If one case is more common than the 
other, the fast path straight line should be preferred.
                                                                                
                              [10:51]
<lucasaiu> Your case, if you have an exception in the slow path, could even be 
simpler: you would avoid the unconditional branch back.
                                                                                
                              [10:52]
<lucasaiu> In fact you might even be able to branch to a *shared* slow-path 
routine, used multiple times.
<lucasaiu> (leaving; have a nice day)  [10:53]
<lucasaiu> (well, not really leaving, but you understood)

-- 
Luca Saiu
* My personal web site:  http://ageinghacker.net
* GNU Jitter:            http://ageinghacker.net/projects/jitter
* GNU epsilon:           http://www.gnu.org/software/epsilon

I support everyone's freedom of mocking any opinion or belief, no
matter how deeply held, with open disrespect and the same unrelented
enthusiasm of a toddler who has just learned the word "poo".

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]