-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack overflow serialising long list #96
Comments
Is this a known limitation of Could |
It's a known limitation of
There are alternative smarter versions of |
Actually the OCaml-containers |
Now is it worth a dependency on
|
No, I don't think this is worth an extra dependency. We could just use |
Is there a length of list to check that would be a stack overflow on most machines? I'm trying to make a test that would fail with the current implementation but succeed with a stack-safe |
On my machine P.S.: I can't read the integer literal you wrote to check that it is a million, do not hesitate to use underscores in numeric literals: |
Nice! Many thanks. I think it's an improvement. Can't really see any serious downsides... I'm not super-familiar with GitHub processes... My understanding is that this is now merged back to the master branch but not yet released. Is that correct? When do you anticipate making a new release with this change included in it? |
See ocaml-ppx/ppx_deriving_yojson#96 With non-tail-recursive to_yojson, List::range over about 6k raises a stack overflow, as does DB::getAll. with tail-recursive yojson, I managed to List::range 0 60000 (60k) and DB::getAllWithKeys a db with 18k records before I stopped trying to break it. https://trello.com/c/1HakZf5x/1570-max-call-stack-size-errors
Serialising an array with many (i.e. hundreds of thousands) elements using the generated
to_yojson
function produced a stack overflow. Tracked this down to the use ofList.map
in this snippet of the generated code:Replacing
List.map
with the tail-recursiveList.rev_map
fixes this but reverses the order. CallingList.rev
on the result ofList.rev_map
should generate correct results without the risk of a crash, but at a performance penalty.The text was updated successfully, but these errors were encountered: