ants

nps源码阅读--自旋锁(Spinlock)

倾然丶 夕夏残阳落幕 提交于 2019-12-11 23:27:47
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 定义 自旋锁是计算机科学用于多线程同步的一种锁,线程反复检查锁变量是否可用。由于线程保持活动状态,但未执行其他的任务,因此是一种 繁忙等待(Busy waiting) 。一旦获取了自旋锁,线程会一直保持该锁,直至显式释放自旋锁。它避免了进程重新调度或上下文的切换带来的开销,因此对于线程只会阻塞很短时间的场合是有效的。 go源码 package internal import ( "runtime" "sync" "sync/atomic" ) type spinLock uint32 func (sl *spinLock) Lock() { for !atomic.CompareAndSwapUint32((*uint32)(sl), 0, 1) { //判断是否能获得锁 runtime.Gosched() //出让cpu } } func (sl *spinLock) Unlock() { atomic.StoreUint32((*uint32)(sl), 0) } // NewSpinLock 实例化自旋锁 func NewSpinLock() sync.Locker { return new(spinLock) } //代码来源 github.com/panjf2000/ants runtime

ModelBinder Request.Content.ReadAsStringAsync performance

て烟熏妆下的殇ゞ 提交于 2019-12-11 09:38:15
问题 I have a custom ModelBinder, which, when I load test my app, and run Ants profiler on, identified reading the Request.Content as string as a hotspot: public class QueryModelBinder : IModelBinder { public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) { var body = actionContext.Request.Content.ReadAsStringAsync().Result; Is there a more efficient way of doing this? Or am I reading the ANTS profiler incorrectly? 回答1: How big is the content? Note that you

What is Time and Hit Count in ANTS Profiler

两盒软妹~` 提交于 2019-12-10 07:58:58
问题 I start to evaluate Red Gate's ANTS Profiler to profile my WPF application. I read through the online support/documentation and can't seem to find explanation for the basics (and I don't know why they are not in the documentation): In the profiler, it shows Time and Hit Count of Method. Why is Time has unit of % ? Shouldn't it be second? I try to add up all the percentage but they don't add up to 100. The Time with Children has also unit in % , which adds up more than 100%. I cannot tell

Why would GetMessageW take up massive CPU usage in my WPF application?

雨燕双飞 提交于 2019-12-05 15:59:02
问题 I've got a serious head-scratcher on my hands here. I'm investigating performance issues with a WPF component in our application. Our .net application is very large, and almost entirely in windows forms. As part of a new initiative we rewrote one of our core components with a rich WPF ui. There is a lot of WinForms<-->WPF interop going on with this thing to glue it together, and I suspect that may be somehow related to what I'm seeing. When I profile the slow operation in ANTS profiler, I see

What is Time and Hit Count in ANTS Profiler

◇◆丶佛笑我妖孽 提交于 2019-12-05 14:26:02
I start to evaluate Red Gate's ANTS Profiler to profile my WPF application. I read through the online support/documentation and can't seem to find explanation for the basics (and I don't know why they are not in the documentation): In the profiler, it shows Time and Hit Count of Method. Why is Time has unit of % ? Shouldn't it be second? I try to add up all the percentage but they don't add up to 100. The Time with Children has also unit in % , which adds up more than 100%. I cannot tell whether they are time or portion of something. What is Hit Count? What is "hitting" my application and what

Why would GetMessageW take up massive CPU usage in my WPF application?

风流意气都作罢 提交于 2019-12-04 01:15:45
I've got a serious head-scratcher on my hands here. I'm investigating performance issues with a WPF component in our application. Our .net application is very large, and almost entirely in windows forms. As part of a new initiative we rewrote one of our core components with a rich WPF ui. There is a lot of WinForms<-->WPF interop going on with this thing to glue it together, and I suspect that may be somehow related to what I'm seeing. When I profile the slow operation in ANTS profiler, I see a lot of activity occurring inside the function UnsafeNativeMethods.IntGetMessageW. ANTS reports as

Obtaining global roots from .NET programs

送分小仙女□ 提交于 2019-12-03 20:53:09
I recently started using the ANTS profiling tools for production work. Aside from being amazed by their awesomeness, I couldn't help but wonder how they work. For example, one of the most useful features lets you visualize the global roots of a running program complete with the number of references to values of different types. How does this tool get hold of that information? Chris Schmich (Full disclosure: I'm on the Visual Studio Profiler team, but the below information is public) You can do this by writing a CLR profiler that runs inside the process you're targeting. CLR profilers are C++