4 ms·
Perf is fascinating to dive into. If you are using C and gcc you can use record/report that show you line by line and instruction by instruction where you are g
by nimos 9y ago
Perf is fascinating to dive into. If you are using C and gcc you can use record/report that show you line by line and instruction by instruction where you are getting slowdowns.
One of my favorite school assignments was we were given an intentionally bad implementation of the Game of Life compiled with -O3 and trying to get it to run faster without changing compiler flags. It's sort of mind boggling how fast computers can do stuff if you can reduce the problem to fixed stride for loops over arrays that can be fully pipelined.
- Someone 9y agoThat's true and a nice exercise for a programming class, but if you "reduce the problem to fixed stride for loops over arrays that can be fully pipelined." to make the game of life as fast as possible, you're doing it wrong (for those who don't know about it: https://en.wikipedia.org/wiki/Hashlife https://en.wikipedia.org/wiki/Hashlife)
- nimos 9y agoYeah for sure. We only had to calculate 1 or 2 iterations of the game and had a random seeded array as input and preallocated array we had to populate as output so there was a lot of optimization that wasn't worth it if you were actually looking to implement Game of Life, it was designed specifically to get you to think about computer system stuff.
- tomovo 9y agoIt's also true and nice for most modern game engines. I'm quite sure Game of life was just a subject for the exercise with the purpose to show that you can get major speedups without changing the algorithm - you don't always have a better one as backup.
- adrianratnapala 9y agoHashlife is impressive, but don't misread the above comment as saying it is "the" right way of doing it. Hashlife is good if there is lots of repetition (or sparseness). There are many other optimisation strategies, with different trade-offs.
- hendzen 9y agoIf you think perf is impressive you should try Intel vTune. Has support for finding hot mutexes, all perf counters, and even generates neat graphs that show diagrams of synchronization points between multiple threads.
- mdani 9y agoSecond that. It is amazing for C and C++ code - but does not work well on VMs such as AWS or with Java code.
- brendangregg 9y ago... I believe I was the first person to run vTune from an AWS EC2 guest. I'll share details when I can. :)
- Asooka 9y agoAre there affordable options for non-enterprise customers? I use it at work, but we buy bulk licenses and I was under the impression that licenses start at several thousands per seat.
- Martinsos 9y agoHi Hendzen, I found in one of your previous comments that you have set up your emacs to have full support for c++ projects, like auto-completion and reference following and similar. I have been using Emacs for a few years now, for js/python/html/C/C++/anything else and have just started working on a larger C++ project where intelligent auto completion and navigation would help a lot. Would you mind providing some more details on how you got it set up, maybe share your init.el file? It is a Cmake project, uses ninja as a generator. Thanks!
- hendzen 9y agoI'm writing less C++ than I used to recently, but here's the basic setup I use: 1) Emacs prelude w/ helm enabled everywhere -https://github.com/bbatsov/prelude https://github.com/bbatsov/prelude 2) Irony-mode for auto completion. Since you're using Cmake, you can just add CMAKE_EXPORT_COMPILE_COMMANDS to your invocation to output the needed metadata for completion to work. - https://github.com/Sarcasm/irony-mode https://github.com/Sarcasm/irony-mode 3) helm-flycheck for syntax checking https://github.com/yasuyk/helm-flycheck https://github.com/yasuyk/helm-flycheck 4) For jump to definition I generally just use helm-ag (grep) , I never actually got this working to my satisfaction despite trying a few things like rtags (slow, unstable) and clang-ctags (promising but annoying to set up at the time). 5) For formatting I usually just enable clang-format on save w/ something like this (requires clang-format mode installed): (add-hook 'c++-mode-hook (lambda () (add-hook 'before-save-hook #'clang-format-buffer nil t)))