[ https://issues.apache.org/jira/browse/SSHD-1148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17306830#comment-17306830 ]
Lyor Goldstein edited comment on SSHD-1148 at 3/23/21, 7:24 AM: ---------------------------------------------------------------- {quote}Despite being the operation being parallel executed, as both the operation are parallelly executed, a single thread does the same operation {quote} It only seems this way - there is actually a +dedicated thread+ for each {{SftpSubsystem}} instance running on the server side. The reason you see the same thread name is because of this code: {code:java} public SftpSubsystem(ChannelSession channel, SftpSubsystemConfigurator configurator) { super(channel, configurator); CloseableExecutorService executorService = configurator.getExecutorService(); if (executorService == null) { this.executorService = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName()); } else { this.executorService = executorService; } } {code} As you can see. the argument to {{ThreadUtils.newSingleThreadExecutor}} is the class name - which is always {{SftpSubsystem}} - therefore when the executor derives its name, it always gets the same result. Thanks for bringing this to our intention - I will fix this. {quote}is there any way to pass an executor thread pool to SshServer so we can see different thread working parallelly. {quote} Not through {{SshServer}} but rather through the {{SftpSubsystemFactory}} - but like I said, you do have threads working in parallel - it just doesn't look like this - so I would not recommend it (unless you want to manage your own pool for some reason) {quote}sshdServer.setScheduledExecutorService(Executors.newScheduledThreadPool(5), true); Will this spawn 5 parallel threads, and will be shut down gracefully as the boolean is set to true {quote} No - the scheduled executors are used for something else - e.g., idle timeout, heartbeat {quote}If it's a single thread model then if we use NioWorker threads as 2, and the number of cores if I have 4 so total will be 6, so now as 1 core is occupied with that single thread, will the remaining 5 cores will sit idle? {quote} (a) it definitely is +not+ a single thread model and (b) {{NioWorker}} threads affect +all+ SSH sessions and their behavior and not just SFTP. was (Author: lgoldstein): {quote}Despite being the operation being parallel executed, as both the operation are parallelly executed, a single thread does the same operation {quote} It only seems this way - there is actually a +dedicated thread+ for each {{SftpSubsystem}} instance running on the server side. The reason you see the same thread name is because of this code: {code:java} public SftpSubsystem(ChannelSession channel, SftpSubsystemConfigurator configurator) { super(channel, configurator); CloseableExecutorService executorService = configurator.getExecutorService(); if (executorService == null) { this.executorService = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName()); } else { this.executorService = executorService; } } {code} As you can see. the argument to {{ThreadUtils.newSingleThreadExecutor}} is the class name - which is always {{SftpSubsystem}} - therefore when the executor derives its name, it always gets the same result. Thanks for bringing this to our intention - I will fix this. {quote}is there any way to pass an executor thread pool to SshServer so we can see different thread working parallelly. {quote} No through {{SshServer}} but rather through the {{SftpSubsystemFactory}} - but like I said, you do have threads working in parallel - it just doesn't look like this - so I would not recommend it (unless you want to manage your own pool for some reason) {quote}sshdServer.setScheduledExecutorService(Executors.newScheduledThreadPool(5), true); Will this spawn 5 parallel threads, and will be shut down gracefully as the boolean is set to true {quote} No - the scheduled executors are used for something else - e.g., idle timeout, heartbeat {quote}If it's a single thread model then if we use NioWorker threads as 2, and the number of cores if I have 4 so total will be 6, so now as 1 core is occupied with that single thread, will the remaining 5 cores will sit idle? {quote} (a) it definitely is +not+ a single thread model and (b) {{NioWorker}} threads affect +all+ SSH sessions and their behavior and not just SFTP. > Question on thread handling with IOservicefactory as NIO2 > --------------------------------------------------------- > > Key: SSHD-1148 > URL: https://issues.apache.org/jira/browse/SSHD-1148 > Project: MINA SSHD > Issue Type: Question > Reporter: Susmit Sarkar > Assignee: Lyor Goldstein > Priority: Major > > Hello Lyor/Team, > I am laterally performing 2 PUT operations, one from ssh terminal and another > from WinSCP. During the process, I am printing the thread name/id. For both > the case, I am getting a thread name as: > *sshd-SftpSubsystem-thread-1* > Despite being the operation being parallel executed, as both the operation > are parallelly executed, a single thread does the same operation may be > because of 2 different sessions, is there any way to pass an executor thread > pool to *SshServer* so we can see different thread working parallelly. May be > my understanding is wrong, can you please guide me > *sshdServer.setScheduledExecutorService(Executors.newScheduledThreadPool(5), > true);* > Will this spawn 5 parallel threads, and will be shut down gracefully as the > boolean is set to *true* > If it's a single thread model then if we use NioWorker threads as 2, and the > number of cores if I have 4 so total will be 6, so now as 1 core is occupied > with that single thread, will the remaining 5 cores will sit idle? -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org