News for hackers. Stuff that matters.
Re:State of Machine Learning in Julia by adgjlsfhk1 on Wednesday January 12, 2022 @11:45AM (#29909170)
TLDR is Julia does a much better job than previous systems of de-virtualizing multiple dispatch. Most earlier systems (definitely CLOS, not sure about Cecil) allowed types of dispatch that were very hard to remove at compile time. When combined with Julia's willingness to generate lots of code, this means that most programs in Julia don't have significant amounts of dynamic dispatch which new.
Re:State of Machine Learning in Julia by Someone on Wednesday January 12, 2022 @12:00PM (#29909438)
So, where’s the long version? I can believe generating more code is cheaper now that we have gigabytes of memory, but does that make things faster, given that more code ≈ more cache misses?

Also, what types of dispatch does Jukai disallow that others allowed?

Just curious.

Re:State of Machine Learning in Julia by ChrisLomont on Wednesday January 12, 2022 @01:36PM (#29911025)
>given that more code ≈ more cache misses

More code isn't randomly jumped around in, so there are not necessarily (or in practice) more cache misses. Hot paths in Julia compile down better than in many other languages (including C/C++/FORTRAN, where aliasing is much more of a problem), specifically since multiple dispatch gets resolved as much as possible (and often completely) at compile time.

If anything, by making per type versions of things, there are less cache misses since things that are similar stay together, needing less instructions on hot paths to look up types and do other stuff that other systems do hit.

The proof is in the pudding - write (or find) some good code doing similarly complex things, and test them. Julia has C/FORTRAN speeds (and better) for a lot of important tasks, with the development flexibility of Python.

Re:State of Machine Learning in Julia by adgjlsfhk1 on Wednesday January 12, 2022 @12:45PM (#29910216)
CLOS has :before, :after, and :around qualifiers which Julia doesn't support, and CLOS supports multiple inheritance. Both of these make de virtualization much harder.

https://arxiv.org/pdf/1411.1607.pdf is a pretty good general resource for info about Julia's design decisions and has a section on multiple dispatch.

The reason that generating more code can be faster is that more code can actually result in fewer cache misses. Julia is so fast because it is really good at inlining, constant prop, and automatic vectorization. These optimizations all increase the amount of generated code, but remove conditionals that decrease code locality.

Re:State of Machine Learning in Julia by johnbcoughlin on Wednesday January 12, 2022 @12:16PM (#29909733)
Addressing the first point: It certainly does make it faster on the happy path. Instruction cache performance is not a major concern when you're running in a tight loop.