Come within an ace of
Means almost or very nearly and dates from the early 16th century. During The Middle Ages, an ace or one was the lowest score one could throw with a dice and hence ace came to mean bad luck. From the early 16th century, an ace also meant a jot or a very small amount, from which the expression derives.