(flus...@127.0.0.1)3> process_info(pid(0,961,0)).
[{current_function,{avcodec,yuv2jpeg0,4}},
{initial_call,{proc_lib,init_p,5}},
{status,runnable},
{message_queue_len,11},
{messages,[{jpeg,[{video_frame,video,37885047.833333336,
37885047.833333336,0,h264,keyframe,1,
<<0,0,0,2,9,240,0,0,21,...>>,
erlang/erts-6.0/bin/beam.smp -K true -Bi -A 100 -a 32 -stbt s -MBas aoffcaobf -MBacul 0
I'm running CPU bound task (make thumbnails from video) in a NIF under erlang 17 (erts 6.0)I'm using dirty nif scheduling:static ERL_NIF_TERMyuv2jpeg0(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {....}static ERL_NIF_TERMasync_jpeg(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {ERL_NIF_TERM result = yuv2jpeg0(env, argc, argv);return enif_schedule_dirty_nif_finalizer(env, result, enif_dirty_nif_finalizer);}static ERL_NIF_TERMyuv2jpeg(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {return enif_schedule_dirty_nif(env, ERL_NIF_DIRTY_JOB_CPU_BOUND, async_jpeg, argc, argv);}I see strange situation: none of CPU core is not 100% loaded, but processes that are calling yuv2jpeg function are hanging in this function:(flus...@127.0.0.1)3> process_info(pid(0,961,0)).
[{current_function,{avcodec,yuv2jpeg0,4}},
I suppose that I could meet the old problem with wrong scheduler behaviour when NIF is using thread for too long.
yuv2jpeg takes usually about 2-4 milliseconds to run.Is it possible to debug this situation? Can I somehow ask erlang if it decided that some scheduler is considered idle?