Comments (5)
Our analysis of ObjectPool in Roslyn has shown that the most common scenario is a burst of ferocious borrow/return activity from the same, but random thread.
That could be explained by the fact that the most benefit from pooling comes when objects are used for very short duration. Objects that are taken from the pool for long times or permanently do not benefit as much from pooling. So, as a result of this, various threads transition into mode of heavy pool use in and out, but rarely at the same time.
Not sure if that translates to the scenarios for BufferPool. I think it might be likely.
Because of the above, in Roslyn we can assume (and see in profiles), that
- pool-per-thread would be expensive and not necessary, since there could be hundreds of threads using the pool, but rarely at the same exact time.
- InterlockExchange in the pool is actually fairly cheap since typically there is no cross-thread sharing.
- Occasionally dropping an object out of the pool is ok, since this is extremely infrequent (due to sharing being rare and contention even less).
I had some limited experiments with striped pool - ie have 4 sub-pools and pick one based on the current threadID to reduce chances of sharing. The additional complication did not pay for itself since we did not have enough contention in the first place.
In a more general solution, contention might be an occasional hazard and I would consider dynamic striping - start with one pool array, and once you detect too many collisions, add another stripe dynamically, and so on, until reaching some reasonable limit of stripes.
Another observation is that there are lots of scenarios (like scratch buffer or a builder) when a task needs briefly just one object at a time, so many requests could be satisfied with just one element of the cache.
Based on that we have a microoptimization of having one singleton object separate from the rest of the pool.
Perhaps this info would be useful.
from corefxlab.
Our object pool is basically a Get/Free API wrapped around a single object + a fixed size array.
It started much more complex, but after a number of refinements ended up as simple as that.
from corefxlab.
Regarding ManagedBufferPool specifically, http archive.org interesting stats is commented as the justification for the 2048000 bytes max buffer size default in System/Buffers/ManagedBufferPool.cs.
That is an informative page, thank you for having pointed it out. I noticed it is updated fortnightly and the Average Bytes per Page is > 2MB as of today (all those Christmas banners maybe?:).
Also shouldn't 2MB be 2097152 rather than 2048000 bytes? (2^20 instead of 2^10*1000)
from corefxlab.
@sokket, I think this issue is resolved. If so, please close it.
But please do continue the discussion about the max size of pooled buffers. It's important that we get it right. Having said that, I looked at the data and it seems like the total size of all assets is approaching 2MB per page. But I am not sure this is relevant to this discussion. Separate assets will be sent/received using separate buffers, correct?
from corefxlab.
I agree, I think this issue can be closed.
@codespare if you think the default buffer size is incorrect, please open an issue and tag me so we can have a discussion about it there and have an action item to tag any PR with to more easily track why the change would occur :)
from corefxlab.
Related Issues (20)
- unable to get header row HOT 5
- Adding `Microsoft.Data.Analysis` 0.2 to .NET Framework 4.7.1 project adds lots of packages
- Update Spark after 0.3.0 is released HOT 2
- support for skipRows or skipRowPattern
- Support for crosstabs
- "Long to wide" and "wide to long" helper functions
- Passing in DataTypes to DataFrame.LoadCsv loses column name information
- DataFrame.LoadCsv doesn't handle `null` values when it attempts to guess the column types
- Writing dataframe to txt doesn't work properly HOT 7
- Column name indexing removed in .4? HOT 15
- DataFrame status HOT 1
- Nuget Package Query (System.IO.FileSystem.Watcher.Polling)
- Question: What is the status of System.Reflection.TypeLoader? HOT 1
- Question about supported platforms in polling watcher HOT 6
- Suggestion - Add constructor for MultiDictionary that takes IEnumerable of KeyValuePair
- A tsv file wouldn't load properly HOT 4
- [DataFrame] Add a LoadCsv overload or other method that takes CSV content directly HOT 1
- dataframe row escape characters HOT 2
- CoreFxLab is now archived! See dotnet/machinelearning and dotnet/runtimelab instead!
- OrderedDictionary indexer conflict HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corefxlab.