14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 4y ago · link · parent
[1]: https://www.bellingcat.com/news/2022/04/14/russias-kramators...
comment 4y ago · link · parent
If indeed premature optimization is the root of all evil, then I have lots to atone for.
comment 4y ago · link · parent
[1]: https://www.info-res.org/post/disinformation-denial-russia-s...
comment 4y ago · link · parent
Unfortunately, even if you have very fast drawing, there are plenty of other ways to make software slow. But high performance GUI software is the main thing I'm working on at the moment and I expect to have interesting results in the coming months. If nothing else, it should be a data point of how fast GUI software can be.
comment 4y ago · link · parent
When you're doing informal reasoning, the calculus changes. There's all kinds of stuff that can go wrong that is not motivated by what the machine is actually doing. In fact, it's something of a nightmare. Doing a memcpy of a struct that has padding in it? What are the exact semantics of restrict? And threading. Benign data races used to be a thing, but in an undefined behavior world, it's game over. C makes things worse than they need to be with its wonky integer rules (left shift of a negative integer and wrapping multiplication of two unsigned shorts are both UB), but a lot of that is potentially fixable and those mistakes won't be repeated in new languages.
In the context of Rust, more undefined behavior makes sense, and Ralf's work takes us much closer to a solid spec. But when you're doing mostly informal reasoning, I can see why people are so emotionally against it, and decisions such as turning off strict aliasing might be justified.
comment 4y ago · link · parent
comment 4y ago · link · parent
I'm also building a new, high performance, high quality 2D rendering engine that runs primarily on the GPU.
And I'm also exploring new approaches to building GUI, primarily in Rust. A new focus is to integrate that more tightly with the renderer mentioned above. A benefit I expect is that I'll be able to do the CPU side of the rendering work in multiple threads, where existing architectures make it very difficult to break out of a single thread.
How did I end up working on this? It's a natural evolution of what I've been working on for a long time, in Ghostscript, on Google Fonts, working on the text stack on Android, and now fortunate enough to have a research position back on Google Fonts where I am able to focus on this and have great support from the rest of the team.
comment 4y ago · link · parent
comment 4y ago · link · parent
Conversely, as many comments here observe, it is terrible as a small build system. There, you want to be able to get started quickly and pull in dependencies without thinking too hard. A simple but easy to understand approach (even one based on make) might work. This is just a different problem than what Bazel solves.
My personal opinion (and I should emphasize, I am absolutely not speaking for anyone here, least of all Google) is that the best way forward is to take the ideas of Bazel (hermetic and deterministic builds) and package them as a good small build system, perhaps even compatible with Bazel so you don't have to rewrite build rules all the time. I also think compilers and tools can and should evolve to become good citizens in such a world. But I have no idea how things will go, it's equally plausible the entire space of build systems will continue to suck as they have for decades.
[1]: http://neilmitchell.blogspot.com/2021/09/small-project-build...
[2]: https://neilmitchell.blogspot.com/2021/09/reflecting-on-shak...
[3]: https://neilmitchell.blogspot.com/2021/09/huge-project-build...
comment 4y ago · link · parent
Regarding "never," I am an adventurous programmer[1], so am fully willing to accept that I am the exception that proves the rule.
On the more general point of UB for arithmetic overflow, I think we're on the same side: this is a pretty broken story in the way C has ended up, and one of the clear motivations for a cleaned up better-than-C language. I'm more interested in your thoughts on data races, where I suspect we have a substantive difference in perspective.
[1]: https://github.com/linebender/kurbo/blob/de52170e084cf658a2a...
comment 4y ago · link · parent
There are two other issues. One is when the shift amount is greater than or equal to the machine word size, for example 1u32 << 32. Java and Rust (release mode; debug is allowed to panic similarly to other forms of arithmetic overflow) take the position that the shift amount is masked to be modulo the word size, which happens to match Intel and aarch64 assembly instructions but not 32-bit ARM, so (unless the optimizer can prove the range) requires an additional mask instruction. This is the motivation for not explicitly specifying the behavior in C, though I believe a very strong case can be made that it should be implementation defined rather than undefined. In any case, it sounds like you are making the opposite decision as Java, so there's extra logic needed to correctly implement it on Intel and aarch64 but it should work efficiently on 32-bit ARM.
But I was specifically referring to the fact that -1 << 1 is UB in C. It was fixed in C++20 (so the value is specified to be -2, as arithmetic is now defined to be twos complement), but that fix is not in the C23 draft. I consider this perhaps the canonical example of programmer-hostile UB.
comment 4y ago · link · parent
let i = mystruct.i;
if (i < array.length) {
let x = expensive_computation(i);
array[i] = x;
}
For the purpose of this example, let's say that the expensive computation is register-intensive but doesn't write any memory (so we don't need to get into alias analysis issues). Because it is register-intensive, our optimizer would like to free up the register occupied by i, replacing the second use of i by another load from mystruct.i. In C or unsafe Rust, this would be a perfectly fine optimization.If another thread writes struct.i concurrently, we have a time of check to time of use (TOCTOU) error. In C or unsafe Rust, that's accounted for by the fact that a data race is undefined behavior. One of the behaviors that's allowed (because basically all behavior are allowed) is for the two uses of i to differ, invalidating the bounds check.
Different languages deal with this in different ways. Java succeeds in its goal of avoiding UB, disallowing this optimization; the mechanism for doing so in LLVM is to consider most memory accesses to have "unordered" semantics. However, this comes with its own steep tradeoff. To avoid tearing, all pointers must be "thin," specifically disallowing slices. Go, by contrast, has slices among its fat pointer types, so incurs UB when there's a data race. It's otherwise a fairly safe language, but this is one of the gaps in that promise.
Basically, my argument is this. If you're really rigorous about avoiding UB, you essentially have to define a memory model, then make sure your use of LLVM (or whatever code generation technique) is actually consistent with that memory model. That's potentially an enormous amount of work, very easy to get subtly wrong, and at the end of the day gives you fewer optimization opportunities than C or unsafe Rust. Thus, it's certainly not a tradeoff I personally would make.
comment 4y ago · link · parent
comment 4y ago · link · parent
While avoiding undefined behavior is a noble goal, my personal feeling is that actually achieving that will be much harder than it might first seem, and will probably end up precluding a good deal of optimization.
Of course, C has an entire class of UB that is much more excessive than useful, for example left shift of a negative integer. It's clearly and obviously possible to do much better than C. I'm just skeptical that "no UB at all" is in reach for a low-level, systems programming language that is also portable and can be compiled with optimization comparable to C.
comment 4y ago · link · parent
I'll probably implement this, as it's very likely what you want in the variable font case.
comment 4y ago · link · parent
I could add a correspondence visualization (I thought about something similar when describing the error measurement technique), but you can also see it pretty clearly by looking at the lengths of the control arms. That's easiest to see when accuracy is set to infinity.
comment 4y ago · link · parent
You can of course change curve representations (I did that with the Euler approach), but there are downsides. Just how bad depends on the application. One place where you really want to stay in a cubic representation is in a font or vector graphics editor. If you just want to add a little weight to the font, ideally you don't want the structure to change, or lots of new control points to appear. In other applications it might be fine though.
comment 4y ago · link · parent
The actual conversation about motivation to publish a paper is a fairly deep topic. In this particular case, I do think it's worthwhile for a variety of reasons:
* The literature dates back about 40 years, and no really good solution has been published.
* The most commonly cited survey paper is possibly fundamentally wrong.
* One of the most commonly cited and used techniques is surprisingly bad.
* The curve-fitting technique I propose probably has many other applications; in the best case, it could potentially open up a new field of study.
So part of my motivation for publishing the blog post is to see if I can recruit a partner in crime, someone who has incentive for publication in academic circles. We'll see!
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
If you're talking about a variation of that where you choose some other concept of "normal" relevant to the point, I'd be interested to learn more.
474.
Parallel Curves of Cubic Béziers(raphlinus.github.io ↗)
225 points · by raphlinus · 4y ago · 51 comments
comment 4y ago · link · parent
Apple does support WebGL2, but compute shader support is not part of that core spec. The demos[2] certainly don't work in Safari in my quick test.
[1]: https://registry.khronos.org/webgl/specs/latest/2.0-compute/
[2]: https://9ballsyndrome.github.io/WebGL_Compute_shader/webgl-c...
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
Yes, that's the draft on arXiv, and I have a blog post in the pipeline[1] explaining it to a more general audience.
And thanks for the other advice, I'll consider it!
[1] https://github.com/raphlinus/raphlinus.github.io/issues/66
comment 4y ago · link · parent
I made a serious attempt to submit some of my GPU monoid work to academic conferences earlier this year, got rejected. As someone who doesn't have the "publish or perish" incentive of actually being in academia, it's really just not worth it.
I'm also doing inquiry into UI, for example architectural patterns in reactive systems. The current state of academic literature on this topic seems to be terrible (though please point out counterexamples!). Most of what's written is marketing material for UI frameworks - there's an explosion of those, especially in the JavaScript world, but very little synthesis of the core concepts. I wouldn't even attempt to try to submit an academic paper on this topic, though I think it would likely be useful to the world.
It feels like there should be a space to publish work that is not novel in an academic sense, but useful. Wikipedia is not it (their articles on cubic and quartic equations are garbage when it comes to numerical concerns), Stack Overflow is not it, academic conferences and journals are not it. I'm using my blog, generally successfully, but it feels there should be a more systematic approach.