Readit News logoReadit News
wholesomepotato commented on Parsing 8-bit integers quickly   lemire.me/blog/2023/11/28... · Posted by u/usdogu
RaisingSpear · 2 years ago
Adding the length means another shift+or operation at minimum. I already think this is slower than the technique presented in the article, and this would make it worse.

It's an interesting idea, but I don't see it being practical, even if the size of the table wasn't an issue.

wholesomepotato · 2 years ago
Instruction level parallelism will make extra shift free. Other than this it needs to be benched and might depend on cpu/arch. I don't care enough to bench and optimize further.
wholesomepotato commented on Parsing 8-bit integers quickly   lemire.me/blog/2023/11/28... · Posted by u/usdogu
RaisingSpear · 2 years ago
The '& 0xfff' eliminates the highest byte, so it doesn't matter what it is.

Your code doesn't handle the 'length' parameter, so the problem isn't the highest byte, it's bytes beyond 'length'.

wholesomepotato · 2 years ago
I think you're right. Even better. Did you have time to bench it, etc.?

I see what you mean by length. I just skimmed over the text originally as I don't have time for rather lame problems like this. I'd just add 3 bits of length to be part of the index, job done. 12KB lookup table instead of 4KB, assuming 0 is not a valid value (negate to avoid needing 0b11).

wholesomepotato commented on Parsing 8-bit integers quickly   lemire.me/blog/2023/11/28... · Posted by u/usdogu
RaisingSpear · 2 years ago
I can't see how it's any different. If you have 0x0y0z, a shift+or gives 0x0yxz, so the result is same as what you have, just with fewer operations.
wholesomepotato · 2 years ago
It's unclear what is in the highest byte, so I assume not 0x000x0y0z, but 0xab0x0y0z where ab is unknown (in the past comment I used XX for this). If highest byte is known, then sure, even better.
wholesomepotato commented on Parsing 8-bit integers quickly   lemire.me/blog/2023/11/28... · Posted by u/usdogu
RaisingSpear · 2 years ago
That's kinda neat. Actually, if you're doing that, you may as well reduce it to a single shift+or:

a = ((a >> 12) | a) & 0xfff

You could also skip the xor with 0x303030 by adjusting the lookup table accordingly.

Unfortunately, you'd still need to factor in the length argument somehow. That is, if given "23" with length=1, it should parse to 2, not 23. You could address this with a variable shift, but at that point, I can't see it being any better than a multiply+shift, even assuming the lookup table is fully cached.

The other major issue is validation, which the lookup table doesn't help much with.

wholesomepotato · 2 years ago
Might be wrong but this shortcut corrupts the lower bits with garbage from the higher byte.

The lookup table can detect some, but not all errors, so yeah, it relies on valid input.

wholesomepotato commented on U.S. GDP Grew at a 5.2% Rate in the Third Quarter, Even Stronger Than Indicated   cnbc.com/2023/11/29/us-gd... · Posted by u/Judyrabbit
sudosysgen · 2 years ago
You can't inflate away government debt, not meaningfully, because it's almost always going to be at a rate higher than inflation by construction.
wholesomepotato · 2 years ago
Yes, but also - they lie about the inflation and force the public to hold the bonds anyway (aka. financial repression, yield curve control).
wholesomepotato commented on U.S. GDP Grew at a 5.2% Rate in the Third Quarter, Even Stronger Than Indicated   cnbc.com/2023/11/29/us-gd... · Posted by u/Judyrabbit
avmich · 2 years ago
Whoever's lived long enough in USA would laugh about end game questions. Inflation? 3.2% is absolutely peanuts to what it was some 3-4 decades ago. Unemployment? Are you kidding? Pandemics? Did you compare what it is today with what it was 2 years ago? COVID is just 4th - which is a lot, but very far from mortal danger - cause of death, and the country even inches up in life expectancy. All fundamentals are pretty much positive, and only debt/GDP is vaguely comparable to the worst numbers in US history.

Now, what about alternatives? If you don't like US numbers, can you get anyplace better on Earth? I'll wait. Meanwhile, there are forward-positive questions and topics - USA is about to jump in 2, count 'em, two very consequential areas, which are AI and space exploration, within this decade. Are you sure your better bets are against USA? Did you take the history lessons into account, or it's business as usual?

wholesomepotato · 2 years ago
I'm sorry but most of your comment has nothing to do to what I said, and seems like random rambling. Except:

> 3.2% is absolutely peanuts to what it was some 3-4 decades ago.

But 3-4 decades ago governments, all institutions and economy as as whole were not so much in debt. https://fred.stlouisfed.org/series/GFDEGDQ188S . And this chart doesn't include all the "unfunded liabilities".

You can hike rates to curb the inflation only if it doesn't bankrupt everything and everyone.

And 3-4 decades ago boomers globally were ahead of most productive years of their lives, without the "baggage" of tons of kids and globalization had plenty of room ahead to increase productivity.

I don't want to waste time talking about nonsense like AI and "space exploration". The financial system is screwed. That's all I'm saying.

wholesomepotato commented on U.S. GDP Grew at a 5.2% Rate in the Third Quarter, Even Stronger Than Indicated   cnbc.com/2023/11/29/us-gd... · Posted by u/Judyrabbit
andrewmutz · 2 years ago
Amazing that the US economy is growing at a faster rate than the Chinese economy:

https://www.reuters.com/world/china/chinas-q3-gdp-grows-49-y...

wholesomepotato · 2 years ago
What's amazing about it if the debt increased more in the absolute terms? :D . If I max out credit cards I can at least show spending (GDP) growth at least the same as what I borrowed...

How is it not obvious to everyone that this is the end game? Increasing rates will rapidly increase debt, which increases inflation, which pushes increasing rates ...

wholesomepotato commented on Parsing 8-bit integers quickly   lemire.me/blog/2023/11/28... · Posted by u/usdogu
RaisingSpear · 2 years ago
How are you packing the number into 12 bits? Multiple shift+and+or operations? If so, I'd expect that to generally be slower than a multiply+shift.
wholesomepotato · 2 years ago
it's one XOR, SHL, OR, SHR, AND, on some archs the shifts might come free with the other instruction. I'd expect it to be faster.

a = v ^ 0x30303030lu // normalize to digits 0xXX0a0b0c

b = (a << 12) | a // combine into XXXXXbacb0c

idx = (b >> 12) & 0xfff // get bac

res = lookup[idx]

wholesomepotato commented on Americans Are Pulling Cash from Their Retirement Savings to Pay Bills   bloomberg.com/news/articl... · Posted by u/marifi
cced · 2 years ago
I thought the Fed was private.
wholesomepotato · 2 years ago
What products/services they produce if they're private?

They're in this sweet spot where they're neither held accountable by the voter, nor by the consumer.

The can be wrong over and over and over again and nothing is going to happen. A private company has to at least not loose more money then they can bribe politicians to give them.

wholesomepotato commented on Americans Are Pulling Cash from Their Retirement Savings to Pay Bills   bloomberg.com/news/articl... · Posted by u/marifi
stillwithit · 2 years ago
Given all the data modeling the powers that be have access to I find it hard to believe such outcomes aren’t intentional.

If Exxon can correctly model climate change back in the 1980s the Fed can correctly model how deep to cut others to hamstring the masses acquisition of assets for themselves over 12-24 months

wholesomepotato · 2 years ago
Exxon is a private company so some basic level of competency can be assumed. The Fed is basically bunch of incompetent academic buffoons.

u/wholesomepotato

KarmaCake day115September 8, 2023View Original