optimization in spark graph workflow