You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing my fix for #4200 and was surprised that the speedup was barely noticeable. So I used the excellent macOS tool instruments to find out why. What I saw was that a synthetic benchmark like the one below causes 25% of the time to be spent in react_to_variable_change() with most of that time being spent in var_is_locale() which is a trivial function that simply tests if the var name is in a vector of locale var names.
I suspect that setting vars like x each time through the for loop is also triggering this code. Which it has to do for correctness since you might be assigning to one of the special vars that we monitor. Which makes it even more critical that code like react_to_variable_change() have as close to zero cost as possible if the var is not being monitored.
Time to rewrite that function to use a dispatch table. That is a map of magic var names to the relevant function to run.
# Test performance of using and manipulating fish vars.
set a1 abc(seq 10)
set a2 xyz(seq 100)
for i in (seq 1000)
for x in $a1$a2
# echo $x
end
end
set a3
for x in $a1$a2
set a3 $a3 $x
end
count $a3
The text was updated successfully, but these errors were encountered:
I was testing my fix for #4200 and was surprised that the speedup was barely noticeable. So I used the excellent macOS tool
instruments
to find out why. What I saw was that a synthetic benchmark like the one below causes 25% of the time to be spent inreact_to_variable_change()
with most of that time being spent invar_is_locale()
which is a trivial function that simply tests if the var name is in a vector of locale var names.I suspect that setting vars like
x
each time through thefor
loop is also triggering this code. Which it has to do for correctness since you might be assigning to one of the special vars that we monitor. Which makes it even more critical that code likereact_to_variable_change()
have as close to zero cost as possible if the var is not being monitored.Time to rewrite that function to use a dispatch table. That is a map of magic var names to the relevant function to run.
The text was updated successfully, but these errors were encountered: