View Single Post
Author Message
kiceqs
Junior Member
Join Date: Jun 2015
Old 01-29-2019 , 14:31   [ANY]A clientprefs replacement for sourcemod using Redis as backend
Reply With Quote #1

clientprefs-redis

A clientprefs extension for sourcemod using Redis as backend.

This plugin is truly mutilthreaded.

Unlike the offical clientprefs only use signle thread for query and getting stuck if there are too many cookies (or other SQL queries), this implementation use a lock-free queue (Thanks to Cameron) and a thread pool to minimize delay and maximize QPS.

Most clients are able to get their cookies before they finish loading the maps, even with 64 player and thousands of cookies, which the orginial implementation can take more than 10 minutes to load.

If the server take super long time to load cookies or threaded SQL queries can take days to return, this plugin might be a nice choice.

Thanks to XNet for long term testing, which they have substantial cookies for their plugins. Before using this plugin, it will take up to 10 minutes to load all cookies; now, it just cost less than a minute to finish loading.

I only test this plugin in Windows, but it should work under Linux.

Installaion

Download the file from here (https://github.com/kice/clientprefs-redis/releases). Just copy the .dll file to sourcemod/extensions, remember to backup the orginial clientprefs.ext.dll file.

No other change was needed. Existing code can still work, but you might loss all your existing cookies data.

Config Redis connection infomation

Add a new config in sourcemod/configs/databases.cfg

PHP Code:
"clientprefs_redis"
{
    
"driver"  "redis"
    "host"    "127.0.0.1"
    "pass"    "foobared233"

Want to save existing data?

You can port existing data to the target redis database, but you have to follow the new data format. See the code for more infomation.

How to complie

Windows
Prerequisites
First complie Microsoft's native port of redis. Copy the hiredis.lib and Win32_Interop.lib to clientprefs-redis/lib/Win32/Release or clientprefs-redis/lib/Win32/Debug folder.

Or You can use my prebuild library.

Build Configurations
You need to enable C++17 feature to complie the code.

Linux
// TODO

Benchmark

There is a test plugin(https://github.com/kice/clientprefs-...esSpeedTest.sp) can benchmark the loading time.

Source: https://github.com/kice/clientprefs-redis

Also see

[ANY]A clientprefs replacement for sourcemod using Redis as backend

[ANY] A Hiredis warpper for Sourcemod

Last edited by kiceqs; 01-29-2019 at 14:48.
kiceqs is offline