From filamentary failure to durable halide perovskite memristors