Avoid usage of dynamic vars when reading and writing json
As pr DJSON-31, benchmarks show that the cost of setting up the bindings for the dynamic vars is high, especially when working with small json payloads.
Passing an options map instead of using dynamic vars.
Although this speeds up quite a bit compared to using the dynamic vars, the creation of the options-map incurs a penalty, as seen from the benchmarks in where parameter passing was used.
For reading, I’d suggest passing them as params as it’s only three of them. For writing, the code is somewhat more involved, so it might make sense to pass them as a map.
It might also be that there is a faster way to create the options maps.
Updated patch with benchmarking code and data
Done in 0002-DJSON-32-Use-options-maps-instead-of-dynamic-vars.patch
Can you switch from using hash-map when constructing the option maps to array-map? If it's not already faster now, it likely will be in 1.11.
I think we should use options map for both reading and writing - that's going to evolve better and there is still more room to reduce the overhead in option map construction but we can defer that to future.