Giter Club home page Giter Club logo

Comments (8)

HeroicKatora avatar HeroicKatora commented on July 23, 2024 1

Trading performance for some well-reviewed unsafe can be okay, imageproc needs to do it as well. It is, however, not the preferred resolution. In my experience, a large part of the work is finding the cause of a particular slowdown. Here, temporarily removing some bounds checks by-hand using unsafe is a useful tool for finding missed optimization. In many cases there are alternatives. The llvm optimizer is quite powerful when given the right inputs.

For example, bounds checks on slices can often be removed by using iteration instead. Or by doing a check once at the start of a local scope then relying on llvm deducing that all indices are smaller than the initial check. When in doubt, the secure code working group or #black-magic in the community Discord can also answer some questions and propose alternative.

from color_quant.

HeroicKatora avatar HeroicKatora commented on July 23, 2024 1

We can't say that it is not used at all.

That said, the code was at some point extracted as a separate crate: color_quant.

from color_quant.

fintelia avatar fintelia commented on July 23, 2024 1

My inclination would be to deprecate the math::nq module and just point people to the color_quant crate.

from color_quant.

TianyiShi2001 avatar TianyiShi2001 commented on July 23, 2024

In my experience, for example, the compiler isn't always smart enough to elide the bound checks for indexing where all indexing operations are garanteed to be in-bound within a function, and using unsafe {x.get_unchecked()} can be used to improve performance, if you can tolerate unsafes in your code in exchange for perf improvement.

from color_quant.

fintelia avatar fintelia commented on July 23, 2024

Do we know if anyone is actually using math::nq?

from color_quant.

HeroicKatora avatar HeroicKatora commented on July 23, 2024

Which was transferred to image-rs not too long ago, by the way:
https://github.com/image-rs/color_quant

from color_quant.

TianyiShi2001 avatar TianyiShi2001 commented on July 23, 2024

Which was transferred to image-rs not too long ago, by the way:
https://github.com/image-rs/color_quant

Then, how about unifying the implementations in math::nq module with the corresponding implementations in the color_quant crate, and any benchmarks and further developments on this algorithm will happen in the color_quant crate.

from color_quant.

HeroicKatora avatar HeroicKatora commented on July 23, 2024

That seems useful, yeah. There probably needs to be one pass ensuring that the implementation hasn't diverged but I see you're already busy merging them 🙂

from color_quant.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.