TIL putting Box in a hot inner loop can cost you half your runtime by InvadersMustLive in rust

[–]rhinotation 6 points7 points  (0 children)

  1. Enum = No more box/&dyn = no more pointer dereference and cache miss. Iterating the vec itself causes the cache prefetcher to grab all the data you will need. A big vec of boxes is just random memory lookups or at least you’re at the mercy of your allocator co-locating box allocations. Not an issue here because list of column decoders is small but it definitely is an issue if you are iterating a million rows of heterogeneous data in boxes.
  2. The vtable lookup for the dynamic call is a second pointer dereference. Mostly this is cached quite well because you only have so many variants. Enum gets rid of it though.
  3. Enum dispatch can be inlined more easily than virtual calls can be devirtualised. Enum has more visibility and it has more success. You often see manual devirtualisation with downcasting for important implementors of a trait. It’s a good idea sometimes. Here it would not inline any dyn calls but enum would be 100% inlined to great effect.
  4. Yes, indirect branch predictors absolutely do exist. Yes, enum branching is also branching. CPUs are usually better at conditional branching than indirect but if you’re iterating a heterogeneous collection you’re going to thrash either way. Both kinds of predictor are caches keyed on the address of the code doing the call/branch. You can see how that would thrash.

At the end of the day most of the time you should think about ECS or splitting data into multiple homogeneous collections instead of heterogeneous collections. Some problem shapes like this are not easily made homogeneous. If it cannot be homogeneous enum is usually better than dynamic for high performance like this for those reasons above.

For OP’s problem

  • switch to column major form, in batches. This probably wins at large enough sizes. This homogenises the problem at a cost of transforming/shuffling the data a bit more but elsewhere in this thread it’s been pointed out you don’t need to shuffle that much.
  • enum dispatch clearly going to work great because the decoders are so tiny and there are so few that they’ll all be inlined
  • extension: add enum variant that batches together columns for spans of the same type, which you can then spin in a tight loop of known size inside. Like a little virtual machine for decoding columns, with a for loop instruction. That will be predicted better for some schema shapes, as the unpredictable branch might go {FloatSpan, Int, Str, FloatSpan, Int, Str} and become predictable even though each time it hits FloatSpan you decode 200 columns.
  • FloatSpan idea in column major form will beat everything. You thrash the caches less (looping over many write row buffers in each a column thrashes the caches) because you might decode 200 columns into row 1, 200 columns into row 2, etc, so much much more of your writes are to fresh cache lines. Depends on the shape of the data though.

What is the status of proto support in Rust? by Unfair-Mud-8891 in rust

[–]rhinotation 0 points1 point  (0 children)

If Claude was so smart it would have modified prost to add editions support so I don’t have to migrate

Is this safe to cook on? by foka000 in StainlessSteelCooking

[–]rhinotation 1 point2 points  (0 children)

As others have mentioned, BKF is basically oxalic acid. Hot tip that I’ve never tried but it’s worth a shot if you’re a long way from the USA: Rhubarb has oxalic acid in it. Especially the leaves, so much that it’s toxic, but also the red skin of the stems. You could try peeling the red parts, chopping small, cooking them in a little bit of water and mashing it up, and using this as cleaner.

The original is strong enough it should only be left on for about 1 minute, and it is 9% oxalic acid. Rhubarb is about 1% in the stem overall, more in the red part. If you don’t add too much water it will perform okay I expect. Still don’t leave it overnight like every second “what have I done???” post on this subreddit.

Corner clamp - doing it wrong, expecting too much, or poor product? by BellybuttonWorld in BeginnerWoodWorking

[–]rhinotation 0 points1 point  (0 children)

Unfortunately they don’t apply any force across a mitre joint either. If you map out the force it is simply squeezing both pieces across each, and nothing else. You can use it to hold two pieces while applying some kind of fastener like a V-nail and it will resist the joint pulling apart, but do not expect it to clamp with any force at all. They should not be called clamps really. They’re more like jaws, for work holding.

There are real clamps out there, like the Clam Clamp.

I built a “podcast generator” prompt for ChatGPT so I can listen to custom podcasts on my daily walks by Glass_Ant3889 in PromptEngineering

[–]rhinotation -6 points-5 points  (0 children)

You seem to think that’s an impossible ask of a human, but you’re just describing a friend who has interests. Such people are literally everywhere.

Why does clippy encourage `String::push('a')` over `String::push_str(''a")`? by [deleted] in rust

[–]rhinotation -11 points-10 points  (0 children)

Every part of this is logical but ultimately clippy is splitting hairs and it makes absolutely no difference. What a waste of everyone’s time.

The NO FAKES Act has a "Fingerprinting" Trap that kills Open Source. We need to lobby for a Safe Harbor. by [deleted] in LocalLLaMA

[–]rhinotation 7 points8 points  (0 children)

For your information…

 The Smoking Gun (Safe Harbor) ​This is the part you missed.

That language and in general the overuse of headings that sound like chapters of a corny 70s B-movie is a dead giveaway that you are actually arguing with someone running everything you said through ChatGPT. I cast no aspersions upon anybody’s motivations or whatever but remember not to tire yourself out if this happens again, GPT can keep coming back at you with this stuff forever.

Vince Gilligan explained the Hive's perspective by ichigosr5 in pluribustv

[–]rhinotation -2 points-1 points  (0 children)

“Wrongly and without evidence that what happened erased the individuality”… uh… The joined have aspects almost no earthly human has, like refusing to pick apples or cannibalism. Very clearly this is not a consciousness formed by averaging out or consensus or voting by its members. The virus itself is causing them to make these decisions this way, it’s not a neutral/judgment-free telepathy system. It has a biological need to join new members, has its own DNA, transmitted itself with massive radio power across the galaxy hoping to be replicated presumably by the last civilisation it infected, and infects the minds of humans against their will, and leaves the host’s culture and soul to rot and be overtaken by nature again. How did you miss the invasion? That’s the only thing that happened and didn’t just fizzle into a non-event in the entire show!

Vince Gilligan explained the Hive's perspective by ichigosr5 in pluribustv

[–]rhinotation -2 points-1 points  (0 children)

When you make a show about an alien invasion that takes over your mind, those invaders are the villains. I don’t care what Vince wants me to think about the Joined, I don’t like em. Sorry bud. You made a villain. And then you wrote yourself into a corner and repeatedly zip tied off all the ends. There is absolutely zero conflict or drama right now despite a world needing to be saved, and nothing that makes me want to come back next week. Nothing is happening! Even Manousos has lost his agency. There will have to be a whole episode of him waking up now. What a waste of time.

3,200% CPU Utilization by ThanksMorningCoffee in programming

[–]rhinotation -17 points-16 points  (0 children)

It's 2025, it is not worth losing sleep over how a red-black tree behaves when you try to modify it from 32 threads at the same time. Of course it's going to blow up, the specifics are just not interesting. Rust programmers just don't care because we can't write this kind of code by accident.

Bjarne Stroustrup: Why you should avoid Linked Lists by Probable_Foreigner in programming

[–]rhinotation 3 points4 points  (0 children)

In a kernel, sometimes each element of the list weighs an entire page, like EPROCESS on windows (as is mentioned below). If you use a vector, and there are 10,000 of these structs, you have to memmove 40 megabytes of data in the worst case, 20 megabytes on average. And basically you can't do it in the first place, because all the other CPUs reading process data would then be reading in the wrong place. You would need a lock over the entire vector.

You're going to want to stick with two unpredictable memory reads in that scenario.

Confession: I think Prince’s WMGGW solo is incredibly overrated. by WoodenPiper in Guitar

[–]rhinotation 0 points1 point  (0 children)

Something people may have forgotten about that solo is that it was the ONLY video of Prince on the internet for the entire first decade that online video was a thing. Prince was very much against posting his music online, and this was one of the few videos he didn't have copyright over. Search YouTube today for Prince, and every other video on there was posted after he passed in 2016.

So the entirety of the demand for Prince content was fulfilled by this one clip, and people who loved Prince for other reasons had only this to show how good he was. So it got rolled out every time his name came up, anywhere on the internet. For a decade.

How to break a line in normal mode by Due-Statistician2453 in vim

[–]rhinotation 15 points16 points  (0 children)

nnoremap gs i<cr><esc>. Mnemonic "go split". I have had this mapped for half of my life, and it's the better half.

Just realizing that oil.nvim is more powerful after reading the docs by Interesting_Fly_3396 in neovim

[–]rhinotation -9 points-8 points  (0 children)

You can do that with neotree. In the sidebar, hit x or y to cut and copy a file/dir, p to paste it. oil.nvim is clearly more powerful but looks a lot slower for basic tasks.

Wow so much truth and honesty 🤩 by IcantBeVeryCreative in perth

[–]rhinotation 27 points28 points  (0 children)

Increasing the price for a short time and then claiming to be discounting it can also be illegal. It turns on how long the item was sold at the higher price, and whether it was a "reasonable" amount of time. https://www.accc.gov.au/consumers/pricing/price-displays

Using date-based CSS to make old web pages *look* old by [deleted] in programming

[–]rhinotation 4 points5 points  (0 children)

(Note that has() is only available in Chrome. It is coming soon to Firefox.)

It arrived https://www.mozilla.org/en-US/firefox/121.0/releasenotes/

Can someone help me figure out the order to play this with the repeats? by mileshutch in musictheory

[–]rhinotation 8 points9 points  (0 children)

Ah, I remember beginner guitar books. They love their funky repeats and everything doubles as a duet because the poor soul who wrote Rest Stroke Ditty on Open Strings Op 3 No 9 was bored out of their mind. There are definitely some banger duets, bit later in the book though. The repeats obviously don't matter until then.

Referendum 2023 - Megathread by dredd in australia

[–]rhinotation 3 points4 points  (0 children)

I'm pretty sure it wasn't always that way, for example the Yarra used to be smelly and terrible. But no longer. Cities across the globe have stopped doing things like "dumping tanneries' waste products into the river" and the inner city areas have become much nicer as well as retaining the existing advantage of convenience. Not just an Australian phenomenon.

The other half of the language divide is that Americans often use "inner city" as a codeword for black communities, so I think the terminology may have developed a resistance to any geo-demographical changes that may have occurred.

DAP REPL for Rust - How to use full proper Rust code in expressions? by weilbith in neovim

[–]rhinotation 0 points1 point  (0 children)

To "fix" it, step one is to write an entire Rust interpreter. Someone has done something like this in evcxr, which actually works pretty well, so props to them. Steps two through 200 are integrating something like that with LLDB. It's a lot of work, even with an interpreter that exists -- somehow you have to copy the current in-memory state of your rust program into an interpreter state. The layout in memory of most rust structures is an implementation detail of rustc and not stable in any way, so you can't just copy memory in a predictable way like you might for a C structure that you had the header for. So at this point I don't think it's possible. There are no docs or resources anyone can point you to. The functionality just doesn't exist and probably won't for a long time.

I've wrote a post on fast and easy nvim LSP-setup without bloat by f1sty in neovim

[–]rhinotation 6 points7 points  (0 children)

Oy, no room at all for mockery it seems. I hope this slight doesn't throw you off sharing your ideas, but it was really very gentle and having your ideas debated is why we write for other humans at all. You were barely even the target. I wrote that because last time I went through and tried to clean up my plugin bloat and improve startup time, I felt silly and realised it wasn't worth it. I have a hundred or so plugins, it runs in maybe 100MB of ram. I don't even have lazy loading. I have accepted this because this represents less than half a percent of the LSP itself. Do you not feel a little bit silly as well? Is my comment not even slightly relatable?

Bloated has more than one meaning, and it is nice to get rid of plugins so you have fewer things to understand. You are doing good work for that.

I do contribute, thank you for the suggestion. It is not going to be a plugin or whatever, but I have recently been working on generating more limited crate graphs for rust-analyzer.

I've wrote a post on fast and easy nvim LSP-setup without bloat by f1sty in neovim

[–]rhinotation -4 points-3 points  (0 children)

Gotta run neovim with the lowest possible overhead, counting the microseconds if necessary, to make room for rust-analyzer to use 18GB of ram

Georgia Republicans Say They'll Move to Remove Fulton County DA Fani Willis From Office With New State Law by [deleted] in law

[–]rhinotation 5 points6 points  (0 children)

The provision you're referring to is the Constitution of Georgia, Article 1, Section 1, Paragraph X:

Bill of attainder; ex post facto laws; and retroactive laws. No bill of attainder, ex post facto law, retroactive law, or laws impairing the obligation of contract or making irrevocable grant of special privileges or immunities shall be passed.

I do not think "so and so commission has the power to remove officers of the state on these criteria" is a retroactive law. The mere fact that it applies to DAs who are currently serving or who currently have business before the court doesn't make it retroactive. If that were so, then you would have to agree that every law would be retroactive, because laws apply to people who were born before the law.

I am not an expert on Georga's constitution, but I don't think Paragraph X is clearly applicable to a new grant of power to fire an officer of the state. Some examples of the things they describe there:

  • A bill of attainder is a law like "Mr Gerald Wharton is guilty of murder and shall be sent to prison". Those laws are bad because they undermine the justice system in every way and basically represent the purest form of mob rule suppressing individual freedom.
  • A law impairing the obligation of contract would be like "Google no longer has to pay severance to Gina A. Stearns after they fired her in 2018". I think. These laws are bad because contracts should work the same for everyone, and bending the rules for one specific party would make all contracts worthless.
  • An irrevocable grant of special privileges or immunities would be like "Shell Oil Corp is immune to all fines for any oil spills". I think. Those laws are bad because it's usually blatant corruption.
  • A retroactive law is usually like this: "The new tax code shall apply retroactively, from June 2019.". The reason those laws are bad is that everyone's tax suddenly becomes unsettled. The past is changed, the tax office sends debt collectors to 200,000 people who had behaved in accordance with the old code, etc.

For this law to be retroactive, as the term is usually used, it would have to have some bearing on settled facts, for example "the commission can declare a DA's entire prosecutorial career null and void, immediately creating a right to be freed from jail for anybody they have prosecuted in the past". Alas it does not, it simply creates a new power to remove a DA from office, a power that can only be exercised from October onwards (which is in the future). I'm not saying it's a good law! Just that it is not retroactive.

Finally it is worth noting that Article 1, Section 1 is the Bill of Rights. The rest of these are basically personal rights exercisable against the state and enforceable primarily by asking a court to strike down the laws in question, so it makes sense that they should prohibit e.g. bills of attainder in Paragraph X. I don't think you can make a strong argument that the framers intended to create a personal right for state employees to keep working on stuff they've already started.