@LamonteCristo,
These are good questions.
Is the sole purpose of IBufferManager to reduce pressure on the GC?
BufferManager is not only to reduce pressure on the GC, but also it could improve the the performance of storage server. GC can create and destroy the buffer pool and these process is costs on each allocation on computer resource. BufferManager can hold on the buffer pool, and is faster than GC every time. Meanwhile, I recommend you can refer to this answers.
What workloads (Table, Queue, Blob) would benefit from this cache?
The answer is yes. Azure storage SDK provided this function for these 3 storage services. And they are same methods.
What are the (measurable) conditions in which I should implement IBufferManager?
Theoretically, we can make concurrent requests with the large different MaxBufferSize to get the server response time. And then send these requests again to get the response time again. We can compare these two response times . Actually, this is a balance between time and memory.
Is BufferManager thread safe? Can I have a runtime serverside pool of buffers I allocate as needed?
From my experience, it is not thread safe if we use one same instance in multiple-threads . Please refer to this document(https://msdn.microsoft.com/en-us/library/system.servicemodel.channels.buffermanager(v=vs.110).aspx#Thread Safety )
How should / shouldn't I implement this bufferManager? (e.g. threads, IDisposable, preallocation in Static method, Redis)
You need implement the "System.ServiceModel
" into your project and try to use this sample:
public class WCFBufferManagerAdapter : IBufferManager
{
private int defaultBufferSize = 0;
public WCFBufferManagerAdapter(BufferManager manager, int defaultBufferSize)
{
this.Manager = manager;
this.defaultBufferSize = defaultBufferSize;
}
public BufferManager Manager { get; internal set; }
public void ReturnBuffer(byte[] buffer)
{
this.Manager.ReturnBuffer(buffer);
}
public byte[] TakeBuffer(int bufferSize)
{
return this.Manager.TakeBuffer(bufferSize);
}
public int GetDefaultBufferSize()
{
return this.defaultBufferSize;
}
}
Then you can used this BufferManager as following:
StorageCredentials credentials = new StorageCredentials("**", "**");
CloudBlobClient serviceClient = new CloudBlobClient(new Uri("**"), credentials);
BufferManager mgr = BufferManager.CreateBufferManager(<you_can_set>, <you_can_set>);
serviceClient.BufferManager = new WCFBufferManagerAdapter(mgr, <you_can_set>);
serviceClient.GetContainerReference("**");
If you want to use multiple-threads, you may be need use 'lock' in your code.
Any concerns,please let me know.