I benchmarked two things:
1) vanilla redis, SET
2) my custom module's PUT, which basically does (i) RedisModule_StringSet, then (ii) RedisModule_Call(ctx, "PUBLISH", ...) to notify subscribers that the write has been finalized.
I used Google's pprof to profile these two variants. Visualizations show that step (2)'s (ii), the publish, has 4x aggregated time than (2)'s (i), which is similar to (1).
Here's the svg for (2) (download & open with Chrome to zoom in/out):
Specific questions:
1) I see RM_Call(.., "PUBLISH", ..) spends a lot of time on createClient(), freeClient().
How does each publish work? Does it create and destroy a client every time it needs to publish a message?
If so, anyway to avoid this? I can ensure that each channel has exactly 1 subscriber.
2) In general, can you optimize the publish codepath for Redis Module? Preferably something like native RedisModule_Publish, to avoid looking up the command by string "PUBLISH".
Zongheng