igc-xc-score icon indicating copy to clipboard operation
igc-xc-score copied to clipboard

Strip/tree shake debug code

Open vicb opened this issue 3 years ago • 7 comments

It would be nice to be able to strip (or tree shake) the debug/test geojson code especially to reduce the payload for websites.

For tree shaking the debug code should be moved out of the class.

Maybe also switch to Typescript ?

vicb avatar Mar 26 '21 17:03 vicb

The gain will be less than 1Kb I think? But still, maybe there should be some way to remove that code altogether in a production buiild When I started this project, it was meant as a support tool, along igc-admin-analyze, for my linear regression analysis of weather data and XC scores - a project that did not turn out to be a great success - except for rediscovering the importance of ambient pressure already known since the Age of Sail

Just as pfd, it was initially a Python project with multithreading support Then, at some point, I decided to hastily hack a JS version - a monothreaded one - to compare the performance - and to my greatest surprise, the mono-threaded JS version outperformed the Python multithreaded one - with or without PyPy

So in fact, this project grew out of a hack and I considered it mostly abandonware :smile:

Initially I didn't want to have any dependencies, but now that it is an ES6 module that must be transpiled anyway, I could as well use Typescript. But in fact, just a few days ago I was even considering a complete rewrite in C++ - so that it can be embedded in flight instruments. This year is going to be my first year with a real flight computer and I am still looking at all available options - and whatever I choose, I will surely consider an embedded port. I will probably start with an Onyx Boox.

mmomtchev avatar Mar 26 '21 18:03 mmomtchev

The gain will be less than 1Kb I think? But still, maybe there should be some way to remove that code altogether in a production buiild

There is no small gain ;)

Making it tree shakeable should be easy, just move the method out of the classes in a different module. You can still access the members (it might look like getBoxJson(box)).

Those days the v8 VM is pretty efficient and I would be curious about the gain you can have with a C++ implementation. Still it is possible to compile C++ to WebASM.

With regards to flight instruments I like XCTrack on Android, FlyME on Android is nice too and they can already optimize the flights in real time. I run XCTrack on a $100 android phone.

vicb avatar Mar 26 '21 18:03 vicb

XCTrack is currently my first choice - initially I intended to write my own :smile: - but XCTrack is so good that one cannot justify rewriting it One of the authors of XCTrack is Ondrej who is the original creator of this algorithm, yet there is no scoring in it?

mmomtchev avatar Mar 26 '21 18:03 mmomtchev

I was also thinking about adding support for Box points - so that it can show you a score-maximizing point in a, let's say 3km or 5km radius - by closing a triangle or by getting closer to an FAI triangle - but there is not point implementing this in JS/TS - this feature belongs to a C++ implementation

mmomtchev avatar Mar 26 '21 18:03 mmomtchev

One of the authors of XCTrack is Ondrej who is the original creator of this algorithm, yet there is no scoring in it?

Yes there is scoring.

  • While you are flying it will show you the best triangle/fai you can close,
  • When you look at a recorded track, it would score it for you.

vicb avatar Mar 26 '21 18:03 vicb

I just stumbled upon https://github.com/igclib/igclib/blob/master/src/xc/xcopt.cpp

vicb avatar Mar 26 '21 22:03 vicb

Also Tom Payne has a C implementation (used by the FFVL). It might be interesting to contact him to at least get some benchmark.

See https://github.com/twpayne/xcscore-js/blob/master/README.md

More sophisticated algorithms are used for scoring real GPS tracklogs with tens of thousands of points. Contact the author for details.

vicb avatar Mar 27 '21 16:03 vicb