Better HN
topnewbestaskshowjobs
Log inSign up

codedokode

9,867 karma · joined Aug 20, 2015 (11y ago) · 5,528 submissions

PHP developer from Russia.
Submissions

comment 3y ago · link · parent

> With your favoured ISA style you can't just put 4 or 8 checked overflow add instructions in a row and run them all in parallel because they all write to the same condition code flag.

This can be implemented using traps, without flags. And RISC-V supports delayed exceptions, which makes the implementation easier.

> In this example you can't write back the updated r0 value until you know whether the instruction traps of not.

RISC-V supports delayed exceptions, so you actually can.

comment 3y ago · link · parent

That would be extremely irrational, to throw away money spent on designing, developing, testing, benchmarking, optimizing, debugging weird bugs, fixing that service just because you like another language.

comment 3y ago · link · parent

As Microsoft has shown, you are the product even if you pay them.

comment 3y ago · link · parent

A good solution is paid registration. Telegram did an experiments for this, but they asked too much (about $10-15 for not requiring a phone number) and you needed to buy their weird cryptocurrency.

If Telegram asked about $4 in BTC for anonimity, I would gladly pay for it.

It's interesting that this experiment shows how valuable is knowing your phone number and identity.

comment 3y ago · link · parent

> Modern processors can retire multiple additions per cycle.

Then add multiple overflow checking units.

> one of them has a throughput of 4/cycle and the other one will be 3/cycle and compiler authors will pick the former every time.

Currently on RISC-V checked addition requires 4 dependent instructions, so its throughput is about 1 addition/cycle.

comment 3y ago · link · parent

Also, here is a list of languages where '+' operator doesn't overflow: PHP, Python, Javascript and Swift. JS doesn't even have wrapping addition, and nobody seems to be unhappy about that.

comment 3y ago · link · parent

> So you are criticising RISC-V not compared to its actual x86 and Arm competition -- where overflow checking is also not free

Do you suggest we should carry on bad design decisions made in the past? x86 is an exhibition of bad choices and I don't think we need to copy them.

> and is seldom used

I believe it is not like this. I think that in most cases you need non-wrapping addition, for example, if you are calculating totals for a customer's order, counting number of visits for a website, or calculating loads in a concrete beam.

Actually wrapping addition is the one that is seldomly used, in niche areas like cryptography. So it surprises me that the kind of addition that is used more often (non-wrapping) requires more instructions than exotic wrapping addition. What were CPU designers thinking I fail to understand.

comment 3y ago · link · parent

> Compilers emit lea on x86-64 these days to save ports and you think they’ll use your faulting add that takes an extra cycle? Definitely not.

"Faulting" addition should be as fast as wrapping addition and take a single instruction. Yes, I want hardware-accelerated overflow checking because it leads to more accurate results and prevents security vulnerabilities.

By the way, I want FPU operations to cause traps too (when getting infinity or NaN).

comment 3y ago · link · parent

Yes the ugliness of the syntax for checked addition overweighs benefits like better accuracy and security from using it.

comment 3y ago · link · parent

> Checking overflow for addition on the other hand is something that is very seldom used (on any CPU).

I believe you are wrong. Almost every addition used in software should be a proper addition, not addition module 2^32 or 2^64. For example, if you want to calculate total for customer's order, you want proper addition, not a remainder after division by 2^32. Or if you are calculating a number of visitors of a website, again, you need the correct number.

Addition modulo N is used only in niche cases like cryptography.

In my opinion, it is wrapping addition which is seldomly used. I can't remember last time when I needed it. So it is surprising that RISC-V makes rarely used operation take less instructions than more popular one.

You might argue, that some poorly designed ancient languages have '+' operator to perform wrapping addition, however that is only because they are poorly designed, not because users want such method of addition. For comparison, a properly designed language, Swift has non-wrapping addition.

comment 3y ago · link · parent

USSR should have supplied a weakened metal that would be only good for pizza ovens.

comment 3y ago · link · parent

RISC-V ISA is very inconsistent. For example, for addition with checked overflow the spec says that there is no need for such instruction as it can be implemented "cheaply" in four instructions. But at the same time they have fused multiply-add which is only needed for matrix multiplication (i.e. only for scientific software), which is difficult to implement (it needs to read 3 registers at once), and which can be easily replaced with two separate instructions.

comment 3y ago · link · parent

I tried searching the spec [1] for "overflow" and here is what it says at page 17:

> We did not include special instruction-set support for overflow checks on integer arithmetic operations in the base instruction set, as many overflow checks can be cheaply implemented using RISC-V branches.

> For general signed addition, three additional instructions after the addition are required

Is this "cheap", replacing 1 instruction with four? According to some old mainframe era research (cannot find link now), addition is one of the most often used instructions and they suggest that we should replace each instruction with four?

Their "rationale" is not rational at all. It doesn't make sense.

Overflow check should be free (no additional instructions required), otherwise we will see the same story we have seen for last 50 years: compiler writers do not want to implement checks because they are expensive; language designers do not want to use proper arithmetic because it is expensive. And CPU designers do not want to implement traps because no language needs them. As a result, there will be errors and vulnerabilities. A vicious circle.

What also surprises me is that they added fused add-multiply instruction which can easily be replaced by 2 separate instructions, is not really needed in most applications (like a web browser), and is difficult to implement (if I am not mistaken, you need to read 3 registers instead of 2, which might require additional ports in register file only for this useless instruction).

[1] https://github.com/riscv/riscv-isa-manual/releases/download/...

comment 3y ago · link · parent

> you need to track the possibility of a branch at every single arithmetic operation

Every memory access can cause a trap, but CPUs seem to have no problem about it. The branch is very unlikely and can always be predicted as "not taken".

comment 3y ago · link · parent

Let's say someone makes a site that compares prices in different stores. It needs a lot of scraping, but is useful for consumers. Obviously, the only ones who are against it will be the store owners.

comment 3y ago · link · parent

This "feature hell" is often seen in open source projects, when users add dubious features that nobody except them needs, and as a result after many years the program has hundreds of CLI flags and settings and becomes too complex.

See openvpn as an example.

comment 3y ago · link · parent

RISC-V is copying wrong decisions made tens years ago. Against any common sense it doesn't trap on overflow on arithmetic operations, and silently wraps number over, producing incorrect result. Furthermore, it does not provide an overflow flag (or any alternative) so it is difficult to make addition of 256-bit numbers for example.

comment 3y ago · link · parent

I remember seeing this name but never heard of anyone using it. So I don't think that Youtube would copy an unpopular app.

comment 3y ago · link · parent

Let's take as an example a website which compares prices in different stores and shows which has the cheapest price. You can do it manually, but using automation it is faster and more convenient. Is doesn't make sense to read websites manually when you can use a script or a language model.

Obviously for consumer it is better to be able to scrape sites. It is only those store owners (greedy capitalists) who do not want consumer to know that their prices are inflated.

Another thing is looking for some information, it is better just to have a language model go around the web and summarize the data for you rather than read someone's site with white letters on black background and weird font.

comment 3y ago · link · parent

And why is there need for scraping proxies? Because greedy capitalists do not allow to scrape their sites.

comment 3y ago · link · parent

> Business has very strong "nothing matters once I have your money" policy.

Western business now has adopted "nothing matters once I got your personal data" policy though. It seems that "nothing matters" policy is not restricted to Asia.

comment 3y ago · link · parent

I see a section with short vertical videos on Youtube that strongly resembles a certain Chinese mobile app. Could it be that those Chinese developers, not respecting intellectual property, are now working for Youtube?

Or maybe not respecting intellectual property when it is profitable is just a worldwide tradition?

comment 3y ago · link · parent

> Rule 4: When we move out of a variable, we can't use it anymore.

> C++ doesn't have rule 4, in C++ the compiler lets us accidentally use the variable after we move out of it.

Why is it so? Moving is not a legacy operation, why did they allow to use moved-out variable?

comment 3y ago · link · parent

> during the recovery process got asked for a phone number.

Do you mean a phone number entered during registration, or an arbitrary phone number?

comment 3y ago · link · parent

> If it were possible to determine the program name in a way that was portable

Every decent OS in 2023 should provide a method for this.

comment 3y ago · link · parent

I think that in 2023 every decent OS should provide a method to get executable name. And every decent filesystem supports exotic characters.

comment 3y ago · link · parent

Modern disappearing scrollbars in Linux are an awful design:

- as scrollbar in browser disappears, I cannot see the position on the page and whether it is scrollable at all

- as scrollbar handle is very narrow, it is difficult to drag it

You might ask, why drag the scrollbar handle? Well, when you have tens thousands of lines in the terminal, it will take a long time to scroll it using touchpad or mouse wheel.

1
949596
185