Hi Linus,

On Sun, Feb 21, 2016 at 03:48:07PM -0800, Linus Torvalds wrote:
> 
> This is a series of four pretty simple patches that get rid of some insane 
> code in the cylinder pressure interpolation logic.

Thanks. I'm glad that I'm not the only one who thought that code was
pretty nuts. Except that you were able to untangle it whereas I just
figured "hey, let's ask Linus to do it"...

> The insane code seems to have grown over time, as the code was updated and 
> made to handle different cases without ever looking at how that changed 
> the rules. It all probably made sense at some point.

Possibly :-)

> The nasty code not only looked quite incomprehensible, with random odd 
> rules that made no sense, it also resulted in the algorithm being O(n**2) 
> in the number of plot entries. Normally that's not a huge issue, because 
> the calculations themselves were simple, and there generally aren't *that* 
> many plot entries.
> 
> But at some point even just a simple O(n**2) gets expensive when you have 
> long dives and have set your dive computer to do samples every 2 
> seconds...

Yes, at 7000 samples as in one of the dives that made the issue obvious
this was taken some serious amount of time to run. Your 4th patch should
result in this being at least a thousand time faster. Nice.

> The fix is fairly simple in the end, but to make it all easier to 
> understand I split it up into four patches. That makes the surgery on some 
> very confusing code be much simpler to follow along, and hopefully makes 
> people go "ok, that's obviously and trivially correct" for each step. 

Yes. This was role modeling what I as a maintainer love to see. I could
read through each of the patches, start with the commit message, then
follow along what the commit message explained in the code.

Extremely well done.

> Still, despite how obvious and trivially correct this series is, people 
> should double-check. It speeds up the example case by quite a bit, to the 
> point where other expenses in plotting long dives with lots of samples 
> dominates. And I did check it on a few dives I have with multiple 
> cylinders, but some more testing certainly can't hurt.

Yes, I've done some testing with my dives and couldn't find anything
obviously odd and I have a few dives where I am lacking gas integration
information, a couple of those are fairly long and the gas graphs look
pleasing.

It would be good if some more people with more complex tech dives where
they have beginning and end pressures of the various tanks would give this
a try. I'll create daily builds in a minute.

Thanks for fixing this.

/D
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to