js_of_ocaml icon indicating copy to clipboard operation
js_of_ocaml copied to clipboard

Text encode decode

Open hhugo opened this issue 1 year ago • 4 comments

hhugo avatar Jul 26 '24 08:07 hhugo

I'd like to benchmark this change

hhugo avatar Jul 26 '24 08:07 hhugo

One should create the encoder and the decoder only once and reuse it, and use a fixed buffer for caml_jsstring_of_string.

vouillon avatar Aug 01 '24 15:08 vouillon

One should create the encoder and the decoder only once and reuse it, and use a fixed buffer for caml_jsstring_of_string.

Done

hhugo avatar Aug 02 '24 15:08 hhugo

@vouillon, any idea on how to benchmark this other that micro benchmarks ?

hhugo avatar Aug 30 '24 08:08 hhugo

A quick micro benchmark show a significant slowdown. master

n: 3, 0.167000 n: 7, 0.268000 n: 10, 0.371000 n: 20, 0.811000 n: 50, 1.989000 n: 100, 3.618000

this PR

n: 3, 1.209000 n: 7, 1.269000 n: 10, 1.354000 n: 20, 1.660000 n: 50, 2.632000 n: 100, 4.578000

hhugo avatar Oct 24 '24 07:10 hhugo

@vouillon, do you have any opinion on this ?

hhugo avatar May 14 '25 15:05 hhugo

A quick micro benchmark show a significant slowdown. master

n: 3, 0.167000 n: 7, 0.268000 n: 10, 0.371000 n: 20, 0.811000 n: 50, 1.989000 n: 100, 3.618000

this PR

n: 3, 1.209000 n: 7, 1.269000 n: 10, 1.354000 n: 20, 1.660000 n: 50, 2.632000 n: 100, 4.578000

Was this slowdown mitigated, or was the end decision to go with it?

OlivierNicole avatar Jul 02 '25 14:07 OlivierNicole

Was this slowdown mitigated, or was the end decision to go with it?

The slowdown should only affect non-ascii strings. Also, my assumption was that conversions between js and ml strings should be negligible compared to other computations. Recent bugs found in our previous implementation made me decide to ignore the performance impact and merge this PR

hhugo avatar Jul 03 '25 07:07 hhugo

I see. Thanks!

OlivierNicole avatar Jul 03 '25 08:07 OlivierNicole