Rule 34 XYZ
Loading...

Shuffle

14 days ago by Sieghard

shuffle.jpg

This is a minor update before a big one.

People have been asking me for a long time to add shuffle to likes, playlists, and the main page. I've tried to build it a few times already, and trust me, this problem is a lot harder than it looks. A true shuffle needs either a lot of CPU, a lot of RAM, or a lot of disk space.

Either way, a lot of something.

The simplest and most direct approach is to sort all posts randomly at request time and return the result. But on a large database that's a brutally expensive operation. Pagination is a problem too. You need to keep the sort order stable so that page two is guaranteed to have no posts from page one. Which means you also need to store the seed of that shuffle somewhere.

This time I managed to solve it without putting any serious load on the server. The only catch is a 20k limit for likes, playlists, and bookmarks. The main page has no limits at all.

How it works

If you don't care about the technical details, just scroll past.

Instead of reshuffling posts on every request, I sort them by hash. A post's position in the random order is computed as hash(post id + salt). The salt is just one number, shared across the whole site, so the order is fixed and known in advance. For the main page there's a regular database index built on top of that order, and grabbing a random page is as cheap as any other, no need to re-sort millions of posts on the fly. The posts actually got shuffled only once, and the randomness you see on every refresh is an illusion. To make it work, and to make the posts look random every time, you just start from a new random point in that sequence and go around it in a circle. Once a day a background job generates a new salt and swaps the index, and that's when the posts get reshuffled for real.

All the traversal state lives in a cursor that goes back and forth between the browser and the server, so the server stores nothing and spends no memory on sessions. You get proper pagination out of this for free. Page two is guaranteed to have no posts from page one, a full walk shows every post exactly once, and refreshing the page just starts a new shuffle. Likes, bookmarks, and playlists don't need an index, the hash is computed on the fly over your selection. But that means the cost of a page grows with the size of the feed, and that's where the 20k post limit comes from. It doesn't affect the main page, that one is served by the index.

Reverse sorting

By default everything is sorted from newest to oldest. For likes that means from "recently added" to "added long ago". People have been asking me for reverse sorting for a long time.

Here it is. Enjoy.

Bigger blacklist limit

When I look at the content on the site, I get that not everything works for everyone. And as it turns out, a blacklist of three tags is just too small. So I'm raising the limit to 10 tags. That should be enough for most of you.

If you don't have these changes yet, they'll show up during the day.

The thing I've been teasing for a while

soon.jpg

Just wait a little longer, almost everything is ready. I'm ALREADY writing the announcement. I need to get everything in place first. I think it's very close now, probably next week.

Comments

To comment you need to sign in or sign up
Or
Sieghard6 days ago
Thank you all for the kind words, I love you ^_^
metamorphosis6 days ago
youre goated man, love the changes
ㅤㅤㅤ8 days ago
Please, someone explain how this works. I can't quite figure it out, to be honest. ×_×
lime9 days ago
Can you add multiple playlist adding? Instead of just being able to add a single media at once per playlist
Celestial10 days ago
Can someone help me get putrid seaweed in fisch
isaacenriquecarmona10 days ago
👀🍍
bumbum12 days ago
This is it. This is all I've ever wanted. You did it. And I love it.
Damian12 days ago
The goat
Nishiniro13 days ago
GIF
KiggerNiller13 days ago
actually goated
Mr.PL13 days ago
Peak
Creamlover13 days ago
Another banger update. Keep cooking bro
Ingaturroña13 days ago
Muchas gracias por el comunicado, esperaré con ansias la actualización 🫂
Sluty6913 days ago
We need a dm system 😢
Augustus Caesar13 days ago
Check steam robtop those who kow
GunnedObama14 days ago
Been off for a while and this is the first thing i saw, lovely way to start my night with this update
RIO1210 (open for DMs ehehe)14 days ago
↓ Sieghard respect button 🔥🔥🔥Thanks for implementing reverse sorting. Now I can check out historical faps.
🖤Cockogoat🖤14 days ago
С кайфом! Ты молодец, как и всегда ;3
somee14 days ago
Thank you! Blacklist is all I ever needed.