|
|
|
|
|
by sabauma
2839 days ago
|
|
This is indeed a consequence of tracing. The problem is that traces are associated to loops in the program, and since the map function contains only one loop, all traces for map are associated to the loop in its implementation. When you manually write a loop, there is only one 'body', so a tracing JIT turns that into a single or small number of traces. For the loop inside of map, you need to produce side exits and new traces for each function passed in. The more times map is used, the slower it gets. This is made worse by the fact that traces out of side exits tend to not be optimized nearly as well. Pycket has this same issue with its builtin (or hand written) looping _functions_ like map. Fortunately, Racket provides many useful looping macros which allows Pycket to generate unique traces for each loop, ameliorating this problem somewhat in Pycket. |
|
Is it true to say that if two functions have the same body and arglist, and capture no variables, then you should be able to reuse the same traces?
This doesn’t happen very often in real code, but it’s useful to understand the problem.