Skip to main content
14 events
when toggle format what by license comment
Jun 16, 2020 at 10:01 history edited CommunityBot
Commonmark migration
Sep 6, 2018 at 20:54 comment added Peter Cordes @Corey: so you'd profile with performance counters for cache misses to see if touching less stack space and other data could help, if you had an actual case where it was a tradeoff between computation and space (unlike the silly example in your question). e.g. perf stat -d ./my_program on Linux to get counts over the whole program, or record a profile of last-level cache misses. Linux C++: how to profile time wasted due to cache misses?.
Sep 6, 2018 at 20:52 comment added Peter Cordes Your answer only talks about memory usage in the context of total memory-allocation of the whole program. The other performance-relevant kind of memory consumption is your cache footprint / working set, over an inner loop or over an outer loop. Memory is cheap, but cache is not. A 1MiB lookup table replacing a short computation might look good in a microbenchmark, and have negligible impact on your total memory footprint, but in real use (when you only index it between other memory operations) can lead to tons of cache misses, at least in L2 cache.
Sep 6, 2018 at 20:44 comment added Peter Cordes It requires some knowledge of how the chipset you are targeting best optimizes memory access. No it doesn't, it requires knowing whether the language you're using does row-major or column-major 2D arrays (or how your data structure is organized). All hardware does much better with sequential contiguous access to all the bytes in a cache line than to strided accesses.
S Sep 5, 2018 at 15:58 history suggested Toby Speight CC BY-SA 4.0
Spelling fixes; use real headers
Sep 5, 2018 at 14:49 review Suggested edits
S Sep 5, 2018 at 15:58
Sep 5, 2018 at 12:50 comment added Berin Loritsch @DocBrown, I have remedied that. Regarding the second question, I pretty much agree with you.
Sep 5, 2018 at 12:49 history edited Berin Loritsch CC BY-SA 4.0
Add a clause to answer the second question more blatantly.
Sep 5, 2018 at 1:09 comment added Eric @BerinLoritsch Again, in general I agree with you, but in this specific case I do not. I've provided my own answer, but I've not personally seen any tools that will flag or even give you ways to potentially identify performance issues related to stack memory size of a function.
Sep 5, 2018 at 0:41 comment added Berin Loritsch @Eric, as I mentioned, the last category of performance improvement would be your micro-optimizations. The only way to have a good guess if it will have any impact is by measuring performance/memory in a profiler. It is rare that those types of improvements have payoff, but in timing sensitive performance problems you have in simulators a couple well placed changes like that can be the difference between hitting your timing target and not. I think I can count on one hand the number of times that paid off in over 20 years of working on software, but it's not zero.
Sep 5, 2018 at 0:24 comment added Eric I feel like this is the generic answer to "How do you address performance bottlenecks" but you would be hard pressed to identify relative memory usage from a particular function based on whether it had 4 or 5 variables using this method. I also question how relevant this level of optimization is when the compiler (or interpreter) may or may not optimize this away.
Sep 4, 2018 at 23:05 comment added Corey P This answer focuses on my question the most and doesn't get caught up on my coding examples, i.e. Method A and Method B.
Sep 4, 2018 at 23:02 vote accept Corey P
Sep 6, 2018 at 13:13
Sep 4, 2018 at 19:08 history answered Berin Loritsch CC BY-SA 4.0