Virtual Memory State:free,reserved, committed. Large Heap object >85K
ephemeral generation =0,1 on ephemeral sequment.
GC phases: Mark Live->Upd ref to compact-> pause/barrierr on ->Compact/Collect unreachable->barrier off.
Freachable Queue, GCSettings tweaks LargeObj compaction/Latency/IsServerGC Mode.
GCSettings.LantencyModel=batch/interactive Server/UI, LowLatency/Sustained --short 0,1 only, long blowup
Server vs. Workstation GC: Non-Concurrent/Background vs. Concurrent/Non-Concurent <gcServer/> <gcConcurrent/> muti-gc-thread high priority vs. gc=user thread
Server GC -- 1 thread+heap per core, larget ctx switching, use wkgc+non-concurent for 100+ inst of a single app
Concurrent gc only for gen2. Fx 4.5 Background replaced concurrent and not restrict alloc during GC.
wkstn vs Svr GC--User Thread GC vs 1 per core GC,Fx4.0+ Background GC even one-core, single core
can be concurrent by swithing
C++/CLI Windows Form int APIENTRY WinMain(HINSTANCE,HINST,LPSTR,in) { Application::Run(gcnew Form1());
WF Databinding: PriceTB.DataBinding.Add("Text,_QuoteList,"Price") CurrencyManager, IList, IBindingList
BindingSource.DataSource=_QuoteList, LB.DataSource=BindingSource, bs.Add() .Remove().
C++/CLI ViewModel INPC Hand coded.
TaskScheduler.FromCurrentSyncCtx, Task work-stealing all core buzy.
lambda= class displayClass1 :: b_0(), delegate(b_0) Closure=lambda+public envVar passByRef Shared not stack e.g Window <>4__this
TaskClosure pass env by param since it will run later: Task.Factory.StartNew((env)=>{},state:env);
TaskCompletionSource ctor(IAsyncResult) gone TCS<T> wraps Task with Workflow in Continuation(set result/Cxl/Excp).
So should have been called TaskContinuationSource.
All blocks: t.Result, Task.WaitAny/All vs Task.WhenAny/All
TaskException=AggregateException .InnerException (list, ae.Flatten()), CLR ret-throw ae
Handling ae coding pattern: WaitAll(); if(t.Excption !=null) or try-catch.
App start catch-all: TaskScheduler.UnObservedTaskException+=EventH<Unobs..EventArgs>(H(){e.SetObserved(););
CancellationTokenSource cts, cts.Token token.ThrowIfCxlRequested, need task-excep code(OperationCxlExcp)
ParentTask.StartNew( child(TaskCreationOptions.AttachToParent);
Parallel.For(0,10,(i)=>{}) (0,10,()=>threadlocal init,(i,lstate,accuRet)=>{}, (fin)=>interlock(ref g,fin)
.For(item, (i,loopState)=>ls.Stop/Break all itr)
pie=Enumerable.Range().AsParallel.Select(), pie.ForAll(),pie1.Unordered.Join(pie2,p2=>p2.id,p1=>p1.id, {p1,p2}).
pie.Aggregate(0, (subTot)=>{thread local},(total)=>,(avg)=>{calc})
Parallel.Invokve(Action[]);
AsyncCache: await Task this[..] indexer cache miss=> Task.Run Get awaitable
Timeout: await .WhenAny(Donwload, Task.Delay(3000ms);
TaskWhenAll: await .TakeWhenAll( from addr in mailinglist select Blast(addr))
Task.FromResult(42): await GetCache(out v)?Task.FromResult(v=42):GetAfterCachMiss();
AsyncProducerConsumer: DataQueue+TCSQueue, Take() .FromRes(DataQ.DeQ) or TCS.EnQ return TCS.Task; Add() DataQ.EnQ, TCS.DeQ.SetResult.
RetryOnFault(10) for10 try catch await F().ConfigureAwait(false);
NeedOnlyOnce data=await .WhenAny([]F(cxlTok)); cxlTok.Cancel(); return data.
WhenAllOr1stException([]tasks) --CountDownEvtn(tasks.Count) ContinueWith( if(ce.Signal()) tcs.SetResult if Excep) tcs.setExcp, return tcs.Task;(cannot .WhenAll since run through all)
[CallerMemberName] INPC
statuc void NotifyPropChanged(this PropertyChangedEventHandler h, object s,[CallerMemberName] string m=null)
{
h(s,new PropertyChangeEventArgs(m);}
INPC PropertyChange.NotifyPropChanged(this)
INPC PropertyChange.NotifyPropChanged(this,nameof(Age));
order?.customer?.name=="jon"
using static Math;
public Age => DateTime.Now -BirthDate;
public DOB { get;}=new DateTime(2000,1,1)
Clicked?.Invoke(this,Empty); EvnH check null
$"{Age} birday comming";
3 pattern of WhenAny
Throttling reduTaskList, while(count>0) t=await WhenAny(), remove t, add from OrgList to reduList
Early Bail out of one task: pass in Cxltok ct tcs=new TCS(false) using(ct.Register(tcs.Set(true)) await WhenAny(task,tcs.task).
Redundancy: 1stTask=await WhenAny([]), cxlToken.Cxl;
Saturday, March 12, 2016
.Net Braindump
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment