This forum is in permanent archive mode. Our new active community can be found here.

GeekNights Monday - Performance Profiling

Tonight on GeekNights, we cover the high level of performance profiling. It's a complex problem that requires an understanding of programming and profilers, but also hardware and statistics. In the news, Orkut is finally dying the true death, right alongside freshmeat.net. ConnectiCon is happening NEXT WEEKEND!

Download MP3
Source Link
«1

Comments

  • I have no idea what orkut or freshmeat was. I was not super into tech at time.

    The occulus rift is OK, but you get sick after 30 min.

    If your 'hello world' is slow, maybe programming isn't for you. Also performance profiling is technical as fuck.

    The correct answer is not to use Java. (Exceptions to this rule are... limited)

    Not functional programing; I think you mean 'back-end' vs front end. (functional programming is totes cool, but kinda has some efficiency issues)

    You can optimize code for efficiency and for usability. These are different things. Super efficient code is often less readable. The first time you write something its always gonna look like butt. To be fair, hacks ship software.

    Dude, quake using bsp maps and stuff! I think Carmack or someone has a paper on that. Basically, always pick a shotty because designers have a vested interest in keeping things in closed quarters for performance reasons.

    Don't get me started on data in networks.I had game project take hours to pull.

    I really don't know systems and networks that well, or real low level programming. So call my bullshit esp. if you can teach me something.

    Eww... Garbage collection... (If you optimize for speed; makes a langue great to hack things up in)

    Did anyone else on the forum follow this podcast episode?
  • Wait, people on the forum listen to the podcasts?
  • Dromaro said:

    Wait, people on the forum listen to the podcasts?

    ^
  • Dromaro said:

    Wait, people on the forum listen to the podcasts?

    They still do a podcast?
  • What's a podcast?
  • how to I log into my old Orkut account? just gives me a window that says it's closing in September...
  • Cremlian said:

    how to I log into my old Orkut account? just gives me a window that says it's closing in September...

    I tried. They converted the system years ago to logins via Google Accounts. So, if I go to Orkut, it gives me a NEW, blank profile for my main google account. There appears to be no way to access an old account.

  • edited July 2014


    If your 'hello world' is slow, maybe programming isn't for you. Also performance profiling is technical as fuck.

    If "hello world" is slow, then something must be seriously wrong with your programming language, its environment, or the system you're running it on (okay, there is one exception with respect to Java below, but I'll explain).


    The correct answer is not to use Java. (Exceptions to this rule are... limited)

    Eh, that depends. A lot of Java's slowness is in the startup time of the VM. Once the VM is up and running and the JIT has done its job of optimizing the most often used code paths, it's actually not that slow. This basically means that you should use Java only for long-running processes where the initial startup and JIT cost are amortized over the entire run time of the process. "Hello World" is a horrid, horrid program in Java because it's so simple that its run time is dominated by the VM startup and JIT costs.

    Not functional programing; I think you mean 'back-end' vs front end. (functional programming is totes cool, but kinda has some efficiency issues)

    It's getting better, at least in some languages. It also has some really, really nice advantages when it comes to parallel programming. I haven't looked too in depth in this, but the "no side effects" nature of most functional languages means they are awesome for doing lock-free parallel programming. Heck, some of the newer programming languages out there, such as Go and Swift, have taken a few pages out of functional languages despite not being completely functional themselves.

    You can optimize code for efficiency and for usability. These are different things. Super efficient code is often less readable. The first time you write something its always gonna look like butt. To be fair, hacks ship software.

    YMMV on this one. It all depends on the algorithm and how you implement said algorithm in the programming language you're choosing. You can make super-efficient code (unless you need efficiency to the point of using hand-coded assembly instead of a higher-level language) super-readable. This is not a good blanket rule.

    I do agree that hacks ship software and often the first pass of coding often looks like butt.

    I really don't know systems and networks that well, or real low level programming. So call my bullshit esp. if you can teach me something.

    Well, my job is as a low level systems programmer, so it's kind of my area of expertise. :)

    Eww... Garbage collection... (If you optimize for speed; makes a langue great to hack things up in)

    Garbage collection isn't necessarily that bad, although I prefer automatic reference counting as implemented in more recent versions of Objective C, Swift, and C++ if you use something like std::shared_ptr or boost::shared_ptr, solely because of the deterministic release of resources these features offer. Still, a good garbage collector isn't necessarily a bad thing. The main issue with it is that you can't always know for sure when it's going to kick in, or even when an individual resource is going to be released. When you have folks like Ken Thompson (one of the original Unix creators, also creator of the B programming language that was C's direct ancestor) and Rob Pike (one of the guys behind the Plan 9 resource operating system and another Bell Labs wizard who worked with folks like Thompson, Ritchie, Kernighan for most of his career) creating a new language (Go) that features garbage collection, it goes to show that it's not necessarily a bad thing when done right. FWIW, garbage collection itself is nothing new. It goes back at least as far as the 70's with Smalltalk, and I believe LISP may have done it as far back as the 80's. It's mostly a solved problem now.

    Did anyone else on the forum follow this podcast episode?

    I'm usually a day or two behind on the podcast episodes, but I do still listen to them.

    Post edited by Dragonmaster Lou on
  • Rym said:

    Cremlian said:

    how to I log into my old Orkut account? just gives me a window that says it's closing in September...

    I tried. They converted the system years ago to logins via Google Accounts. So, if I go to Orkut, it gives me a NEW, blank profile for my main google account. There appears to be no way to access an old account.

    I figured it out, you have to log out of your google account and then use the E-mail address you started orkut with in the google account log in. In my case it was my old AOL address. If you can't remember the password just do the forgot password stuff obvioulsy if you still have access to your old E-mail account. I got access.
  • Don't have access to old RIT e-mail address.
  • I still to this day am very sad about RIT's E-mail policy from our years. I wish I could look back at those years of E-mail but back then they didn't even transfer your account to a Alumni account. I know these days you have a RIT E-mail for life I'm pretty sure.
  • edited July 2014
    Garbage collection is usually fine. Most languages that have garbage collection have ways of managing what gets garbage collected so you can perform those cleanups faster. I would argue most of the time it's not a big deal. Manual memory management a pain in the ass to manage and often opens a lot of bugs in production code. If you don't need your shit to as fast as possible or on an embedded system then GCs do just fine.

    I was under the impression Java and C# did reference counting but apparently Java doesn't do it at all (or not to the same effect). Then I thought non root threads might be what did reference counting then I realized I was thinking of lock striping.

    EDIT: I just learned more about Java's weird memory management model.
    Post edited by MATATAT on
  • MATATAT said:

    I was under the impression Java and C# did reference counting but apparently Java doesn't do it at all (or not to the same effect).

    As I recall, Java uses a type of mark and sweep garbage collector instead of a reference counted garbage collector. The main reason for this is that reference counted garbage collectors can't really handle cyclic references. Python is an example of a language that uses a reference counted garbage collector, but I don't know offhand how it handles cyclic references. I think the implementation of its garbage collector is also why it's been so troubling to get rid of Python's Global Interpreter Lock (GIL).
  • edited July 2014
    Yeah Java keeps a map and does a scan of that to see if there are any nodes without edges. Then it marks those as dead and on the next minor sweep cleans them up.
    Post edited by MATATAT on
  • In regards to the program efficiency as a first year programming student I get rewarded by a professor teaching Python for making code more concise and more efficient on one hand while on the other hand I actually got marked down for writing code which would be more efficient by a professor teaching Java because "it would take someone who doesn't know the language longer to read" and "it wouldn't matter as the hardware can deal with it".

    I tried out Google's GO and that language feels really good to use compared to Java. Could just be me. I also had a read of Apple's Swift and found it difficult to follow, I chalked this up to me being uneducated.

    I was just trying to work out how to pick up good programming habits but with this type of approach is likely to be churning out the the 'hacks' others are speaking of.
    Dromaro said:

    Wait, people on the forum listen to the podcasts?

    Yes, I've been listening since 2006.
    Like Scott wondered in the newsletter, there are listeners who feel that they already know their podcast hosts (when they finally get to meet them at PAX Aus).
  • If you are writing a program where performance doesn't really matter, write your code so it is easy to read, clear, and concise. This is 99% of code.

    If you are writing something where every ounce of performance matters, like code for a high end game, space rocket, etc. then you can sacrifice readability.

    If you are a great programmer, you will be able to optimize for performance without losing readability.
  • Why can't you write high performance code with good comments? Wouldn't that be the best option?
  • Usually, only one TINY area of your code needs to be "high performance" even in high performance applications.
  • Rym said:

    Usually, only one TINY area of your code needs to be "high performance" even in high performance applications.

    You youngins and your 64 bit applications with near limitless memory. Why back when I learned programming we had hard limits on system resources. Do you really need a signed integer for that variable or can you go unsigned to save on memory?

    Seriously, I remember going from 16 bit to 32 bit and how liberating it was. My code could be messy and inefficient and still work!
  • HMTKSteve said:

    Why can't you write high performance code with good comments? Wouldn't that be the best option?

    Well, you can, but there is also the legendary "you are not expected to understand this" comment in classic UNIX code. That particular comment gets a bit of a bad rep, but the thing is that it's not the only comment referring to the code in question. There is a very long paragraph explaining the craziness they needed to do in order to properly do a context switch on the PDP-11 or something like that and the last line of the comment was "you are not expected to understand this."

    Then you get other fun stuff like Duff's Device.

    Ideally, you'd want good comments and easy to follow code. If it's impossible to make easy to follow code performant enough for your application, then yeah, you better have it well-commented. Still, even comments aren't always enough to fully understand what a piece of code does.
    HMTKSteve said:

    Rym said:

    Usually, only one TINY area of your code needs to be "high performance" even in high performance applications.

    You youngins and your 64 bit applications with near limitless memory. Why back when I learned programming we had hard limits on system resources. Do you really need a signed integer for that variable or can you go unsigned to save on memory?
    Bah, the 80-20 rule was in effect even back then. Also, there is a difference in performance vs. dealing with resource constraints. Sometimes the fastest algorithm may require more resources (RAM, CPU, etc.) then you have to offer, and in that case you need to fall back on a slower algorithm that better fits in your available resources.
  • HMTKSteve said:

    Why can't you write high performance code with good comments? Wouldn't that be the best option?

    Let me give you a fake example
    // the following line of code is what makes your application work
    poai03-fu8aoif hp98^)Y#%)(^ *(H:KL;;
    Ok, great. Now you know what that line of code does. But there's a problem with it. What do you do when you have to modify it?
  • Apreche said:

    HMTKSteve said:

    Why can't you write high performance code with good comments? Wouldn't that be the best option?

    Let me give you a fake example
    // the following line of code is what makes your application work
    poai03-fu8aoif hp98^)Y#%)(^ *(H:KL;;
    Ok, great. Now you know what that line of code does. But there's a problem with it. What do you do when you have to modify it?
    Personally, I find out just enough to know that I'm making a huge mistake, and then post that mistake on Reddit. You'll have detailed and through explanations within seconds.
  • edited July 2014
    Apreche said:

    HMTKSteve said:

    Why can't you write high performance code with good comments? Wouldn't that be the best option?

    Let me give you a fake example
    // the following line of code is what makes your application work
    poai03-fu8aoif hp98^)Y#%)(^ *(H:KL;;
    Ok, great. Now you know what that line of code does. But there's a problem with it. What do you do when you have to modify it?
    I wouldn't call that comment "good." In fact, that comment is about as useless a comment as you can have. It hardly says what that line of code does.

    The programming language also looks like a dialect of Malboge, but that's a different issue. :P
    Post edited by Dragonmaster Lou on
  • I have not written any serious code in probably six years. Even then I stuck to C (not C++, keep your OO). The code snippet above is complete gibberish to me because nothing in the comment tells me anything. You have open parentheses that are not closed and there is nothing to tell me what any of the variables (if they are variables) do.

    Typically when I do write code (mostly php these days) I tend to write things twice. The first pass is very clear and very inefficient while later passes are rewritten to increase performance and add comments to explain things that are no longer obvious due to performance enhancements.

    Since I code for pleasure I am not under any pressure to make my code look nice but it helps me if I have to go back months later and make changes.

    Bad: using $Array[] in my program.
    Good: using $ArrayOfLicenseData[] in my program.
  • HMTKSteve said:

    I have not written any serious code in probably six years. Even then I stuck to C (not C++, keep your OO). The code snippet above is complete gibberish to me because nothing in the comment tells me anything. You have open parentheses that are not closed and there is nothing to tell me what any of the variables (if they are variables) do.

    That snippet looks like it was taken out of one of those languages that were specifically written to be as hard as possible to understand, like my previously mentioned example of Malboge (of course, it probably wasn't literally taken out of one of those languages -- it's probably just Scott randomly banging on the keyboard). In many of those languages, each individual character is a different opcode, meaning that unclosed parentheses are perfectly valid syntax.

    Now if the comment was something like this:

    /*
    * The following line takes the Pre Optimized Account Information from 2003
    * and subtracts the Federated Universal 8-bit Access Object InterFace value
    * from it. It then runs it through the HP-98 calculator emulation routine and
    * then performs blah blah mathematical transfers on the result.
    */


    (Yeah, I didn't comment all the individual opcodes, but just imagine similarly detailed comments for them. I also struggled to come up with ways to describe the variable names based on what they look like). It would actually be decent, even when using such a horrible language.
  • Guys, what is wrong with you? Seriously. I just slammed on my keyboard to demonstrate a point. Let me try again.
    // INCREDIBLY HELPFUL COMMENT HERE
    ABSOLUTELY ILLEGIBLE CODE HERE
    No matter how helpful the comment is, if the code is completely illegible, you can't work on it.
  • Does anyone have any small programs in Java / Python / Go / C# which I could read to see what a good level of commenting and readable code looks like at a professional level?

    I would add C and C++ but I'm learning it next semester.
  • Apreche said:

    Guys, what is wrong with you? Seriously. I just slammed on my keyboard to demonstrate a point. Let me try again.

    // INCREDIBLY HELPFUL COMMENT HERE
    ABSOLUTELY ILLEGIBLE CODE HERE
    No matter how helpful the comment is, if the code is completely illegible, you can't work on it.
    AKA, the problem with most Perl code I've seen lurking about. Perl is probably the one real language that approaches some of the joke languages in lacking readability. Well, Perl and standard regex syntax (which is deeply integrated into Perl, though everyone else's regex routines use pretty much the same syntax).

    I'd argue that a programming language that by default (that is without using preprocessor tricks such as those used in the Obfuscated C Code Contest) allows you to easily write completely illegible code is a flawed or joke language. Perl's problem here is that the language supports so many syntactical shortcuts and context-sensitive sigils and operators that it does push the bounds of flawed due to allowing illegible code (and again, that's ignoring the regex syntax). C isn't quite so bad since the language isn't so dependent on syntactical shortcuts, context-sensitive sigils, and so on. Obfuscating C code actually requires some effort (via the preprocessor, "clever" use of typdefs and function pointers, etc.) if you want to do things more complicated than using minimal whitespace and single-character variable and function names. Obfuscating Perl seems to be standard operating procedure due to the nature of the language.
  • Is there a master list detailing the best uses of each particular language? My knowledge is limited to C and PHP with a little bit of java tossed in. For me anything I write to run on my PC is written in C and anything for the web is PHP.
  • edited July 2014
    I don't think such a list exists. It's mostly a case of established wisdom within the community as to which languages are best for which task, along with some historical knowledge and availability of tools/libraries. Here's my point of view, based on a combination of experience and various things I've read:

    Best for low-level systems stuff where you don't want/need assembly, including operating system kernels: C

    Best for user-space/slightly higher-level systems/application stuff where you need C-like native performance but want more safety than C offers and/or object orientation: C++

    Best for scientific number crunching: Fortran

    Best for web stuff: to be fair, any of the common ones such as Python, Ruby, PHP, are probably all roughly equally good. PHP does have some issues, mostly due to the syntax and libraries rather than the language's capabilities/performance.

    Best for "Swiss Army Knife" scripting: Take your pick between Python, Perl, and Ruby, with Python and Ruby having an advantage in readability over Perl.

    Best for long-running processes where you want decent performance, though not necessarily the best performance, and relatively safe code. Also good if you need cross-platform support: Java

    Best for user-driven Windows apps where the user, and not the CPU or I/O, is the primary performance bottleneck: C#

    These are just my own personal opinions and there certainly are overlaps between many of these categories (C# and Java in particular overlap quite a bit). These also don't cover all the other random situations where one language may be better than another (Lua is quite excellent if you need an embedded scripting engine, such as in games, for instance). They also don't cover trade-offs that people may make. For example, Fortran may be the best if you're doing some heavy duty nuclear physics simulations on massive datasets, but if you just want to bang out a few calculations on smaller datasets, tools such as MATLAB or Python with a library such as Scientific Python may be better as whatever time you lose due to the calculations taking longer is offset by the time saved in developing the code to perform the calculations.

    A lot of language decisions pretty much comes down to time spent developing/maintaining vs. time spent executing. Languages that are easier to develop in and/or maintain tend to be slower executing, but if the execution time is still "fast enough" for your purposes, then you're usually better off saving development time instead of execution time. In other words:

    If development_time < execution_time, probably best to go with something like C, C++, Fortran, etc.

    If execution_time < development_time, probably best to use some sort of scripting language like Python, Ruby, Perl, MATLAB, etc.

    Java and C# kind of straddle the line between these two extremes.

    Essentially, the best way that currently exists to determine if a particular language is best for any particular task is to look around and see what languages are used for similar tasks and follow the lead. Re-evaluate every few years as new languages crop up to see if things have changed since the last time.
    Post edited by Dragonmaster Lou on
Sign In or Register to comment.