7 ms·
Context switch logging with the Windows Event Tracing API (2014)
- rmccue 11y agoOff-topic, but take a look at the source on the site: all absolutely-positioned divs. Previously: https://news.ycombinator.com/item?id=8895662 https://news.ycombinator.com/item?id=8895662
- wheaties 11y agoThis site worked great on my android phone. Much better than most responsive sites I've visited. Add to that it loaded quickly. I'd say it's a good design.
- pvdebbe 11y agoNot really. I immediately noticed the layout breaks if you use your own font size. Not a good design at all.
- pmontra 11y agoThere are overlaps between paragraphs due to Opera's autoreflow after pinch to zoom.
- pmontra 11y agoDownvote me as much as you want, reality doesn't change. If you use Opera with force reflow and you zoom in, text of different paragraphs overlap and you can't read anything. Bad design as expected when trying to format HTML as if it was PDF. The designer has to adapt to unpredictable user agent settings, not the other way around.
- adwhit 11y agoAnother oldie-but-a-baddie: http://www.thejaywalker.net/2010/12/system-v-semaphores-how-not-to-design.html http://www.thejaywalker.net/2010/12/system-v-semaphores-how-...
- ArkyBeagle 11y agoOh, they're not that bad. It uses the ioctl() metaphor. I'm surprised somebody who's read ALP doesn't see that.
- lmm 11y agoioctl() isn't a metaphor, it's a sin-bin for things that don't fit in the file metaphor.
- ArkyBeagle 11y agoI'd agree if there were no codes for READ and WRITE under the ioctl() rubric :)
- _yosefk 11y agoThis API is for people (both program authors and users) who really know quite well what they're doing, for very rare occasions, and the alternative/status quo was to not be able to get this info from the kernel at all. I imagine someone at MS thought they did a favor to people doing performance optimization by giving them something instead of nothing, perhaps they even had to fight to include this feature in the product because obviously Windows would sell rather well without the feature. They must have had a bad day reading this criticism. (I'm not saying "poor Microsoft" - it's definitely not poor - and I'm not saying "you should thank people for whatever API they give you" - a lot of programs/features do more harm than good - and I'm not saying someone shouldn't vent having had a lot of time burnt by some ugly API. I'm saying specifically that this here is a dark corner of the OS that the API in question sheds at least some light on and I have a hunch, perhaps an entirely mistaken one, that it was someone's pet initiative and they thought it was definitely better than nothing. "Little did they know." To take a simple example of the other kind of API: sprintf, the version that doesn't take a buffer size, is a really bad API because that's something everyone's gonna use a lot and you just shouldn't give this kind of thing to people (give them snprintf at the very least) and you certainly can't be excused by "one should know what they're doing" in this case because it's between hard and uneconomical to use safely while passing the buffer size is the obvious thing to do, also one seems entitled to care-free string formatting, definitely 100x more so than care-free kernel status monitoring on the grounds of it being something many more people do much more often.)
- georgemcbay 11y agoNormally, I'd agree with your optimistic assumption, but having spent a bunch of the early to mid 2000s writing code for Windows applications, the oddness of this API relative to the simplicity of what you're actually doing was, IMO, nearly universal across Microsoft, including for APIs (like Direct3D in the first couple of releases, DirectShow, COM in general from any non-Visual Basic language, etc) that were wholly intended to be public facing APIs by their very nature. I can't speak to the conspiracy-theoryish idea that Microsoft wrote bad APIs on purpose to make it easier to compete with other software companies at the application level, I suspect the issues were more subtle than that (an overly bike-sheddy code review culture, maybe?), but I did find them nearly universally bad to use as a programmer for a Windows "ISV" at the time. Having said that, most modern Microsoft/Windows APIs I've used have been quite sane. Not bashing Microsoft in general here, just their APIs from about the mid 90s to the mid 2000s.
- grx 11y agojs;dr
- windowsworkstoo 11y agoYep, it's a difficult API, which has unfortunately meant the functionality, which works amazingly well, hasn't been learnt or adopted as much as it should have been. However reading this, it seems the author simply wanted to collect trace information. It's probably a documentation issue, but typically you would just use tools like xperf or logman to collect and analyze traces based on in built Windows providers. There's no need in this use case to utilise the API directly at all.
- bjackman 11y ago> You can use tools like PerfMon to view logged information about your game, like how much working set it was using or how much disk I/O it did. But there is one specific thing that directly accessing Event Tracing gives you that you can’t get anywhere else: context switch timing.
- windowsworkstoo 11y agoPerfMon != logman/xperf, which exercise the same API this guy was struggling with.
- recentdarkness 11y agoPlease amend with '2014' this is not a new post
- dang 11y agoOK, done.
- csours 11y agoSo is this badness from over-engineering, or from complexity due to other parts of the API?
- fla 11y agoIMO, it looks like the API carries alot of heritage. It clearly contains 'layers' fo crap with different design patterns that were added over time. They should simply make a new one.
- to3m 11y agoPreviously on HN: https://news.ycombinator.com/item?id=8146124 https://news.ycombinator.com/item?id=8146124
- ibiza 11y agoSomewhat related, Jeff & Casey take down another MS API: How to draw a rectangle with Direct2D. http://braid-game.com/news/2009/01/the-jeff-and-casey-show-on-visual-studio-2010-and-direct2d/ http://braid-game.com/news/2009/01/the-jeff-and-casey-show-o...
- ygra 11y agoMost of that sample is actually how to deal with the Window API to get a window that redraws itself when resized. All that has nothing to do with Direct2D. Drawing the rectangle is just three lines, actually.
- sythe2o0 11y agoThe files on that page wouldn't load for me-- the podcast that's being drawn from is here, and the Direct2D portion is around the 1 hour mark: https://mollyrocket.com/jacs/jacs_0001_0050.html https://mollyrocket.com/jacs/jacs_0001_0050.html
- wtbob 11y agoWell, I don't know about the API, but that's certainly the worst blog software ever made, requiring me to enable JavaScript and execute code in order to read some simple HTML and CSS. Why‽
- aforty 11y agoReading his site on an iPhone is nearly impossible.
- dclowd9901 11y agoPush that button in the uri area that has a bunch of horizontal lines
- stephenr 11y agoReader mode doesn't "trigger" for this site.
- dingo_bat 11y agoThe text was a bit small but I could easily read it on my Galaxy.
- bjacobel 11y agoPerhaps consider that coming on here and being condescending about the impact your own browsing habits have on the web experience of your (very small, but very vocal) JavaScript-disabling demographic makes the rest of us web developers really not very interested in building sites that meet your demands. I agree that the site shouldn't need JavaScript to function, but I don't think comments like these help the goal of helping the content creators achieve progressive enhancement.
- hghdfgv 11y agoConstructive criticism is a good thing.
- markbnj 11y agoI think most of the author's comments apply to the Win32 API in general. Windows game developers are probably among the few tech demographics that still have to encounter it on a regular basis. Having written an entire game to the Win16 API and then later ported it to Win32 I lost a significant chunk of my life spent in drilling into GDI and DirectDraw (I think that is what it was called then) structures and entrypoints. Pretty much the whole native API looks like his examples. I also thought it was perhaps a tad strange to equate CSS, DirectShow, and the Android SDK as examples of tough "APIs" to master. I get his point, but those are three pretty wildly different levels of abstraction there.
- bluetomcat 11y agoWin32 API is the most horrendous collection of badly named, nonsensical types and functions I've ever encountered in my career. Back in the mid 90s I was learning how to program and understanding a Win32 "Hello world" was a royal pain compared to everything else I was doing. Functions with more than 8 parameters were the norm, structs with tens of members had to be manually initialised before calling them. And don't get me started on the WPARAM/LPARAM idiocy.
- markbnj 11y agoEasy to call it idiotic today, after twenty years of evolution, but it's a little silly to do so. The windows API was written in C, and as such they needed some way to accommodate multiple dispatch in the message loop using statically typed parameters. That same entry point handled literally hundreds of different message types for every operation in the system. From my perspective it was pretty well designed for its time.
- holmak 11y agoSDL is written in C, and it has a much more pleasant way of dealing with heterogeneous event types. There is a struct called SDL_Event, which you fill by calling SDL_PollEvent() until there are no more events to read. The struct is a (discriminated) union of all the possible event types. (It even wraps the Win32 API, so it is very directly comparable -- it is returning the same events!) https://wiki.libsdl.org/SDL_PollEvent https://wiki.libsdl.org/SDL_PollEvent
- jjaredsimpson 11y agoETW isn't supposed to be written like this at all. MS has entire codegen toolchain that lets you define events in an xml manifest as part of your build process. This codegens a C header file which lets you fire events in your own code with a simple function call. When you want to correlate events from your own code and OS events you use a tool like XPerf which knows the OS events and can read your application manifest to get strong typing on the events your application fires. This also lets you take traces on deployed software on customer machines. If you want to roll your own event consumers you can do that too. But XPerf probably already does what you want. This all existed back in like 2010 when I was using ETW. I'm sure the tooling has only gotten better since then. So yeah you can go write your own bad incomplete version of XPerf and not leverage your existing build process and MS tooling. But then is the API really bad? Or are you just not googling correctly?
- anentropic 11y agoThe API is still bad, it seems to have been badly designed regardless of whether the intended consumers are external developers or internal code
- jjaredsimpson 11y agoI don't see a well argued point that it is badly designed. It supports a powerful set of low overhead performance analysis tools. If you want to correlate OS events, SQL server events, and application events, etc, you can get this working simply,correctly, fast and maintainable. An api having a point of view about how it should be used doesn't make it a bad api.
- kabdib 11y ago> lets you define events in an xml manifest as part of your build process ... at which point you should run screaming.
- jjaredsimpson 11y agoBecause all uses of xml are wrong by default? Something like: <myevent> <int/> <timestamp/> <string/> </myevent> Will codegen to a function like myevent_fire(int,timestamp,string). Why is this bad? You separate the definition of event classes from their use sites and have correctness by default.
- strictnein 11y agoWas expecting this to be about Paypal's API.
- deleted 11y ago[deleted]
- alblue 11y agoI thought this might be about the (old) Java Date API (which also inspired the JavaScript API as well): https://stackoverflow.com/questions/1969442/whats-wrong-with-java-date-time-api/1969651#1969651 https://stackoverflow.com/questions/1969442/whats-wrong-with... As it is, it's a JavaScript laden blog about a Microsoft Win32 API and is virtually unreadable, so there's not much point in following the OP link.
- jdbernard 11y agoI had no problem reading it on my mobile phone. Did you have any comments about the content of the article?
- raldi 11y agoCould a mod de-hype the headline please? I propose, "Context switch logging with the Windows Event Tracing API"
- dang 11y agoOk, done.
- mikestew 11y agoIf by "worst API ever" he means "didn't do it the way I'd do it", he might be right. But if what he really means is "biggest pain in the arse to use", I give the crown to the AirWatch API. Not only do few of the functions work they way that they are documented, the sample code will never work (nor is it even close to a representation of how one might use it in the real world"), and my fave: you have to misspell the parameter name going in, but when it comes out it will be spelled right. So my code is littered with "no, that's not a typo; it's what the API requires" and "don't forget to spell the parameter correctly when referencing the return value". What amounted to maybe 100 lines of code against that API took me days of experimentation and cursing the useless docs. On our internal wiki, I documented what I was writing with a preface: "in 30 years of writing against APIs of all shapes and sizes, including ISAM data engines on IBM 370 mainframes from the 70s and open source projects written by some dude during an all nighter of coding and bong hits, the AirWatch API is by far the most steaming pile of poo I've ever had the displeasure of working with." To me it's obvious that no one within the AirWatch organization ever used the API. They couldn't without running into the egregious bugs I have. My suspicion is that someone said "we should have an API", wrote a spec and shipped it offshore, then never checked the work that came back.