KVP/RocksDB very slow

Hey, it seems that RocksDB is super slow on FXServer compared to the performance of the benchmarks

Simple repro script:

CreateThread(function()
	-- KVP test
	local prefix = "caching_"
	local start = os.clock()

	print(start)
	for i = 0, 1000 do
		SetResourceKvp(prefix .. i, "s")
	end
	print('end ' .. os.clock())
	print(os.clock() - start)
end)

This simple script takes on average 30 seconds to complete

However, getters and delete are super fast

The SetResourceKvp uses synchronous writes: https://github.com/citizenfx/fivem/blob/master/code/components/citizen-server-impl/src/ServerKVScriptFunctions.cpp#L112 . So of course it will be slow compared to benchmarks that have --sync=0 enabled for must benchmark cases.

I think what you’re indirectly trying to ask is whether additional native arguments for SetResourceKvp to control said write options (although, consider ABI compat), or even an additional asynchronous API (e.g., SetAsyncResourceKvp FlushAsyncKvp), would be accepted as a PR.

1 Like

I’m guessing this is a leftover from the client KVP usage where writes have to be syncing the FS since a client system may randomly decide to go poof.

This consistency might be less important on servers.