Optimization of incremental encoder

Post datasheets of the proximity sensor and the rotary-encoder.
It is important information how the proximity sensor works:
capacitive, inductive, high-time of the signal, maximum-frequency of the proximity-sensor

and how the rotary-encoder works.
Optical detection, mechanic-elecetrical detection, half-pulse, full-pulse
signal-HIGH of channel A and channel B overlapping or not overlapping

and maybe your microcontroller is simply not fast enough:
4096 pulses per rotation at 700 rpm means
1 / (700 / 60 * 4096) = 0,0000209 seconds until next pulse rushes in
This is 20,9 microseconds which is pretty short.

on an arduino uno 16 MHz digitalwrite needs 48 cycles which is 3 microseconds
based on this post

I don't know how many cycle the other commands need.
You could add a digitalwrite HIGH at the top of your ISR
and a digitalWrite LOWat the end of your ISR and then watch on an oscilloscope how long the pulses are

or storing the value of micros() at the top and storing the value of micros() at the end of your ISR.
You will have to substract the execution-times of the added commands

best regards Stefan