Skip to content

Multithreading (Load balancing). Question? (maybe bug). #4320

Closed
@heretic13

Description

@heretic13

Hello.

I have an architectural question.
I don't understand how threads are used in pjsip.
I understand perfectly well that if I use a sound card sampling frequency different from the conference frequency, then the library will use a resampler. Also, if a codec with a sampling frequency different from the conference frequency is used during a call, then the resampler will also be used.
I have a device with a 4-core processor.
During the tests, I made the following settings:

  1. pjsua_media_config media_cfg;
    pjsua_media_config_default(&media_cfg);
    media_cfg.thread_cnt = 4;
  2. pjsua_config sua_cfg;
    pjsua_config_default(&sua_cfg);
    sua_cfg.thread_cnt =8;

Then I do the tests:
I specifically chose a codec with a frequency of 8 kHz so that a resampler would be used. The frequency of the sound card and conference is 16 kHz.

  1. A call to a single subscriber. Bidirectional audio transmission is used between the local audio system and the subscriber. Echo cancellation is not used.
  2. Two simultaneous calls to two subscribers. Bidirectional audio transmission is used between the local audio system and subscriber N1 and bidirectional audio transmission between the audio system and subscriber N2. Echo cancellation is not used.
  3. Then I repeat test N2 with echo cancellation enabled.

I see that the CPU load in test 2 is greater than the CPU load in test 1. I see that the CPU load in test 3 is greater than the CPU load in test 2. The test results are logical and understandable.

But the problem is that the ENTIRE load on the processor falls on one core (one thread), while the load of other pjsip threads on other processor cores is negligible!.

On the third test, the sound from my speakers began to choke.

I believe that I am doing something wrong, but I do not know how to correctly tell the pjsip library to use all processor cores to organize a conference, handle calls, resample conference ports (if the port frequency does not match the conference), and perform echo cancellation.

Also, I did not find an official document in pjsip where the threads and their purpose would be described (if a fixed number of threads is used in pjsip). From the outside, it is not clear to me how many threads perform resampling, conference processing, sound card processing, echo cancellation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions