I see that you have a typo in your code
var myPG1= tw.system.org.findParticipantGroupByName("role1");
myPG1.refresh();
var allUsers = myPG1.allUsers;
for (var i=0; i<allUsers.length; i++)
{ log.info(allUsers[i].name);
}
try a refresh once and time the individual steps which one is taking long time findPG or .allUsers also time the refresh also, idea being you may need to call refresh only once and caching should happen after that, I remember we had a situation where calling the refresh on a scheduled basis though a timer UCA helped.