Skip to content

WIP: speed up msg box by caching the glist in t_messresponder for fetching $0

Jonathan Wilkes requested to merge message-improvements into master

This brings msg box back to the same performance it had before $0 expansion was added as a feature to message boxes.

The first implementation relied on calling canvas_setcurrent and canvas_unsetcurrent in the message box methods. This added a malloc/free for each message box method call.

Instead this implementation caches the msg box glist in the t_messresponder. That is available as the target parameter in m_binbuf. Unfortunately, we have to add a parameter to binbuf_realizedollsym. Since that's a public function we have to break out the new param into binbuf_dorealizedollsym.

A very basic test patch is attached.

Here are some performance numbers on my Asus C201 Rockchip under Debian Stretch for the test patchmessage-perf.pd:

Edit: added "2nd impl. bugfix" for c60dbc04

Average performance

[ ( [42( [$0( [list one two three four $0 $1(
no $0 in msg box: 5 ms 7ms 8ms 14.5ms
1st implementation: 11.5ms 14ms 13ms 17 ms
2nd implementation: 4.5ms 6ms 8.7ms 13 ms
2nd impl. fix 1: 4.5ms 6.5ms 7.5ms 14 ms
2nd impl. fix 2: 4 ms 6ms 6.5ms 13 ms

Worst case performance

[ ( [42( [$0( [list one two three four $0 $1(
no $0 in msg box: 12 ms 17ms 17ms 35.5ms
1st implementation: 32 ms 35ms 36ms 37 ms
2nd implementation: 11 ms 15ms 19ms 32 ms
2nd impl. fix 1: 12 ms 17ms 17.7ms 32 ms
2nd impl. fix 2: 12.5ms 17ms 19ms 35 ms

Merge request reports