Performance of PurchasesReceiptParser.default.parse(from:)
could be drastically improved.
#4006
Labels
PurchasesReceiptParser.default.parse(from:)
could be drastically improved.
#4006
Hey guys! I played a bit with profiler and was able to make
PurchasesReceiptParser.default.parse(from:)
way faster.Here are results that I've observed on iPhone 8.
Date
mach_absolute_time
Cycles
INST_ALL
L1D_TLB_MISS
Unfortunately I don't have active developer account and I only tested on small receipts that I've found over internet. If you have any big receipt please send me a base64String.
Surprisingly reason of slowness is Date parsing. In particular
ISO8601DateFormatter.default
called fromArraySlice<UInt8>.toDate
. Since all receipts I see have date formatyyyy-MM-dd'T'HH:mm:ssZ
it's easy to parse components manually. Here is the whole change:I have prepared branch with tests ensuring that this change has no impact on SDK behavior. Unfortunately I don't have permission to push. Could you grant me permissions so I could prepare pull-request and you could decide if you want this improvement or not?
Btw it's crazy that this change has so huge impact. I would imagine that
Self.toDateCalendar.date(from: components)
does most of the work. It also shows that industry standards are really bad. Apple's server had some kind integer counting seconds, they wasted compute to create string, on device we receive string and waste compute to calculate some kind integer counting seconds 🙃The text was updated successfully, but these errors were encountered: