2011-04-27 1 views
2

하나의 컬렉션으로 직렬화 할 때 총 140,000 개 이상의 속성을 갖는 EAV 스키마에서 ~ 4600 개의 객체로 작업하는 경우 25MB 미만입니다. 그들이 여기에있는 것처럼 직렬화 될 때 정확히 4600 개의 개별 캐시 된 항목으로서 정확하게 얼마나 큰지는 알 수 없습니다.여기에 로컬 캐시가 사용됩니까? 왜 그렇게 느린 IEnumerable 평가?

EAV 특성 스키마로드 시간 문제를 해결하기 위해 시작시 AppFabric을 초기화하고 로컬 캐시에 의지하려고합니다. 그러나, 나는 GetObjectsByTag 또는 GetObjectsInRegion에서 IEnumerable을 평가한다 매우 낮은 성능을 관찰 해요 :

var products = new Dictionary<string, ProductContract>(); 

    Trace.WriteLine(DateTime.Now.ToLongTimeString() + " retrieving object collection from cache"); 
    //object productsObj = _cache.Get(ProductCollectionNameInCache, this.CacheRegion); 
    //var productsObjUneval = _cache.GetObjectsByTag(ProductCacheTag, this.CacheRegion); 
    var productsObjUneval = _cache.GetObjectsInRegion(this.CacheRegion); 
    Trace.WriteLine(DateTime.Now.ToLongTimeString() + " retrieving object collection from cache complete"); 

    Trace.WriteLine(DateTime.Now.ToLongTimeString() + " evaluating IEnumerable object"); 
    var productsObj = productsObjUneval.Where(p=>p.Key != ProductsPrimedFlagNameInCache).ToList(); 
    Trace.WriteLine(DateTime.Now.ToLongTimeString() + " end evaluating IEnumerable object"); 

    Trace.WriteLine(DateTime.Now.ToLongTimeString() + " converting object collection to Dictionary<string, ProductContract>"); 
    products = productsObj.ToDictionary(p => p.Key, p => (ProductContract) p.Value); 
    Trace.WriteLine(DateTime.Now.ToLongTimeString() + " end converting object collection to Dictionary<string, ProductContract>"); 

은 EventLog를 출력 :

Level Date and Time Source Event ID Task Category 
Information 4/27/2011 12:55:22 PM EPC Service 0 None 12:55:22 PM end getting products from cache 
Information 4/27/2011 12:55:22 PM EPC Service 0 None 12:55:22 PM end converting object collection to Dictionary<string, ProductContract> 
Information 4/27/2011 12:55:22 PM EPC Service 0 None 12:55:22 PM converting object collection to Dictionary<string, ProductContract> 
Information 4/27/2011 12:55:22 PM EPC Service 0 None 12:55:22 PM end evaluating IEnumerable object 
Information 4/27/2011 12:55:05 PM EPC Service 0 None 12:55:05 PM evaluating IEnumerable object 
Information 4/27/2011 12:55:05 PM EPC Service 0 None 12:55:05 PM retrieving object collection from cache complete 
Information 4/27/2011 12:55:05 PM EPC Service 0 None 12:55:05 PM retrieving object collection from cache 
Information 4/27/2011 12:55:05 PM EPC Service 0 None 12:55:05 PM getting products from cache 
Information 4/27/2011 12:55:05 PM EPC Service 0 None 12:55:05 PM is cache primed? True 

편집 : 태그 모든 객체 또는 모든 객체에 대한 호출을 지역에서는 항상 로컬이 아닌 분산 캐시를 사용합니까? 그것은 매우 실망스럽고 우리의 필요를 완전히 소멸시킬 것입니다. http://social.msdn.microsoft.com/forums/en-us/velocity/thread/C0F1863A-87D6-43BC-8EA5-667F072040D2

답변

0

잘 모르겠으므로 기본 구현을 모르지만 .ToList()는 나에게 의심스러워 보입니다. 그것은 전체 열거를 걸을 것입니다. 그게 필요 할까? ToDictionary()에 직접가는 것은 어떨까요?

+0

BTW, 이것은 아마도 ToDictionary() 호출의 속도 저하를 지연시킬 것입니다. –

+0

기본 .NET .ToList이며 프로필 작성 목적으로 ToDictionary 변환에서 IEnumerable 평가를 분리하기위한 것입니다. ToList는 원래 존재하지 않았고, 그렇습니다 .ToDictionary가 호출되었을 때 원래 그 지연이 보였습니다. – andrewbadera

+0

이것을 프로파일 러를 통해 실행 했습니까? 다음 중 하나에서 속도가 느린 것 같습니다. - 키 또는 값 접근 자 - 열거 자 MoveNext() 호출 –