-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
fix data to use managed memory instead of naked pointer #96
Conversation
Thanks for your investigation I been to dive into this. Did you try to run benchmarks for this? And also measure GC stats in the end comparing to the main branch? |
I'm not sure if I did it right, but it doesn't seem to make a noticeable difference on a simple usecase.
Are there any scenarios where GC can be critical? |
If the intention is to use the codec's buffer as is, I think a completely different approach is also possible. Instead of copying the buffer into a bigarray, create a custom block pointer and register the finalizer on it. Although odiff will be less dependent on OCaml, it will boot faster with less copying. Either way, it will have roughly the same lifetime as the program, so major GC (of the image data) will occur rarely I guess. Note: This change should not trigger additional GC, it just moves the buffer's location. |
I didn't review the details but the change broadly matches what I had in mind. Did you manage to test that the project now works with OCaml 5 ? |
Yep, i tested it for work with OCaml 5 in my branch https://github.com/cometkim/odiff/tree/ocaml5 |
btw the OCaml 5 build is about 10% larger (5_148_720 -> 5_725_304 bytes) perf is not changed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally I've got some time to investigate and play around with this change. I think is pretty nice and thank you for diving into this!
Great! Migrating to OCaml 5 is now very simple. I haven't tried parallelization yet, but I guess it shouldn't be too difficult. Considering the anti-aliasing feature, some pixels may be processed redundantly, or additional optimization may be required. |
Tried to update the ocaml 5 but I am getting esy permissoin issues. I see you have ocaml5 branch in your fork, were you able to build it with esy @cometkim ? |
yep, I already did upstream it reasonml/reason-native#271 let me file a PR to this repo too |
resolving esy dependencies with bunch of overrides is non-trivial .. 😅 I'm fixing effects that started appearing in a completely unrelated place after changing the |
Found this ocaml/opam-repository#25961 I think I should try again after |
as following ocaml/ocaml#13141
I tried to fix it but let me ask if this doesn't ruin your intentions.