I have re-written a part of code in C. When testing it with logging the resource usage using getrusage(2) C API.
Before changing the code:
A voluntary context switch can occur whenever a thread/process makes a system call that blocks.
An involuntary context switch occurs when a thread has been running too long (usually something like 10 ms) without making a system call that blocks and there are processes waiting for the CPU.
It looks like your program is more CPU-intensive now than before. If you have made it multi-threaded then an increase is probably expected.
821 context switches - depending on the execution time of your program this may or may not be a lot.
If you want to reduce the number of context switches you can reduce the number of worker threads so there are less threads than there are CPU cores.
Update
Assuming that the load is identical in both cases, it looks like the code modifications have increased the cpu usage. If the increased load is a concern you should analyse the code to find the bottleneck. Instrumentation can be helpful in isolating which part of the code is causing the problem.