The search giant has so far bucked the tech sector’s layoff trend, but pressure to cut costs leaves few options.