4 ms·
Intrinsics, when available, are a convenient tool. But even then, I think assembly these days has very limited applications and most programmers don't need to k
by david-gpu 2y ago
Intrinsics, when available, are a convenient tool. But even then, I think assembly these days has very limited applications and most programmers don't need to know any assembly to be effective.
Preemptive disclaimer: all my jobs were the exception to the rule and I sadly had to work with various assembly languages on a daily basis. Still not a fan.
- AlotOfReading 2y agoYou should be able to read assembly, not least because understanding what's generated by the compiler or jit is pretty important to performance optimization.
- david-gpu 2y agoAren't there many other steps with better bang for your buck to be done before that? Libraries, better algorithms and data structures, parallelism, etc.
- AlotOfReading 2y agoReading assembly, like compiler explorer or in a debugger.
- david-gpu 2y agoYes, I understand. But the only way that gives you good bang for your buck is if you have already exhausted a number of other areas earlier. I.e. it is marginal gains. How many programmers out there would be better served by spending time learning more about those other areas before they even start thinking about whether the compiler is generating slightly suboptimal assembly?
- boris-smidt 2y agoI suspect it depends, when you would write a yaml/json parser you can only change the algorithm up to a point. After that you will have to start doing some bit fiddling and then being able to see the assembly can be really valuable.
- david-gpu 2y agoHow many programmers write a YAML/JSON parser vs. use an existing library? How many of the ones who write their own parser would benefit from using a library more than from reading assembly? If your answer is that: "well, the ones writing the library benefit from learning assembly"... Think about what percentage of programmers they represent. Not to mention that source-level profiling will still give them better bang for their buck. As somebody who has read a ton of assembly in their career because those marginal gains mattered: 99% of programmers are better off investing their time elsewhere.
- boris-smidt 2y agoYes i agree with that one most people don't need, they should first use a profiler. Then they can easily improve the performance by 10x. For example I optimized a calculation with python dataframes by monkeypatching the 'unique' method so it would skip the sort, since my data was already sorted. This gained me a 5% performance improvement. (there where a few other tricks which reduced the calculation time from 3h to 20m making iterating faster) So i guess the assembly part is just a personal interest and it is only useful for the most inner loop of a program which you can't avoid. It seems that in general using SIMDs/intrinsic is already in the very advanced playbook of a developer. Just like reflection, classpath scanning etc, GPU acceleration. Ideally the standard library should provide the fastest JSON/YAML/CSV parser so no other attempts are made to improve on the standard. I suspect your argument could even be used if you need performance it might be easier to just switch languages. Somebody was super exiting to me that he used a javascript lib which generated optimized code for SQL queries deserialization at runtime. I bluntly said well shouldn't you just use another language to avoid this complexity. Curious question, Why did you read assembly often in your career?
- boris-smidt 2y agoReading is indeed the main thing i would like to learn, For my master thesis i had dome some GPU programming (8 years ago) and then it was super useful to read the assembly to reduce the amount of steps and to understand the 'execution model'. So this allows you to make sure your 'optimization' actually optimized anything.
- dragontamer 2y agoThings like the condition flags, or GPU execution flags, or other 'implicit' flags are when assembly is needed. Otherwise, intrinsics are sufficient. And with wavefront voting / ballot instructions (and intrinsics) being so readily available on modern GPUs, there's very little reason to go to those assembly level / machine code flags or registers. Similarly, back when ccmov instructions weren't reliably output by compilers, you'd probably want raw assembly. But today I think it's safe to rely upon the optimizers.