optimize stack size