Rule 34 World
Loading...

Shuffle

26 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
rogeliobravo53810 days ago
Wtf
mazoemu16 days ago
Tq for the increase of blacklist :)
MagicMain17 days ago
So how does one shuffle a playlist?
Roboute Guilliman21 days ago
For sh"t nga dih🥀
Roboute Guilliman21 days ago
Add a Warhammer section.🙏🥀
Dachitarooo23 days ago
Yo please add search to playlists,ive got like 100+ playlists and diff categories so its rlly hard to search for the ones i want
CasualCummer24 days ago
Take ur time ma nigga
384970830624 days ago
bro你做的这个网站一直深受我喜欢这次我有几个建议要提
EPIKGAMER6000025 days ago
straight W
JeS25 days ago
Ёу, Сейдж, сделай пожалуйста что бы можно было быстро переходить на конкретную страницу (в закладках например), а то по одной листать не очень удобно
Hritik25 days ago
Thanks sieghard
沫星疏25 days ago
听我说谢谢你
bloom26 days ago
please give ME a inf cum history cd🤧
l৻ꪆvelly26 days ago
thanks, sieghard!
Dickcancer26 days ago
W.
John nigga26 days ago
I guess bro
Manuelsaurio26 days ago
thank you ❤
71tgC26 days ago
thank you sieghard ❤🩹
Porn is bad26 days ago
Finally getting more blacklist tags🙏😭
Mabel, Girl of Nihility26 days ago
no upload feature😥😭😥😭🎉damn isn't 😥😥🤞