12 ms·
Fixing races generally means stricter synchronization, which makes for slower code. The world is complex and there are always exceptions, but I'd expect perform
by eloff 7y ago
Fixing races generally means stricter synchronization, which makes for slower code. The world is complex and there are always exceptions, but I'd expect performance to decrease.
Edit: it goes without saying, but it's much better to fix the race conditions, regardless of what it means for performance. Some people seem to think I'm advocating for not fixing them.
- dekhn 7y ago"brakes make my car slower, so I'd expect my average velocity to decrease if you fixed them"
- babuskov 7y agoIt's more like traffic lights being turned off.
- vanderZwan 7y agoI grew up near a city where they set up the traffic lights along one of the main roads in such a way that if you kept to the speed limit you would always arrive at the next light just after it turned green, so you never would have to brake or accelerate. I wouldn't be surprised if there are concurrency patterns analogous to that.
- dekhn 7y agosystolic matrix multiplication is roughly analogous to that. Great Highway in SF, if you drive 35MPH you will just get greens on the evenly spaced lights. The worst is when you get stuck behind a person who drives 40, then brakes heavily, then drives 40, then brakes heavily, etc.
- V-eHGsd_ 7y agothere's a 3 or 4 mile stretch of road in san francisco called the great highway that's like this (https://www.google.com/maps/@37.750302,-122.5062241,14.64z https://www.google.com/maps/@37.750302,-122.5062241,14.64z) It was one my little pleasures to drive along that at 35 (or 30, I forget what the speed limit was) and see cars zip ahead at each light at 45, only to watch them ride the brakes as they hit the next red.
- guan 7y agoWhen there’s not too much traffic, Ocean Parkway in Brooklyn also has a green wave.
- Doubl 7y agoSlow drivers must cause extreme road rage on that road
- IggleSniggle 7y agoIn my experience, it is the “fast” drivers that cause road rage by being slow. They race to the next light, stop, and because they are stopped, prevent everyone from riding the green wave because they now must accelerate from stopped. Sooooo frustrating. Just go the speed limit and none of us will need to stop you idiots! Edit: (or go double the speed limit if you must but please stop creating stops)
- Fnoord 7y agoAh yeah, groene golf (green wave [1]). I grew up remembering my parents also using that. Except it never bloody worked. [1] https://en.wikipedia.org/wiki/Green_wave https://en.wikipedia.org/wiki/Green_wave
- vanderZwan 7y agoWorked fine for my family near Drachten, but that had the advantage that they also had a sign showing your speed next to the road. I suspect one issue is that the speedometer in cars are not that accurate
- SECProto 7y agoI live somewhere with lots of roadside speed signs (they flash speed in red if you're speeding, green if under). In the tens of cars I've driven/ridden here, the speedometer is always within a small range (±2km) of what the road sign says
- kevin_thibedeau 7y agoradar detectors always read lower than your true speed since they can't be positioned directly in your line of travel.
- SECProto 7y agoIn the situation I experience on my commute daily: I'm 40m back and the detector is 3m perpendicular off my line of travel (reasonable approximation, as they're on a roadside light standard, the lane width is 3.5m, and the car is centered in the lane), that is a very minor discrepency. On the order of 0.2 km/h
- perl4ever 7y agoThere are some weird speed signs near me. One that particularly irritates me is set up to flash if you're over 25 mph. But the speed limit is 30! There's also a flashing sign by a school, that is left on at times that the regular sign specifically says the school speed limit is not in effect.
- nashequilibrium 7y agoThe road I take to the gym is exactly like this, if you keep just under 40mph.
- swebs 7y agoIn both directions? How would that work?
- ninkendo 7y agoYou can actually do all 4 directions. Imagine a translucent checker board of blue and black squares overlaid on top of a map of roads. You can see the color of the squares but you can also see the roads underneath them. If a light falls on a blue square, make its principal north/south direction Red at t=0 and it’s principal east/west direction green. For black squares do the opposite. Calculate how long it would take cars to travel through each square unimpeded. It helps if this time is roughly the same regardless of direction. It also helps if the squares are roughly large enough that it takes roughly one light phase worth of time to travel through it. Call that time N. At t=N, switch the lights to the opposite color, so now north/southbound traffic gets green lights on blue squares, and east/west gets red. Black squares get the opposite. What you’ll see if you imagine yourself as a car driving through this, is that as you enter a black square as it turns green, the green lights will stay green until you enter the nearest blue square, at which point the phase shifts and now the blue square gets green lights as you drive through it. This works in both directions, with both north and south bound traffic. Now, this falls apart when roads are diagonal, although it’s mitigated if diagonal roads have higher speed limits. It also means if you make a turn, you’re in the wrong light cycle, but it will correct itself after the next red light. It also doesn’t work well at all if you have left turn arrows complicating your light cycles, so you’ll need to have something like a Michigan Left and the requisite wide medians to make this work. It’s not as ideal as I described in real life, but the basic principle works.
- cameronh90 7y agoI'm guessing it doesn't work so well if the stretches of road between lights are of significantly different distances.
- AnimalMuppet 7y agoOr, worse, if the roads aren't on a rectangular grid. But for square blocks, it can work very well.
- smolder 7y agoThey did this on a few roads around where I grew up.(Southern Tier of New York.)
- hawski 7y agoThere's a road in Berlin (and probably it's not an exception) that has overhead displays showing how fast you should go to be on a green wave. At least that's how I understood how it works from driving there several times. Additionally it has variable number of lanes for each direction signaled by lights. Here it's street view of the road, it's not perfectly visible, because those are LED displays: https://goo.gl/maps/T7RzQCUS4nk3QVZN9 https://goo.gl/maps/T7RzQCUS4nk3QVZN9
- philjohn 7y agoYou run the risk of the computational equivalent of speedo not beeing 100% accurate, e.g. clock innacuracy.
- deleted 7y ago[deleted]
- svnpenn 7y agoSounds like branch predictors https://stackoverflow.com/questions/11227809/-/11227902 https://stackoverflow.com/questions/11227809/-/11227902
- perl4ever 7y agoThere's a highway near me with periodic lights triggered by the cross traffic such that you almost always have to stop. The limit is 55 mph, but if you see someone on the side street and speed up to, say 70, to try to beat the light, you will probably see it turn yellow within a second and have to stop anyway. There aren't that many lights, but you almost always have to stop for every one because of the cross traffic taking precedence.
- PyroLagus 7y agoSo lock-free datastructures such as ring buffers are like roundabouts, huh?
- chrisseaton 7y agoBut many race conditions are harmless. 'Fixing' those that are with extra synchronisation is not a good use of anyone's time.
- ggggtez 7y agoI think by definition, you are wrong. If the race condition was harmless then it wouldn't be a race condition.
- chrisseaton 7y agoBy who's definition? If you go by Padua's classic definition, it's any behaviour that depends on timing sequences. For example HN has a race condition in that the ID your comment gets allocated depends on when it's submitted. But that's not a bug, is it? It only becomes a bug when it's undesirable. I think, like a few people here, you're confusing it with a 'data race'.
- mffnbs 7y agoYou still understand, though, that the colloquial definition being used here is what you're referring to as a "data race." Your comments are disingenuous in that I believe you know that you're being pedantic, I just don't know why you've brought it up the multiple times.
- chrisseaton 7y agoI didn't realise something as specific as 'race condition' could have a colloquial definition, but ok.
- pure-awesome 7y agoFor many terms of (programming) jargon, there's a strict academic definition, perhaps as defined in a paper in which the term was originally introduced, and the usage of the word in the broader (programming) community. The latter is the colloquial definition.
- curlypaul924 7y agoI see your point, though in racing brakes make a car faster, not slower. :)
- LeonM 7y agoBrakes slow a car down in terms of velocity over time. But they may make a car faster in the sense of distance over time (aka lap times). I guess the real issue here is that 'fast' is ambiguous. In terms of racing it can be used for both lap-times or velocity. lap-times and maximum velocity are not necessarily correlated. </nerdsnipe>
- michalf6 7y agoYou could say that brakes make the car faster in race conditions.
- IggleSniggle 7y agoDaaaaaaaymn. Good one, holds up!
- JangoSteve 7y agoThey often are correlated though. Better brakes mean you can stay on the accelerator longer before braking, which means you usually have higher maximum velocity and faster lap times (faster lap times are literally higher average velocities, so this makes sense).
- resters 7y agoNot really, if the brakes are broken, your average will approach 0 mph after the vehicle crashes.
- mindcrime 7y ago"brakes make my car slower, so I'd expect my average velocity to decrease if you fixed them" Just to be pedantic... in some contexts better brakes actually allow you to go faster. Consider racing on an oval track... a car with better braking ability can maintain speed longer as it approaches a corner, then scrub off speed more quickly to navigate the corner. A car with inferior brakes has to start slowing down sooner or risk crashing by taking the corner too fast. So better brakes can lead directly to faster lap times.
- Craighead 7y agoThat helps that posters arguments.
- mindcrime 7y agoThat's fine by me. I don't have a dog in that fight, so to speak...
- nickserv 7y agoIndeed, disk brakes were first used on race tracks before being available on street cars.
- discreteevent 7y agoAnd some people now argue that disc brakes on road bicycles are more dangerous because you learn that you can brake later and more suddenly. I.e You will more frequently approach the limit of friction between the (very narrow) tyre and the road.
- mindcrime 7y agoI had not heard that one. I always thought the main argument against disc brakes on road bikes was they they aren't good for long descents where you're riding the brake for long periods of time... due to heat fade or whatever. Of course both things could be true...
- tryauuum 7y agoWhy are you comparing linux kernel and cars?
- StreamBright 7y agoWould you live with a less secure but faster platform rather?
- Fnoord 7y agoIt is a good question, the answer is "it depends" but usually it would be "more secure", unless you know WTF you are doing. Usually, people don't, or they think they do but they don't.
- typical182 7y agoAs far as I understand, performance is not a valid concern. For example, from dvyukov's KTSAN wiki [1]: Given a sufficiently expressive atomic API and a good implementation, you pay only for what you really need (if you pay just a bit less, generated code becomes incorrect). So performance is not an argument here. [1] https://github.com/google/ktsan/wiki/READ_ONCE-and-WRITE_ONCE#performance-considerations https://github.com/google/ktsan/wiki/READ_ONCE-and-WRITE_ONC...
- eloff 7y agoYou're talking about the sanitizer performance. We were talking about the kernel performance in the real world. Fixing these race conditions will have some effect.
- rrss 7y agoNo, that page is about kernel performance, not sanitizer performance. The idea is that if you omit READ_ONCE/WRITE_ONCE when they are needed, it doesn't matter if the code is faster because it is wrong.
- LeonM 7y agoWould 'stricter' mean 'more' in this context? Will the fixes consist of adding more synchronization mechanisms (mutexes, semaphores, etc) to prevent potential race conditions?
- umvi 7y agoWell, if we want true security, we need to accept that all computers must take MASSIVE performance hits. It's the price to be paid for security. No more branch prediction, no more cutting corners with UB. It's time to do things the right way once and for all and that means setting back performance a good 10-20 years.