Can someone help with it?

08/28/2019 17:43 InnoTx#1
Hi. :feelsbadman:

i Really dont want to Annoying someone just write something if u want to be Helpfull


now i Worked on the new Leaked or Released Cryless Source and got some Problems With Parser and ON.Import.Console


now the first Problem is i get this Error:

That the CPU issue is at 100% and it does nothing like it dont Parse just CPU issue is at 100%


or

it shows me something with that code
HTML Code:
     Parallel.ForEach(_packetList.Where(o => o[0].Equals("at")), linesave =>
            {
                if (linesave.Length <= 7 || dictionaryMusic.ContainsKey(int.Parse(linesave[2])))
                {
                    return;
                }
                dictionaryMusic[int.Parse(linesave[2])] = int.Parse(linesave[7]);
                if (_packetList.FirstOrDefault(s => s[0].Equals("c_map") && _packetList.FindIndex(b => b == s) > _packetList.FindIndex(b => b == linesave)) is string[] cmap)
                {
                    dictionaryMap[short.Parse(cmap[2])] = short.Parse(linesave[2]);
                }
            });
and if u want to ask did u have add in ON.Master.Server this one:
HTML Code:
    <add key="PartnerSpXp" value="1"/>
yes i did it.

i've did this one too :
HTML Code:
                    string[] linesave = line.Split(' ');
                    if (linesave.Length <= 2)
                    {
                        continue;
                    }
idk what i have to do... so if someone knows and want to Help me Feel free to add me on Discord : Inno#5157





EDIT !!!: so now i've got helped by the Code from @[Only registered and activated users can see links. Click Here To Register...] Ty so much btw.

and now the Problem is that ive got this one : [Only registered and activated users can see links. Click Here To Register...]

if i Click on "Y" it starts up to 100% and my pc freeze

btw. no my pc is good and would be much then enough for it so idk could someone help me ?

Ty in advance
Sorry for my Bad english


Greetings
Inno
08/28/2019 20:10 Blowa#2
Typical "optimization" that is just bullshit.
Using parallel for that is useless and may produce a deadlock/unexpected behavior.

You are trying to write on a dictionary without even checking if the dictionary already contains the key.
If your packet.txt got 2 entries where someone went on the same map, it might happen that your dictionary is getting modified (adding a new key)

Don't know if that dictionary is a "ConcurrentDictionary" on the source you are using, but if it's not, it may be a probably reason of your crashes.

As well, I would recommend to switch back to a simple foreach without any kind of concurrency.
Parallel foreach is sometimes faster than a foreach, depending on how you manage to use the data you are iterating on.

Anyway, usage of Parallel here is unjustified and probably slowing down your parsing for no reason.
But this kind of code does have CPU costs since it's using computation on CPU (parsing, linq filtering...)
08/28/2019 21:24 InnoTx#3
so what u mean what i have to do now i mean i dident write the code and ive got some Crashes with Where is the Parallel.cs ... idk what u mean sorry but ty for trying help me
08/28/2019 22:41 NosRaible#4
Quote:
Originally Posted by InnoTx View Post
Hi. :feelsbadman:

i Really dont want to Annoying someone just write something if u want to be Helpfull


now i Worked on the new Leaked or Released Cryless Source and got some Problems With Parser and ON.Import.Console


now the first Problem is i get this Error:

That the CPU issue is at 100% and it does nothing like it dont Parse just CPU issue is at 100%


or

it shows me something with that code
HTML Code:
     Parallel.ForEach(_packetList.Where(o => o[0].Equals("at")), linesave =>
            {
                if (linesave.Length <= 7 || dictionaryMusic.ContainsKey(int.Parse(linesave[2])))
                {
                    return;
                }
                dictionaryMusic[int.Parse(linesave[2])] = int.Parse(linesave[7]);
                if (_packetList.FirstOrDefault(s => s[0].Equals("c_map") && _packetList.FindIndex(b => b == s) > _packetList.FindIndex(b => b == linesave)) is string[] cmap)
                {
                    dictionaryMap[short.Parse(cmap[2])] = short.Parse(linesave[2]);
                }
            });
and if u want to ask did u have add in ON.Master.Server this one:
HTML Code:
    <add key="PartnerSpXp" value="1"/>
yes i did it.

i've did this one too :
HTML Code:
                    string[] linesave = line.Split(' ');
                    if (linesave.Length <= 2)
                    {
                        continue;
                    }
idk what i have to do... so if someone knows and want to Help me Feel free to add me on Discord : Inno#5157


Ty in advance
Sorry for my Bad english


Greetings
Inno
I have fix of it. Maybe i can give you some advises :)

Layne#6797
08/29/2019 06:11 erixor#5
Quote:
Originally Posted by InnoTx View Post
so what u mean what i have to do now i mean i dident write the code and ive got some Crashes with Where is the Parallel.cs ... idk what u mean sorry but ty for trying help me
"where is the parallel.cs" u_u

In the code example you sent in your thread, there is a :
Parallel.ForEach(_packetList.Where(o => o[0].Equals("at")), linesave => blablabla...

Replace that Parallel by a simple foreach such as :

Code:
foreach (var linesave in _packetList.Where(o => o[0].Equals("at")))
{
     blablabla...
}
Because as Blowa said, Parallel foreach involves not needed concurrency. That's what happens when people don't know what they're doing.

Btw, this is only a "probable fix", because we can't really help more with a simple "it shows me something with that code "
09/01/2019 16:44 InnoTx#6
EDIT !!!: so now i've got helped by the Code from @[Only registered and activated users can see links. Click Here To Register...] Ty so much btw.

and now the Problem is that ive got this one : [Only registered and activated users can see links. Click Here To Register...]

if i Click on "Y" it starts up to 100% and my pc freeze

btw. no my pc is good and would be much then enough for it so idk could someone help me ?
09/04/2019 12:53 InnoTx#7
push still need help with it
09/04/2019 18:39 FI0w#8
Quote:
Originally Posted by InnoTx View Post
push still need help with it
This "professional" code is so. It's use like 100% cpu for loading maps make sure everything is like it should be. Even then it will take like 5-20min depend on your Pc.
09/04/2019 22:02 0Lucifer0#9
Opennos parser is having a lot of n+1 you will need to remove them but this is not easy task without knowledge in c# and Db.