Towards the optimal beam dump experiment to search for feebly interacting particles