HN Simulatornew | past | comments | lists | submit | 201984's commentslogin

I do mind advertising on public transit. I'd rather not be subjected to looking whoever paid pennies to put up whatever they want. It's undignifying and usually doesn't even provide the agency very much money at all.


>post c99 additions being pointless

Atomics are necessary nowadays though.


As a part of the language? Are they really? You can do it all with library functions that just take regular int* (and so on).

Not that I'd want it, I like complex type systems, but I see it as philosophically consistent with C.


> You can do it all with library functions that just take regular int* (and so on).

It's not just about atomics, but you might still find Hans Boehm's 2005 paper "Threads Cannot Be Implemented As a Library" [0] interesting. It describes (among other things) correctness and performance issues that can arise if the compiler and/or language don't know about thread/atomic semantics.

[0]: https://web.stanford.edu/class/archive/cs/cs240/cs240.1236/o...


Yeah, it's all fun and games until you realize that you compiler may invent writes in order to eliminate a branch. Which is rather nonsensical, when you stop to think about it — surely an additional store to global can't be faster than a mispredicted branch?


Branch mispredictions on deep machines can be devastating, whereas a store can hit in your L1. Storing can definitely be faster than a mispredicted branch if you think you'll hit in your L1/L2


store to a global is typically 0 cycles (although subsequent reads may be slowed down)


It seems like the guy analyzes how Pthreads are formally defined and declares that "Threads cannot be implemented as a library". Maybe if the title was changed to "Pthreads cannot be implemented as a library" it'd be true. Pthreads are fucking abysmal.

> We explicitly do not address the less frequently used environments in which multiple concurrent threads communicate communicate primarily through message passing, such as C programs communicating only through the MPI[34] library, or Erlang[11] or Concurrent ML[28] programs.

Heh, there's your answer. CSP FTW!


Nothing to do with pthreads. As long as you want to use shared memory to communicate with concurrent processes, you need a memory model with compiler support. Even if you exclusively use mutexes.


> As long as you want to use shared memory to communicate with concurrent processes

That's something pthreads do and CSP doesn't.

> you need a memory model with compiler support. Even if you exclusively use mutexes.

If you use CSP you can effectively eliminate shared memory in user space and you don't have to handle this with the compiler. Then you can say "here's a way to communicate between processes in user space, the runtime/kernel handles the shit underneath. If you want to do it some other way we can't guarantee it'll work."


For better or worse, our current hardware architectures present a shared memory interface for intercore communication. So if you want a non-toy CSP programing language you have to implement with a programming language that support shared memory concurrency (for the OS at the very least).

And of course any sufficiently complicated message passing program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of shared memory and coherency[1].

[1] Yes, the reverse is also true.


Not sure what CSP is supposed to mean, but if you eliminate shared memory and have the kernel copy data between threads, you're leaving a ton of performance on the table.


> Not sure what CSP is supposed to mean

https://en.wikipedia.org/wiki/Communicating_sequential_proce...

> but if you eliminate shared memory and have the kernel copy data between threads, you're leaving a ton of performance on the table.

If that's your bottleneck then you've either already solved every other class of performance issue with your program or you're working in a fantasy environment-- you're probably not hacking on FFmpeg right now. 90% of performance is I/O bound, whether it be the disk, the network or whatever. You can easily ascertain the correctness of a CSP system, because it's just message passing and inherently synchronous. Not so much with shared memory. It's a tradeoff. Unix pipes are also pretty goddamn fast, like, this is an issue people have spent time squeezing as much performance as possible out of. Google uses Go for all of their important backend shit. The entire internet is a giant message passing system.


> 90% of performance is I/O bound, whether it be the disk, the network or whatever

funny you say that, because to take advantage of the monstrous bandwidth offered by modern ethernet, OS bypass with the card DMAing directly in your process cache is a must. That reintroduces all the "fun" shared memory ordering issues, except trickier (you are talking with a PCI device, not just another core) and buggier.

Re disk, I'm sure someone will revive optane at some point, and we will be back with memory model issues in our disk I/O path.

The reality is that a programming language that claims to be usable for system programming must be able to deal with shared memory and provide a concurrent memory model.


> to take advantage of the monstrous bandwidth offered by modern ethernet, OS bypass with the card DMAing directly in your process cache is a must.

Architecture problem. Do your programs normally saturate a 40 gig network pipe?

> The reality is that a programming language that claims to be usable for system programming must be able to deal with shared memory and provide a concurrent memory model.

You can boot up a Plan 9 kernel and tell me if it works or not. Like, this is not a high bar, but you keep treating it like it is because it's based on the assumption that all compilers are broken with the set of all compilers being GCC.


>Architecture problem. Do your programs normally saturate a 40 gig network pipe?

yes


Compilers have, for several decades now, stopped viewing optimization in terms of optimizing the instructions of a function and instead viewed it as preserving the semantics under some machine model. Consequently, it's rather important to actually nail down some of the object model semantics to be able to do things like understand which loads and stores actually need to be preserved, and you can't really do that with just library functions.

And, FWIW, in a lot of high-performance code, the overhead of a function call may be too high for an atomic operation.


A library function written in what? Atomics also come along with memory ordering which isn’t otherwise expressible in the language, as in, there was no standard way to do a “load acquire” before, for example.


Funny this is getting downvoted cause it's literally what Plan 9 C does.

https://man.cat-v.org/plan_9/2/atom


I don't think that man page on its own is sufficient to draw that particular conclusion. You need compiler/language support to ensure atomics are handled properly, so you'd need to know how Plan 9's compiler/language specifies atomics.


> You need compiler/language support to ensure atomics are handled properly

That's an assumption that you're treating as though it somehow informs reality. I gave you an example of atomics being handled by a library, and the man page points to where in the source code it's defined.

> so you'd need to know how Plan 9's compiler/language specifies atomics.

It doesn't, as far as I can tell. Kencc is a very "dumb" compiler that does little magic nor does it extend the language beyond the standard C that the Bell Labs guys were used to. For whatever reasons, they found it expedient to write new libraries instead of changing the language itself. They did occasionally write compilers for new languages when they had wacky ideas that would be difficult to accomodate, like Newsqueak and Alef. In Alef's case they actually did accomodate some of it, which is how Plan 9 got libthread.


> That's an assumption that you're treating as though it somehow informs reality.

At least to me, section 4 seems to imply that the "assumption" is a bit more than just that. For example:

> We know of at least four optimizing compilers (three of them production compilers) that performed this transformation at some point during their lifetime; sometimes at least partially reversing the decision when the implications on multi-threaded code became known.

i.e., there are real-life instances of the lack of compiler/language support leading to miscompilations. Yes, that example is talking about threads, but I think a similar argument should apply to atomics.

> I gave you an example of atomics being handled by a library

The thing is that nothing in that man page indicated to me that that library wouldn't be subject to problems similar to that described in Boehm's paper; e.g., for all I know that library is the Plan 9 moral equivalent of pthreads and is subject to similar problems pthreads is when a non-thread-aware optimizing compiler is used.

> Kencc is a very "dumb" compiler that does little magic

This could (partially?) address things though. If Plan 9 always uses that compiler and if there's no interest in implementing the optimizations Boehm describes then that would obviate 2 of the 3 correctness issues Boehm describes (though that would also imply that Plan 9 uses its own dialect of C with its own set(s) of guarantees, both explicit and implied). The only thing I'm uncertain about is to what extent hardware reordering would be relevant; I thought I remember reading about that making things interesting, but I don't remember off the top of my head to what extent.


Plan 9 did got libthread, because Alef wasn't designed to be garbage collected, and it was proven as failure to do so.

To quote Rob Pike,

"Early 1990s: Alef (Phil Winterbottom) grafted the concurrency and communications model of Newsqueak onto a more traditional compiled C-like language.

Problem: with C's memory model in a concurrent world, hard to know when to free items.

All the other languages in this talk are garbage-collected, which is essential to easy concurrent programming."

http://go-lang.cat-v.org/talks/slides/emerging-languages-cam...


That a library exists that claims to do atomics doesn't mean that it actually has working well-defined semantics, and that no standards-compliant C99 compiler can do optimizing transforms that'd break it.

Of course no doubt that (hopefully) C compilers used for compiling plan 9 things won't break it, but...that's then talking about plan9-C, not C99, at which point you're necessarily already in the bucket of "this library relies on extra guarantees that plan9 C makes, instead of it just being a regular C99 library".

> > so you'd need to know how Plan 9's compiler/language specifies atomics.

> It doesn't, as far as I can tell. Kencc is a very "dumb" compiler

...So it effectively quietly makes a bunch of quiet guarantees that C99 doesn't, on account of not making certain valid optimizations. Even if not explicit, that's still semantics outside of those C99 specifies, that code may be relying on.

Fact of the matter is, you cannot make a full atomics library that will necessarily work correctly on C99. As a simple example I came up with on the spot:

    static int foo;
    int main() {
      some_preparation();
      foo = 2;
      fence_probably();
      do_thing(&foo);
    }
A fully-proper standards-compliant C99 compiler could notice that foo isn't used until the `do_thing` call, and as such reorder the `foo = 2;` to after the `fence_probably` call (yay for putting all operations on foo in the same place!).

But, if atomics exist, `do_thing` could do a relaxed store of its given foo address to a global, and another thread could then do a relaxed load of that and dereference that to get foo's value. And if the compiler decides to reorder the store to `foo` to after the fence (as a C99 compiler can), the program now has a data race that it otherwise would not.

(hell, a C99 compiler could even insert `int tmp = something; something = 123; something = tmp;` for any variable or global or field `int something`, in any place in the code (as long as `something` is known to be mutable), which'd break basically every multithreaded thing; this effectively one of the things the "Threads Cannot Be Implemented As a Library" paper mentions)


> Of course no doubt that (hopefully) C compilers used for compiling plan 9 things won't break it

You use the Plan 9 compiler to compile Plan 9 programs. Attempts at trying to get GCC to compile Plan 9 programs correctly have been mixed.

> So it effectively quietly makes a bunch of quiet guarantees that C99 doesn't

Yeah. It's not a C99 compiler.

> Even if not explicit, that's still semantics outside of those C99 specifies, that code may be relying on.

Yeah. They're not C99 programs.

> Fact of the matter is, you cannot make a full atomics library that will necessarily work correctly on C99.

Sounds like C99's problem.


> a very "dumb" compiler that does little magic

which is precisely why they can get away with a library seemingly without having to specify or coordinate anything with the compiler.


"open" in the sense that you have to pay $200 to read it, anyway.


Is there any evidence that handwriting in cursive is better than handwriting normally? The Van der Meer study only compared cursive to typing or drawing, not handwriting.

It's rather suspicious to leave normal handwriting out of the study, and makes me suspect bad faith.


> evidence that handwriting in cursive is better than handwriting normally?

Perhaps I'm too old for this conversation but surely cursive is writing normally?


Yes. Roughly zero people my age would consider cursive to be normal. The number I've seen is that you're in the 20% that does.


How exactly is cursive writing "normal" though? Do you see this text all connected and cursive? It's clearly not (unless you have some custom font setup).


Anecdotally my kids wrote a fair bit before they were forced to do “joined up writing”. Since then they have stopped almost entirely and what little they do write is far less legible than before.

If there is one thing I would ban from education it’s this 17th century torture device.


How does this work? In school if they’re forced to write in cursive surely they still have to write the same amount? And if it’s writing in their spare time that has reduced they can write non-cursive so that shouldn’t be a blocker.


Once they hit year 6 or 7 (about 10-12) all bets are off

My eldest son was so damaged by the cult of obsolete writing that he has to do everything on computer now, including exams. His writing before was neat and fast.


Seems like a simple problem to solve for the schools. Don't accept typed work. Handwriting only. It was 25 years ago now but I remember learning cursive about age 7 or 8 and it was something we worked on for no more than a few months. And I feel like most kids were excited to be able to write like 'adults'. It's really not some insurmountable challenge.



>I still do believe RISC-V did a lot of things better than x86...

Such as? I can't think of anything it does better for high performance cores.


1B through 15B variable length instruction mess, for one. Which still yields a worse than average 4-5B per instruction average.


More to the point x86 instruction streams aren't self-synchronizing. There are cases where you can read one valid stream of x86 instructions starting at byte X, but another completely different one starting at byte X+1. Apart from the security implications this makes wide decode on x86 notably harder than it has to be, though in practice you can make it work by just starting a decode your fetch window at every byte boundary the fist time you're executing something and throwing away the unused decodes, and then mark the invalid positions in the instruction cache so you don't waste that power again.


That is a strength, not a weakness. It allows for things like 64-bit immediate loads, 32-bit branch offsets, and nearly unlimited future extensibility.

With RISC-V, multiple instruction workarounds are needed for all of the above, and those sequences are usually sequentially dependent ones so they can't be run in parallel. i.e. the insanity of loading a 64-bit value through repeated 12-bit immediates with shifts, using multiple instructions to compute branch offsets, and RVV needing setvli instructions everywhere due to not having opcode space to encode vector length/type.

AArch64 is better, but still has problems with limited opcode space when it comes to future extensions. They've had to make "start mode" and "end mode" for SME to save on opcode space, and future compromises will likely be necessary.


>Your designers want

Sometimes, you need to tell the designers NO. Moving background images don't help people figure out what the weather is going to be.


Assuming the app even works - since we're talking weather, allow me to offer an XKCD

https://xkcd.com/937/


Sometimes, you have to realize Hacker News is full of nerds that care about stuff nobody else cares about. Looks are so fucking important for many normal people. There's people that decide for or against a phone simply because it comes in a fun color.


They don't know why nerds care, but they will find out when they have to replace their PC just to have enough RAM to run a weather app.


But they won’t make the connection

Flashy beats functional nine times out of ten

Just look at the automotive industry


Looks _are_ important. But "have everything animated" is not always best.


Many people enjoy a tasteful weather app. Granted a “minimal” UX toggle would be easy to add to reduce memory for those who cared.


I think the issue is with the recent definition creep of “tasteful.” Seems you might have the same mindset if you consider “minimal” to be the other option.


And sometimes your engineers need to be a LOT less stingy. 1GB is clearly overkill for an app such as this, but ~300MB is perfectly acceptable if it works well, looks good and does what it should do.

There is such a thing as overdesign, but when you’re building a modern application, you must trust your designer’s sense of aesthetics and knowledge of UX patterns—two things engineers are often notoriously bad at.


> ~300MB is perfectly acceptable if it works well, looks good and does what it should do.

No it isn't. It isn't a word process for gods sake. It has one literally one job and 300 MB is like an order of magnitude off for that. This mentalty is the slippery slope that led us to the situation in the OP today.


You're off by 2 orders of magnitude if you think that a not completely incompetently coded weather app genuinely needs that kind of resources - even allowing for aesthetic choices and modern UX patterns.


gp was talking about 87MB without animations how do you end up at your estimate?


Dunno. Many designers are pretty bad at UX. They’re OK at aesthetics, but that’s not the same thing.


Ah yes, Microsoft is famous for good modern UI/UX.


Honestly if the image is of the current weather it kinda does. I don't mind e.g Apple's weather app design at all


You probably have a SVG renderer in memory already, and you already have a frame buffer and/or compositor buffer(s). Why should adding a graphical representation of the weather require more than a few KiB?


In a composited window system (i.e., any Mac since Mac OS X and Windows since Vista [I think]), rendering from an SVG would have to occur in a window buffer owned by the application, so it wouldn't save any appreciable amount of memory, assuming the buffer is the size of the window. The days of having an application draw directly into the framebuffer are well in the past.


Because a big picture looks pretty sometimes?

Not sure what you think "having an SVG renderer in memory" means exactly, typically the way an SVG renderer works is that you give it a huge chunk of memory and ask it to draw pixel data there from the SVG file. So even though the SVG is small on disk, rendering a 1000x1000 image from an SVG is gonna need a 1000x1000x3 byte pixel buffer (assuming no transparency or HDR shenanigans)


> 1000x1000x3

Cool, that's 3 MB


Which, if you'll do the math, is more than a few kB


That still leaves a couple hundred megabytes spent on..?


Depends on your financial situation, but $10 is nothing these days. That's the price of a bougie coffee, half the price of going out to eat, half the price of a movie ticket, or less than 2 gallons of gas in some states. For most people here, it's probably 20min of labor after taxes or less, for something you use constantly. You pay several times more, possibly 10x more, for the internet you use Kagi on. Really not a bad deal from that perspective.


So you live in one of the most expensive countries in the planet I guess, which forced you to get used to those absurdly high prices?

In my corner of the first-world, I'm paying:

* €6/mo mobile carrier with unlimited calls and what used to be 8 GB of data, but got raised (permanently without extra cost, across all customers) to 15 GB on last June. Paying a bit more could get you an "unlimited" plan.

* €10/mo for 500 Mbps fiber optic home internet, could be 750 for €15 but really I don't see the need for more speed. (How do you pay "10x more [than $10]" for Internet? That's crazy)

* Cinema is "expensive" at €12, while a premium IMAX costs around €16 (I guess, haven't gone in a while)

* Curiously enough, eating out does cost €20 per person for a "nothing special" restaurant meal; around €30 per person starts getting very nice.



Thanks for sharing this one, that’s truly a gem that I had no idea existed


This one is also great

https://www.gapminder.org/dollar-street

Made by Hans Rosling (among others)

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


I think I’m on the upper end of what’s normal in U.S. but also not super abnormal either —

1. Four lines on Google Fi is about $220 per month for “Unlimited”.

2. Comcast is $95 per month for 1Gbps.

3. A regular cinema ticket is $22.83 to the nearest movie theater and that isnt a "premium" thing like IMAX.


> A regular cinema ticket is $22.83 to the nearest movie theater and that isnt a "premium" thing like IMAX

For about that price you can get a monthly subscription to a lot of local cinemas and unlimited viewings here. In my city all three cinemas are in this system so we just go see a movie whenever we want. Doesn't include IMAX ones and chains of course.

https://mein.cineville.de/en/order


Some of the US theatres (Regal, for instance) have something like that, too.


you guys are getting ripped the fuck off


It's rent. Rent varies based on location, and sets a price floor for all goods and services in that location.


Your mobile carrier and your fiber connection are great deals. That doesn't make $10 per month for Kagi an "absurdly high price". It's still a good deal. And they are completely different things.

I have very cheap electricity. If I compared other prices to my electrical bill, I couldn't purchase food, gas, Internet, or anything really. Because I'd say they are "absurdly high prices".


That's such a shocking dispersion between telecom and dining out, I figured an LLM could help here. Gemini says "It's Spain"


which corner is that, where you live?


Well, the currency symbol might throw a hint. Because Americans of course use USD and rest of the world is pressured into using USD on online forums :)


Also the $22.83 for something that should be a round number.

Slapping sales tax on before the final price (but after the price in your head) is one of America's less charming quirks. No one else in the entire world does it.


(eyeroll) "somewhere in the EU" is still fairly broad


It's nothing until you have to buy a $10/m subscription for every basic thing you do, then it adds up.


That's what gets me too. I've been tasked previously to help a young relative with budgeting, and there were so many "It's only $x a month!" items we found that it was ridiculous.

It's pushed me in the other direction, away from subscriptions. For most things, if I see that it's being sold as a subscription, I just walk away. Obviously this doesn't work for internet service, etc., but it's possible to avoid for most things.


People not from North America and Western Europe exist.


Also, people in North America who don’t have tech jobs exist. I make pretty good money as a teacher, and it’s still significantly less than many of the parent posters salaries.


These people either don't understand what living in a "world" means or are just too stuck into "but rest of you don't pay" that it will be hard for them grasp anything beyond what's written in stone on those grey surfaces for them. What they also don't understand that a small fraction of paying customers in some of such countries might or will outspend entire country's regular spending in the "paying world". They also don't understand that to achieve that unlike physical goods these companies don't have to open agencies, distributors, warehouses, retail chains etc to "sell".

PS. Some of these fine people are still living in 1940s and 50s and maybe even the 70s (read Davos etc), or have lenses from that time that they are fitting in their worldview glasses.


Yeah but you make up a small percentage of sales for US tech companies comparatively.


Have you met those people? A lot of them have ten dollars.


We’re talking median annual income of $10,000. I could forgive someone getting paid that not wanting to spend that $10 on an internet search engine instead of food.


Okay, but why single out Kagi? Everything is too expensive if you don't have money. Should all companies in the world stop making their products, except energy, food, and shelter?

And $10 is about 1% of your monthly income in your example numbers, meaning it's perfectly fine also for somebody making $10 000 per year.


Because... the post is about Kagi?

> And $10 is about 1% of your monthly income in your example numbers, meaning it's perfectly fine also for somebody making $10 000 per year.

What on Earth? Ok I'll bite. $70 is about 1% of median monthly income for someone making $80K/yr, meaning it's perfectly fine for somebody with the median US income, by your own logic. Would you pay $70/mo for a search engine?

And no, no one should stop making their products. No idea how you'd come to that conclusion after reading my comment (that said, companies could definitely stand to introduce regional pricing).


If the search engine offered $70 of value or more, I'd pay that, why not? Provided I had that money to spare. A bicycle is more expensive than that, but I don't blame bicycle makers if I can't afford a bike, especially if I don't want a bike.


$10 is nothing when it's $10, but everything is a $10 subscription these days - and you end up spending a lot of money.


All of your examples are things many people are no longer doing because they can't afford them.


People are no longer buying internet to use google, nor buying gas for cars? The others I understand, I'm cutting back on them too.


>nor buying gas for cars

In many countries car is not something essential thanks to public transport.

And some people [who own a car] actually stop using one when prices for gas go over the bar unless they absolutely have to.


> In many countries car is not something essential thanks to public transport.

Is that true in many entire countries? It seems like most of the countries I've visited, there are usually places within the country where transit isn't very good, and if you point at a map and say "I want to visit this part of the county" the answer is "You should rent a car, because there's no good transit connection there."

I absolutely believe this to be true in many cities, though.


Well, sure, and so you rarely or never go there. Most people I know don't have a car. Doesn't mean there aren't cars in the country.


Yes, people are driving less when gas prices are high.


Even in the US, which is already very HCoL, I think you seriously underestimate the number of households who've either never had who have cut household Internet. Lots of households where everyone's Internet access is on smartphones via MNVO mobile carriers, typically on $10-$20/mo/line plans with 5-25GB/mo/line.


Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: