[HN Gopher] Speeding Up the Webcola Graph Viz Library with Rust ...
       ___________________________________________________________________
        
       Speeding Up the Webcola Graph Viz Library with Rust and WebAssembly
        
       Author : Ameo
       Score  : 102 points
       Date   : 2021-07-04 19:53 UTC (3 hours ago)
        
 (HTM) web link (cprimozic.net)
 (TXT) w3m dump (cprimozic.net)
        
       | etimberg wrote:
       | Great writeup! I love the level of detail and that the author
       | touched on strategies they tried that didn't end up working out.
        
       | miohtama wrote:
       | This is quite a hardcore trip down to optimising single CPU
       | instructions. I need to tip off my hat to the author. Though not
       | sure what kind of motivation and project goals warrant this deep
       | and detailed problem tackling.
        
         | Ameo wrote:
         | Author here - I was on a week-long vacation at the time and had
         | been working on the visualization as a side project before
         | that. I started really getting into the deep end of the
         | optimization work while on that week-long break.
         | 
         | The thing about optimization work is that it's incredibly
         | addicting once you get into it. Seeing consistent, measurable
         | improvement and watching the frame times shrink is so
         | satisfying, plus the process itself is really enjoyable in and
         | of itself.
         | 
         | I definitely agree that the optimizations here are overkill for
         | the actual application itself. However, it served as a great
         | learning experience for me personally and allowed me to write
         | this blog post as well!
        
           | tyfon wrote:
           | > I definitely agree that the optimizations here are overkill
           | for the actual application itself. However, it served as a
           | great learning experience for me personally and allowed me to
           | write this blog post as well!
           | 
           | While this might be a bit overkill, I wish more developers
           | spent at least 10% as much effort as here, the modern world
           | of software really feels bloated often. The core engines are
           | getting faster and the cpus are getting faster but the web
           | feels slower.
           | 
           | And another important factor is that more and more software
           | runs on battery powered portable devices in some form.
           | Instructions saved is battery saved = happier users :)
        
       | jarym wrote:
       | "This whole experience served to reinforce my confidence in the
       | power of the modern web as a flexible and fully-featured
       | application platform." !! Yes, congrats to author for taking the
       | considerable time and dedication necessary for the exercise at
       | hand.
        
       | acidburnNSA wrote:
       | Great post.
       | 
       | In physics simulations when we're dealing with the distance
       | formula we often just skip the square root part. This works if
       | you're dealing in relative distances. I bet this algorithm could
       | skip the sqrt altogether.
        
         | Ameo wrote:
         | That is a good point. The distance computation and displacement
         | checking indeed could be changed to use the squared forms.
         | However, I was unable to remove the square rooting because of
         | their use in the core math.[1]
         | 
         | There are components of it like this:                  2. *
         | weight * (distance - ideal_distance) / (ideal_distance_squared
         | * distance)
         | 
         | I don't think there's a way to change this math to work without
         | taking the square root to get `distance`. It's possible that
         | there is a way to change that to work with the squared forms,
         | but I don't grasp the actual math going on well enough to
         | determine that unfortunately.
         | 
         | Looking at the perf metrics for the full function's
         | disassembly[2], square root-related instructions only account
         | for a tiny amount of the program's runtime anyway.
         | 
         | That all being said, thank you so much for taking the time to
         | read the post closely enough to come up with this idea!
         | 
         | [1] https://github.com/Ameobea/webcola-
         | wasm/blob/master/src/wasm... [2] https://ameo.link/u/91u.html
        
       ___________________________________________________________________
       (page generated 2021-07-04 23:00 UTC)