[sh_2dg] optimize emit_commands and engine_sync