HNHacker News
TopNewBestAskShowJobs

foobazgt

637 karma · joined September 12, 2022

submissionscomments
foobazgt··on DoubleClickjacking: A New type of web hacking technique
My mother constantly struggles between when to double click or not after decades of using computers. This is probably an issue that will die out with her generation, though.

Entirely separate, a common failure mode of dying mice is that they start generating spurious clicks. I've had a couple of logitechs do this to me. And the thing about scams is you can often legit make money off of very low success rates.

foobazgt··on Why is my CPU usage always 100%?
For those not familiar with servlets, this means serializing every single request to the server that hits that servlet. And a single servlet can serve many different pages. In fact, in the early days, servlet filters didn't exist, so you would often implement cross-cutting functionality like authentication using a servlet.

TBF, I don't think a lot of developers at the time (90's) were used to the idea of having to write MT-safe callback code. Nowadays thousands of object allocations per second is nothing to sweat over, so a framework might make a different decision to instantiate callbacks per request by default.

foobazgt··on WASM-4: Build retro games using WebAssembly for a fantasy console
It's a reference to Pico-8.

https://www.lexaloffle.com/pico-8.php

foobazgt··on Tesla has the highest fatal accident rate of all auto brands, study finds
Some context for others - 2015 is fairly early in Tesla's history. The model 3 didn't even exist until 2017. The overwhelming majority of Teslas on the road today are Y's and 3's.

FWIW, I've personally owned three Teslas with zero problems, but none older than 2019. YMMV.

foobazgt··on Trump wins presidency for second time
Tesla literally has a massive (electrical) energy storage business alongside solar. There are huge battery installations that are helping regions like Hawaii and Australia pivot to renewables.
foobazgt··on Next Generation Out of Band Garbage Collection
Cinder's benchmarks don't seem "like Java" performance, given they aren't that far off cython.

https://github.com/facebookincubator/cinder/blob/cinder/3.8/...

foobazgt··on Next Generation Out of Band Garbage Collection
A similar strategy is to serialize the object and store it in-process but off heap. This is useful when the values are private to the process, and/or they don't need to survive a crash, and/or you need to avoid the network overhead. Access times are often 100x-1000x faster.
foobazgt··on Scalable self-improvement for compiler optimization
One of the fun parts of compiler optimizations is that they can be competing forces, for example inlining for speed and outlining for size. You can see a similar pattern in garbage collectors (throughout vs latency). It can be easy to land in an infinite loop or an oscillating function.

One technique I've seen is to set a goal for one optimization and, once that's met, throw the remaining resources at the other target. That feels like a bit of a cop out, though.

foobazgt··on Smart pointers for the kernel
Yes, the drawback of unsafe is one single goof in just one unsafe block can blow your entire program wide open. The advantage is that your entire program isn't one gigantic unsafe block (like C).

The magnitude matters.

foobazgt··on The Copenhagen Book: general guideline on implementing auth in web applications
I have two reactions to this:

- Complicated authorization systems bleed through everything else, adding exponential complexity. Maybe, as an industry, we should seek better tradeoffs? One example I can think of is preferring auditing over authorization. It's a lot easier to build a generic, unified auditing system and interface than to build sleek, fluent UIs that also have to accommodate arbitrarily complex authz behaviors.

- OTOH, I'm very keen on fine-grained controls over what data I grant third parties access to. For example, I want to be able to say, "grant this lender access to the last 18 months of account balance for this specific account" and exactly no more or less.

foobazgt··on The Rise of Worse Is Better (1991)
It's definitely in a class above Toyota, but once you account for gas savings, the LR RWD costs about as much as the cheapest Corolla you can buy. People bagged on Tesla being too expensive when their $35K car was only available over the phone. Now, adjusted for inflation, the LR RWD is $28K and comes with 100mi additional range to boot. On top of that, it's $13K below the average car purchase price.

IMO, it destroys its competitors in the value market, and the media is being awfully silent about it. I guess it's far too easy to focus on Elon instead.

foobazgt··on The Fastest Mutexes
> in which case it's all monitorEnter and monitorExit, regardless.

Oops, I need to correct myself!

ReentrantLock doesn't depend upon monitorEnter/Exit, but rather AbstractQueuedSynchronizer and LockSupport, which ultimately delegate to Unsafe methods like park/unpark and CAS (*compareAndSet*). Don't know why I had that confused in my head.

In any case, the point holds that "synchronized" as a language feature has mostly a zero cost for code that doesn't use it. It's a red herring when discussing modern Java concurrency.

foobazgt··on The Fastest Mutexes
"every synchronized function"

Right. Synchronized is the key word here. The vast majority of code doesn't involve synchronized, and therefore the vast majority of objects don't have locks associated with them. That's quite important.

Those classes which do use synchronized were just going to create a ReentrantLock held for the duration of the call anyway, in which case it's all monitorEnter and monitorExit, regardless.

> This is going to put a damper on any further conversation.

Sadge.

foobazgt··on The Fastest Mutexes
> because every object is its own mutex.

Not true in any practical sense.

> And you end up having to trade single core performance for multi core by deciding to speculatively calculate the object.

What is the alternative you suggest? If you care about having the predicate actually hold, and you also don't want to have to hold the lock while constructing the object, then you're going to end up in an optimistic-concurrency scenario where you check the predicate under lock, compute the object, and check again before swapping the value in. You may end up having to throw your work away when you discover the predicate changed. Java is no better nor worse at doing this than anything else.

foobazgt··on The Fastest Mutexes
Every abstraction is about outsourcing the thing it's abstracting away. If using a queue solves your problem, you no longer have to deal with all the headaches that you can run into using a bare mutex.
foobazgt··on The Fastest Mutexes
Composing locks isn't a Java problem - it's a fundamental abstraction problem with locks. This is one of the reasons why you usually reach for higher level abstractions than mutexes.

> And computeIfAbsent can end up holding the lock for too long if the function is slow.

How is this different from any other lock-holding code written anywhere?

foobazgt··on The Fastest Mutexes
Java's take on monitors was definitely not great, and people were emulating mutexes with them even in the language's earliest days.

Still there are a lot of things that can go wrong with mutexes: forgetting to unlock in the case of exceptions, priority inversion, recursive locking, deadlock, needlessly high contention, etc.

Java has had an excellent concurrency runtime with abstractions that are typically a better fit than a bare mutex for over 20 years now (c.f. Doug Lea). Synchronized still exists, because of Java's excellent backwards compatibility.

foobazgt··on Ryujinx (Nintendo Switch emulator) has been removed from GitHub
Sadly, sometimes there's a perverse incentive for lawyers to intentionally delay lawsuits so that they can reap increased damages/penalties.
foobazgt··on I Quit Teaching Because of ChatGPT
You don't allow students to use calculators for operations they haven't personally mastered. If you don't learn how to add two numbers on your own, the rest of your learning is in serious jeopardy.

This is the author's lament. These students are skipping over personal mastery.

foobazgt··on Mark Zuckerberg: "Ship the App" (2011)
He doesn't just say "why is this so hard?". He provides rationale for what he thinks is required and the effort it should take, posits some things he might have missed, and asks for more explanation. If you get a good-faith request like this from a technical manager, you should be able to point them at some docs or give a relatively concise response as to what they're missing. Honestly, you should have already headed this off, because the moment you realized you were in danger of missing deadlines, you should already be raising it as an issue and either explaining your plan or asking advice for how to get back on track.

If you're missing deadlines, you can't both complain a) when there's no accountability and the business is going poorly, and b) when your managers are trying to hold you accountable.

Ultimately your employer has to make money to pay you for your work. Keeping this in mind is one way to help you avoid yak-shaving, bike-shedding, and other weed-entering activities.

foobazgt··on How Discord stores trillions of messages (2023)
Sadly, I can understand why Discord doesn't have a lot of incentive to do this. Maybe the community should popularize an open-source free/low-costing bot and hosting solution for exported chat? (I couldn't find one in a few minutes of searching).
foobazgt··on How Discord stores trillions of messages (2023)
This blog post seems to blame GC heavily, but if you look back at their earlier blog post [0], it seems to be more shortcomings in either how they're using Cassandra or how Cassandra handles heavy deletes, or some combination:

"It was at that moment that it became obvious they deleted millions of messages using our API, leaving only 1 message in the channel. If you have been paying attention you might remember how Cassandra handles deletes using tombstones (mentioned in Eventual Consistency). When a user loaded this channel, even though there was only 1 message, Cassandra had to effectively scan millions of message tombstones (generating garbage faster than the JVM could collect it)."

And although the blog post talks about GC tuning, there's mention here [1] that they didn't do much tuning and were actually running on an old version of Cassandra (and presumably JVM) - having just switched over from CMS (!).

  0) https://discord.com/blog/how-discord-stores-billions-of-messages
  1) https://news.ycombinator.com/item?id=33136453
foobazgt··on Third Party Testing Paints Dark Picture of Tesla FSD
Perhaps a lifetime of watching my rear view mirror, scanning traffic up far ahead, keeping an eye on drivers next to me, etc, has made those tasks mechanically low-effort. I find them more engaging than exhausting.

However, on long road trips, autopilot definitely reduces fatigue for me far more than standard cruise. I'm hoping now that FSD is on interstates, it'll be even better. (Assuming they've fixed the issue where the new minimum speed signs in my area are being read as a speed limit).

foobazgt··on Third Party Testing Paints Dark Picture of Tesla FSD
I recently got 12.5.4, but haven't put it through the paces yet. My personal experience has been that I don't see very many (any?), critical interventions now. It seems to be handling the more complicated situations like unprotected left turns, roundabouts, etc smoothly.

However, it still doesn't serve a valuable purpose for me yet. I can't take my eyes off the road or my hands off the wheel. Instead, it's the opposite - I must still be hyper vigilante. In fact, it's even worse than that. Because it doesn't drive how I would, I find myself constantly intervening. E.G. I take over when I know there's a good spot to merge for an upcoming turn, but it's delaying the merge. You can force fsd to merge by signaling, but the navigable gaps between vehicles in heavy traffic can disappear faster than fsd will perform the merge. Then the maneuver shifts from reasonable to rude.

If I were just a passenger in the vehicle, I would probably care much less. But right now I'm the operator.

I don't know that anyone will ever train vehicles to behave how you would prefer to drive. I think the gold standard will rather be to behave as you find acceptable as a passenger.

For now, I'm appreciating the much improved summons. Having your vehicle pick you up in the rain is super nice.

foobazgt··on Rawdrawandroid – Build Android apps without any Java, in C and Make
FWIW, I spend a lot of my time writing low-level code, but more for desktop/server machines and less-so for mobile.

> SoA requires unboxed arrays, otherwise it defeats the purpose. I may have been wrong about int[] being boxed

Yeah, that's wrong. Primitive arrays aren't "boxed". An int[] is not an Integer[], and no boxing is performed unless you ask for it. SoA is fine in Java.

> the fact that ints still auto-promote to Integer in certain circumstances

It's pretty easy to avoid boxing if you don't want it. They are separate types after all. Even so, Android lint has an inspection for it, and Intellij (presumably Android Studio too?) has an inspection you can turn on to detect it [1]. If you're running afoul of autoboxing, it's probably mostly in collections-based code and you'll want something like fastutil [2].

> It's also hilarious that Value Objects are still in preview.

Agreed, it's been a long time coming, but they've been doing a good job of releasing features that don't need deprecating five years later.

> This is false. structs in C or C++ don't have a language-imposed overhead. They may have different sizes depending on the alignment requirements of the platform.

Sorry, I misunderstood your comment. You were talking about different overheads on different platforms, and I read that as general overhead. (For example, if you run the exact same x86_64 binary on an Intel and AMD processor from the same generation, you can get drastically different results. Heck, you can get drastically different results within the same family from the same manufacturer for a half-dozen reasons). In any case, I wouldn't lose sleep over the varying size of object headers on different platforms. In the cases it matters, you should be avoiding them altogether.

> Also hilarious. It's 2024.

I don't know when Valhalla will land, but the Vector API is far smaller in scope. It's on its 8th incubator, and seems likely to land soon. You could give it a try.

> Checking every single array access in a tight loop, for example, is stupid.

This is a red herring in most situations. Your array accesses did get elided, you need to rewrite your code so it's easier for them to get elided, or the checks didn't have a performance impact. Also, you dev for mobile in Ada?

> No, I am talking about Java.

You must not be, because there are no exceptions used for control flow in code I write or review.

> Oh, and how does Java do low-level systems programming without unsigned integer types, lol?

It's annoying. You don't cast, you promote through a mask, e.g. val & 0xFF; That said, jOOU [3] looks interesting.

> And you better hope you don't need more than the native size, because then you get fuck-boxed into Integer

I don't understand this. You aren't using more than "native size" on any platform in any language without some sort of emulated Big* type.

> Also, you don't even have a guarantee that a variable is allocated on the stack even when the dumbest compiler can tell it's bound by function scope.

Implementations typically have both escape analysis and a nursery generation for this. This works well in a desktop/server environment. I can't speak to ART. Ultimately, Valhalla will solve this for constrained implementations.

> I love LWJGL

I'm knee-deep in GDX and LWJGL, right now, but again not in a mobile context. I used to hang out in the Java gaming forums with the folks who originated LWJGL (e.g. cas).

> This is a criticism of the language, not the library

I think your criticisms are mostly with ART. I agree there are a handful of language changes that would make things easier for ART.

1) https://www.jetbrains.com/help/inspectopedia/boxing.html#loc... 2) https://github.com/vigna/fastutil 3) https://github.com/jOOQ/jOOU

foobazgt··on Porsche's idea for a six-stroke internal combustion engine
> If it's the only car you've driven for five years of course it doesn't feel sterile...

I don't understand what you're trying to say here, but clearly we disagree. To each their own.

foobazgt··on Porsche's idea for a six-stroke internal combustion engine
The model 3 is a track car [0], literally with a tunable track mode. It weighs less than other track competitors like the M3 competition. It is fun in the bends.

https://www.youtube.com/watch?v=oXqxiSZAevY

foobazgt··on Rawdrawandroid – Build Android apps without any Java, in C and Make
> JVMs imposing an 8-24 byte overhead per object

You want project Valhalla, or more specifically Value Objects, which are in preview [0]. If you really want the highest performance related to cache accesses, you want to arrange things as SoA (struct of arrays) anyway, which has approx 0 object overhead and doesn't require Value Objects.

> Not only is the overhead bad, it's implementation-dependent, i.e. unpredictable.

This is silly. This happens with all other languages, and Java will give you better results on average. Use a different compiler or runtime for your C code, or run it on a different processor architecture, and have fun tuning your code.

> That, along with lacking SIMD

The Vector API [1] is available in preview.

> imposing stupid decisions like bounds checks on all array accesses

It's widely understood that doing the opposite has been perhaps one of the largest mistakes in the history of the industry. JITs elide access checks when safe, and it's easier for them to do with high performance code that doesn't bounce around in memory and thrash cache.

> making arrays boxed (int[] is not an array of ints, sorry)

What does this even mean? An int[] is a linear array of 32-bit int values in memory.

> or using exceptions for control flow, which is the wrong way to use exceptions

Are we now just talking about a small slice of people who write bad code?

> is a just part of the big laundry list of why Java is a piece of obsolete crap

Ah, ok. Have a fine day.

0) https://openjdk.org/jeps/401

1) https://openjdk.org/jeps/460

foobazgt··on Porsche's idea for a six-stroke internal combustion engine
Model 3's didn't exist in 2012. Did you mean something else? I've driven an M3P for 5 years, and I wouldn't call it sterile.

I haven't been cross shopping it with vehicles that cost 3x as much and get only 15% of the mileage, so maybe I'm missing something? But weighing 10% more and taking 20% longer to reach 60 doesn't seem particularly compelling.

foobazgt··on Porsche's idea for a six-stroke internal combustion engine
I drove stick for a couple of decades. They were fun at the time (except in traffic jams), but I'm no Luddite. I can enjoy being thrown back into my seat with roller coaster acceleration without the accompaniment of vroom vroom noises, exhaust, and shifting.
← PreviousPage 3 of 8Next →