When to make dirty NIFs?

Hi,

I have a NIF where profiling indicates some functions are hovering around the 1ms region so I intend to make them dirty. Should I just make those functions dirty, or should I do it for all of them? Is there a disadvantage in making a fast NIF function dirty when it doesn’t need to be?

Thanks

2 Likes

There is a small performance cost as the process needs to be re-scheduled on another scheduler to do the dirty work. How much it costs will vary depending on lots of factors, so you should benchmark your case and see if it matters in the big scheme of things.

5 Likes

Thanks, it’s safe to have some functions dirty and others not then?

1 Like

yes it is.

2 Likes