How old is the doctrine of a sinless Mary? What are the oldest known writings that state that Mary was without sin?
The earliest Christian writings outside the bible are from what are called the Church Fathers, from around the middle of the second century onwards for a few hundred years.

On the Immaculate Conception explicitly, the earliest would appear to be Hippolytus and Origen:


  He [Jesus] was the ark formed of incorruptible wood. For by this is signified that His tabernacle [Mary] was exempt from defilement and corruption (Hippolytus, Orat. In Illud, Dominus pascit me, in Gallandi, Bibl. Patrum, II, 496 ante [A.D. 235]).





  This Virgin Mother of the Only-begotten of God is called Mary, worthy of God, immaculate of the immaculate, one of the one (Origen, Homily 1 [A.D. 244]).


Earlier writers hint at the doctrine, by comparing Mary to Eve, who was created without the stain of sin:


  [Jesus] became man by the Virgin so that the course that was taken by disobedience in the beginning through the agency of the serpent might be also the very course by which it would be put down. Eve, a virgin and undefiled, conceived the word of the serpent and bore disobedience and death. But the Virgin Mary received faith and joy when the angel Gabriel announced to her the glad tidings that the Spirit of the Lord would come upon her and the power of the Most High would overshadow her, for which reason the Holy One being born of her is the Son of God. And she replied, "Be it done unto me according to your word" (Luke 1:38) (Justin Martyr, Dialogue with Trypho 100 [A.D. 155]).





  Consequently, then, Mary the Virgin is found to be obedient, saying, "Behold, O Lord, your handmaid; be it done to me according to your word." Eve . . . who was then still a virgin although she had Adam for a husband — for in paradise they were both naked but were not ashamed; for, having been created only a short time, they had no understanding of the procreation of children . . . having become disobedient [sin], was made the cause of death for herself and for the whole human race; so also Mary, betrothed to a man but nevertheless still a virgin, being obedient [no sin], was made the cause of salvation for herself and for the whole human race. . . . Thus, the knot of Eve's disobedience was loosed by the obedience of Mary. What the virgin Eve had bound in unbelief, the Virgin Mary loosed through faith (Iranaeus, Against Heresies 3:22:24 [A.D. 189]).


There are further, later comments where I found those but those are the earliest cited. These four are the earliest of the Fathers.