My max nerdetry…

Update

Ive attached some patches that demonstrate the optimization techniques Ive mentioned. Been horribly busy.

Download the patches here

has reached new heights:

sigh.. but at least ive got a nice Share shirt as well. Ive always wanted to make an [uzi] max shirt, in the ‘defend brooklyn’ style. Perhaps I ought to actually design it.

Speaking of Max/MSP, I recently spoke with Marlon, and he had some questions about general optimization techniques for Max/Jitter (I wont pretend to know MSP tilde objects and that jazz). I wont get too much into specifics, but ill cover some basics here (might as well, you know, have some content every once in a while).

Some Max and Jitter optimization techniques:

  • Any programming language will benefit from organized and elegant code. Organize first, then optimize after youve gotten it working. Patcher spaghetti is just not easy to work with, debug, let alone optimize.
  • Use one clock source to drive things. One [metro] or [qmetro], or, ideally use [clocker] and [setclock] to make your own abstracted timing source and tell any objects that take the ‘clock’ message to use your named clock. This stops objects like [line] from internally instantiating and using their own metro. If youve got a high resolution clock in your patch somewhere, no need to re-make it for every object that needs a timer. (Just make sure that the clock you are using has a higher resolution than what you need to be slaved off of it)
  • Jitter users: if you have a jit.pwindow and are using it to view matrices that are smaller than the size of your jit.pwindow, turn the onscreen attribute off.
  • If you are driving [jit.qt.movie] or with a high speed clock source (I typically use [qmetro 2] to drive my patches, use [qlim 33.33] (or anything appropriate) to limit the speed the [jit.qt.movie] is banged. No need to output more matrices than you need, and [jit.qt.movie] can be cpu greedy to decode all those frames.
  • [jit.change] – no need to calculate when you dont have to.
  • Use trigger (ie: [t b b b] ). really. it helps organize your code and unambiguate timing/left right issues as well.
  • [vexpr] seems to typcially be faster than [expr].
  • And most important, experiment with different approaches. Sometimes you find surprises.

Thats by no means a complete list, but ill throw up some patches, and maybe even some before and after code to illustrate some points. Using the above principles, I was able to get a patch that barely ran at 14 fps on my system (1.67 powerbook G4) to over 300 with video shown on screen, or close too 900 (just checked, make that 1000) (yes 1000), without any video, and only matrix processing. The patch was made by a co-worker to decode and parse closed captioning signals in a video stream. Fun stuff.

7 Responses to “My max nerdetry…”

  1. dan Says:

    Did you make the shirt or buy it? I’ve been meaning to make a Max patch t-shirt iron-on. Patch candidates welcome. :)

  2. Brecht Says:

    Hi Vade,

    Interesting stuff, the optimization part! I’m particularly interested in the named clocker thing, could you maybe give some more info about that,..? Been messing around, but I can’t seem to work out how that should work.

  3. vade Says:

    Can you tell im franticly refreshing my email all day long?

    Ive posted some patches that demonstrate the performance differences for the optimization techniques I talk about in the post. The link is above :)

    Enjoy, and hope it clears things up.

  4. vade Says:

    Oh, and Dan, no, I didnt make it (unfortunately), I purchased it for $9 from http://suchaturnon.com/ – its in their ‘attainable’ section.

    Im pondering the LFO one now too.. hmm..

  5. Gideon Says:

    Hey, interesting stuff. Could you tell us on which computer you benchmarked this ?
    I’m getting similar and different results here on my MBpro 2,16

  6. Brecht Says:

    Sweet!
    One can never have enough optimization techniques in the bag.
    I take it you also have a blackberry for those painfull transitions between locations with internet access :)
    Thanks!

  7. vade Says:

    Gideon: Im using my G4 Powerbook 1.67, OS X 10.4.7 , Qucktime 7.1.2 with 1.5Gb Ram. Ive actually got access to a Macbook Pro 2.0Ghz today. Ill run the tests and see what I can come up with.

    What were your results?

    Brecht, no 😉

    Id love to know any other techniques people use. I havent done a complete list yet, but I dont recall everything so far. Maybe people could point to some patches for optimization?

Leave a Reply