rescript-labs/decco

Performance issue decoding large arrays.

Opened this issue · 0 comments

em commented

Decoding is extremely slow with large arrays:

try it:

@decco
type t = {ids: array<string>}

Js.Console.timeStart("noneofthisisslow")
let bigboi = {ids: Belt.Array.makeBy(100000, i => i->string_of_int)}
let json = bigboi->Js.Json.stringifyAny->Belt.Option.getExn->Js.Json.parseExn

Js.Console.timeEnd("noneofthisisslow")

Js.Console.timeStart("yusoslow")
let _ = t_decode(json)
Js.Console.timeEnd("yusoslow")

Js.Console.log("what gives?")
noneofthisisslow: 50.296ms
yusoslow: 6.616s
what gives?

Doing batch processing of millions of records in nodejs and found decco of all things locking up the event loop causing timeouts elsewhere, sometimes blocking for minutes in our case.