Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Enable multithreading on P2P deserialization workload" #4757

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Nethermind/Nethermind.Init/Steps/InitializeNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ private async Task InitPeer()
encryptionHandshakeServiceA,
_api.SessionMonitor,
_api.DisconnectsAnalyzer,
_networkConfig.P2PHandlerThreadCount,
_api.LogManager);

await _api.RlpxPeer.Init();
Expand Down
7 changes: 3 additions & 4 deletions src/Nethermind/Nethermind.Network.Test/Rlpx/RlpxPeerTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2021 Demerzel Solutions Limited
// This file is part of the Nethermind library.
//
//
// The Nethermind library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// The Nethermind library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -40,7 +40,6 @@ public async Task Start_stop()
Substitute.For<IHandshakeService>(),
Substitute.For<ISessionMonitor>(),
NullDisconnectsAnalyzer.Instance,
1,
LimboLogs.Instance);
await host.Init();
await host.Shutdown();
Expand Down
9 changes: 3 additions & 6 deletions src/Nethermind/Nethermind.Network/Config/INetworkConfig.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2021 Demerzel Solutions Limited
// This file is part of the Nethermind library.
//
//
// The Nethermind library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// The Nethermind library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -81,8 +81,5 @@ public interface INetworkConfig : IConfig

[ConfigItem(DefaultValue = "", Description = "Bootnodes")]
string Bootnodes { get; set; }

[ConfigItem(DefaultValue = "0", Description = "[TECHNICAL] Set P2P handler thread count. Set this to a low number such as 1 or 2 if you have too slow block processing during old bodies or old receipts sync which may cause missed attestation. Defaults to processor count - 2.")]
int P2PHandlerThreadCount { get; set; }
}
}
7 changes: 3 additions & 4 deletions src/Nethermind/Nethermind.Network/Config/NetworkConfig.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2021 Demerzel Solutions Limited
// This file is part of the Nethermind library.
//
//
// The Nethermind library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// The Nethermind library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -42,6 +42,5 @@ public class NetworkConfig : INetworkConfig
public string Bootnodes { get; set; } = string.Empty;
public int DiscoveryPort { get; set; } = 30303;
public int P2PPort { get; set; } = 30303;
public int P2PHandlerThreadCount { get; set; } = 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2021 Demerzel Solutions Limited
// This file is part of the Nethermind library.
//
//
// The Nethermind library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// The Nethermind library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

Expand Down
21 changes: 5 additions & 16 deletions src/Nethermind/Nethermind.Network/Rlpx/RlpxHost.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2021 Demerzel Solutions Limited
// This file is part of the Nethermind library.
//
//
// The Nethermind library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// The Nethermind library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -54,17 +54,14 @@ public class RlpxHost : IRlpxHost
private readonly ILogger _logger;
private readonly ISessionMonitor _sessionMonitor;
private readonly IDisconnectsAnalyzer _disconnectsAnalyzer;

// Main executor group. Used to execute snappy decompression and message deserialization.
private readonly IEventExecutorGroup _group;
private IEventExecutorGroup _group;

public RlpxHost(IMessageSerializationService serializationService,
PublicKey localNodeId,
int localPort,
IHandshakeService handshakeService,
ISessionMonitor sessionMonitor,
IDisconnectsAnalyzer disconnectsAnalyzer,
int handlerThreadCount,
ILogManager logManager)
{
// .NET Core definitely got the easy logging setup right :D
Expand All @@ -82,15 +79,7 @@ public RlpxHost(IMessageSerializationService serializationService,
// new LoggerFilterOptions { MinLevel = Microsoft.Extensions.Logging.LogLevel.Warning });
// InternalLoggerFactory.DefaultFactory = loggerFactory;

if (handlerThreadCount == 0)
{
// Using slightly less than processor count to give some compute for other tasks
// The thread count is rarely a limit, outside of old bodies/old receipts, but it may improve
// some latency as a peer message may get blocked by another peer's message deserialization
// if thread count is 1.
handlerThreadCount = Math.Max(1, Environment.ProcessorCount - 2);
}
_group = new MultithreadEventLoopGroup(handlerThreadCount);
_group = new SingleThreadEventLoop();
_serializationService = serializationService ?? throw new ArgumentNullException(nameof(serializationService));
_logManager = logManager ?? throw new ArgumentNullException(nameof(logManager));
_logger = logManager.GetClassLogger();
Expand Down