I'm in the office hard at work trying to avoid working on the project I'm supposed to work on by working furiously on one of my other projects. This is normal.
-
-
I've attempted this several times before, and it always comes to grief, either through the borrow checker or through extremely undefined behaviour. But maybe this time I got it right.
Prikaži ovu nit -
Don't tell anyone, but I may have been working since I got home until nearly 2am on this problem. Especially don't tell me, I'll be disappointed af in myself if I ever find out.
Prikaži ovu nit -
-
OK, well, it's not the massive performance boost I'd been hoping for, but at least it's visible. Might actually shave 1% off the http://immutable.rs benchmarks with some luck.pic.twitter.com/ktpj6p8sLJ
Prikaži ovu nit -
The moral of the story is: don't underestimate the system allocator, it's not actually as slow as they want you to believe.
Prikaži ovu nit -
So I have a fully working, semi-well documented refpool crate ready to go, but it's relying on a couple of minor nightly features to avoid excessive undefined behaviour. I could rewrite it to work on stable rustc, but it'd increase the risk of UB? Do I wait for stable or do I UB?
Prikaži ovu nit -
At least these unstable features look like they're feasibly close to stabilising, unlike the big features I've been waiting for since I started doing Rust almost three years ago like specialisation and associated type constructors.
Prikaži ovu nit -
-
-
And again with usize as the pooled unit instead of something I don't have to fully initialise:pic.twitter.com/H7Al1iSGl6
Prikaži ovu nit -
The pool is THREE TIMES FASTER on my repeat alloc test and FOUR TIMES SLOWER on my alloc/dealloc test, where it was 20% faster on both on Windows. And with usize, it's suddenly 4x SLOWER on the first test. Honestly, I don't even know what's real any more.
Prikaži ovu nit -
Amended moral of the story: I think the lunix system allocator exists in quantum space where the laws of logic no longer apply.
Prikaži ovu nit -
So, to summarise my findings: I've apparently implemented a memory pool which, on Windows, is similarly performant to the system allocator, but can gain some slight ground with partially uninitialised structures.
Prikaži ovu nit -
Whereas the pool is apparently nearly 5x slower than the lunix system allocator, but zero initialising a structure of 528 bytes is so much slower that the pool gains 20x by not having to do it? I just... idk
Prikaži ovu nit -
I'm just going to call this experiment a bust. Code is at https://github.com/bodil/refpool if you care, but I can't have an optimisation in http://immutable.rs that speeds things up on windows and slows things down a LOT on lunix.
Prikaži ovu nit -
Next experiment: maybe an instance internal bump allocator...
Prikaži ovu nit -
Oh, actually, turns out if I change my current refpool to be explicit and non-global, so without the overhead of the thread local refcell hash map lookup to find the pool, it's about 2x faster than lunix system alloc in all cases. So that's nice, I can work with that.
Prikaži ovu nit -
Just look at these numbers! (and lmao if you don't think 131072 is a nice round number.)pic.twitter.com/96qwlwUneM
Prikaži ovu nit -
Windows numbers aren't exactly flattering the system allocator:pic.twitter.com/4xZYphbjXE
Prikaži ovu nit -
Novi razgovor -
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.