I am new to Redis and having a really hard time with performance - I described the issue over here:
http://stackoverflow.com/questions/25105832/multiple-repeated-sadd-commands-for-one-redisclient-storerelatedentities-call
Would you be kind enough to see whether you can pinpoint what I may be doing wrong?
Thanks
Hi Tolga, just checked this and your right, it should be moved to the outerloop which I’ve done in this commit: https://github.com/ServiceStack/ServiceStack.Redis/commit/96260e0d96102b6a323360a9239bef458d5435ce
Cutting a new build for you now, will let you know when its ready.
Ok this has just been deployed to MyGet, you can get it at: https://github.com/ServiceStack/ServiceStack/wiki/MyGet
let me know how it goes, thx.
Tolga Erdogus:
Demis - thanks for getting back to quickly. I don’t really understand what the code is doing so I am going to comment abstractly.
entry.Value and registeredTypeIdsWithinPipeline both contain the same x ids. So the inner foreach and its inner Each(x=>…) together still (after you mod) execute x*x times.
Again - I have no idea what I am doing but it’s almost like it needs to be like this:
internal void AddTypeIdsRegisteredDuringPipeline()
{
foreach (var entry in registeredTypeIdsWithinPipelineMap)
{
var typeIdsSetKey = entry.Key;
var registeredTypeIdsWithinPipeline = GetRegisteredTypeIdsWithinPipeline(typeIdsSetKey);
foreach (var id in entry.Value)
{
//registeredTypeIdsWithinPipeline.Each(x => this.AddItemToSet(typeIdsSetKey, id));
this.AddItemToSet(typeIdsSetKey, id);
}
}
registeredTypeIdsWithinPipelineMap = new Dictionary<string, HashSet<string>>();
}
Yep like you say it’s still iterating over the collection twice. In which case this can be much better optimized to run within a pipeline. Now updated in this commit: https://github.com/ServiceStack/ServiceStack.Redis/commit/869c0bc7542702c9bed55887ee942964e0e453eb
Which is now available on MyGet. https://github.com/ServiceStack/ServiceStack/wiki/MyGet
As it keeps the same version number, if you installed from MyGet earlier you’ll have to uninstall so NuGet will pull the latest packages.
Tolga Erdogus:
This seems to fix my problem. Thanks very much!