Comments (8)
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.
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.
My inclination would be to deprecate the math::nq
module and just point people to the color_quant
crate.
from color_quant.
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 unsafe
s in your code in exchange for perf improvement.
from color_quant.
Do we know if anyone is actually using math::nq
?
from color_quant.
Which was transferred to image-rs
not too long ago, by the way:
https://github.com/image-rs/color_quant
from color_quant.
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.
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)
- Add bvssvni as owner to crates.io
- More tests; more examples
- Support GPU acceleration when possible
- bug: bad sampling with 500x500 image due to prime numbers
- Docs look broken HOT 2
- [Feature Request] Support for more color quantisation algorithms
- Add LICENSE file HOT 5
- Move crate to image-rs organization HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from color_quant.