Skip to content

Commit 5f554fb

Browse files
Merge pull request #313 from sshanks-kx/mtim
removed duplicate info on mtim
2 parents d21dea5 + d4d0644 commit 5f554fb

File tree

3 files changed

+21
-35
lines changed

3 files changed

+21
-35
lines changed

docs/basics/listening-port.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,26 @@ q)\p myhost:2000/2010 / use a free port between 2000 and 2010, using given h
8686

8787
## Multi-threaded port
8888

89-
A negative port sets a [multi-threaded](../kb/multithreaded-input.md) port and if used it must be the initial and only mode of operation, i.e. do not dynamically switch between positive port and negative port.
89+
A negative port sets a [multi-threaded](../kb/multithreaded-input.md) port and if used it must be the initial and only mode of operation,
90+
i.e. do not dynamically switch between positive port and negative port.
9091

92+
Note that there are a number of restrictions in multithreaded mode:
93+
94+
* queries are unable to update globals
95+
* [.z.po](../ref/dotz.md#zpo-open) is not called on connect
96+
* [.z.pc](../ref/dotz.md#zpc-close) is not called on disconnect
97+
* [.z.W](../ref/dotz.md#zw-handles) has a view on main thread sockets only
98+
* Cannot send async message
99+
* Views can be recalculated from the main thread only
100+
101+
Multithreaded input mode supports WebSockets and HTTP (but not TLS) since 4.1t 2021.03.30.
102+
TLS support available since 4.1t 2023.12.14. A custom [.z.ph](../ref/dotz.md#zph-http-get) which does not update global state should be used with HTTP.
103+
104+
The use of sockets from within those threads is allowed only for the one-shot sync request and HTTP client request (TLS/SSL support added in 4.1t 2023.11.10).
105+
These can be inefficient, as it opens, queries and closes each time. Erroneous socket usage is blocked and signals a nosocket error.
106+
107+
In multithreaded input mode, the seed for the random-number generator used for threads other than the main thread is based on the socket descriptor for that connection;
108+
these threads are transient – destroyed when the socket is closed, and no context is carried over for new threads/connections.
91109

92110
## Unix domain socket
93111

docs/kb/multithreaded-input.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ keywords: input, kdb+, mode, multithreaded, q, queue
55
---
66
# Multithreaded input queue mode
77

8-
9-
10-
118
By default, kdb+ is single-threaded, and processes incoming queries sequentially.
129

1310
An additional mode exists, designed for serving in-memory static data to an externally constrained number of clients only; it is not intended for use as a gateway, or serving mutable data, or data from disk. Each incoming connection is executed in its own thread, and is unable to update globals – it is purely functional in the sense that the execution of a query should not have side-effects.
@@ -18,27 +15,8 @@ Updates to globals are allowed only if they occur from within [`.z.ts`](../ref/d
1815

1916
The switching in and out of this mode now checks to avoid the situation where the main thread could have a socket open, and sockets being processed in other threads simultaneously.
2017

21-
Multithreaded input queue mode is active when the port for incoming connections is specified as negative, e.g. for startup
18+
Multithreaded input queue mode is active when the port for incoming connections is specified as [negative](../basics/listening-port.md#negative-ports), e.g. for startup
2219

2320
```bash
2421
$ q -p -5000
2522
```
26-
27-
Multithreaded input mode supports WebSockets and HTTP (but not TLS) since 4.1t 2021.03.30. TLS support available since 4.1t 2023.12.14.
28-
A custom [`.z.ph`](../ref/dotz.md#zph-http-get) which does not update global state should be used with HTTP.
29-
30-
31-
## Restrictions
32-
33-
Some of the restrictions are:
34-
35-
1. queries are unable to update globals
36-
2. [`.z.po`](../ref/dotz.md#zpo-open) is not called on connect
37-
3. [`.z.pc`](../ref/dotz.md#zpc-close) is not called on disconnect
38-
4. [`.z.W`](../ref/dotz.md#zw-handles) has a view on main thread sockets only
39-
5. cannot send async messages
40-
6. views can be recalculated from the main thread only
41-
42-
The use of sockets from within those threads is allowed only for the [one-shot sync request](../ref/hopen.md#one-shot-request) and HTTP client request (TLS/SSL support added in 4.1t 2023.11.10). These can be inefficient, as it opens, queries and closes each time. Erroneous socket usage is blocked and signals a `nosocket` error.
43-
44-
In multithreaded input mode, the seed for the random-number generator used for threads other than the main thread is based on the socket descriptor for that connection; these threads are transient – destroyed when the socket is closed, and no context is carried over for new threads/connections.

docs/wp/ipc/index.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ The TLS protocol is used to communicate across a network in a way designed to pr
222222

223223
### Negative ports
224224

225-
A kdb+ process can be started in multithreaded input mode by setting a negative port number. A multithreaded process will use separate threads for every process that connects, which means that each client request can be executed on a separate CPU.
225+
A kdb+ process can be started in multithreaded input mode by setting a [negative port number](../../basics/listening-port.md#multi-threaded-port). A multithreaded process will use separate threads for every process that connects, which means that each client request can be executed on a separate CPU.
226226

227227
Although secondary processes are used to farm queries out to multiple processes, they still have a single-threaded input queue. By using a negative port number, it is possible to multithread that queue too.
228228

@@ -237,15 +237,6 @@ q)\p
237237

238238
Connections can be opened to this process in the same way as described previously for positive port numbers.
239239

240-
Note that there are a number of restrictions in multithreaded mode:
241-
242-
- Queries cannot update globals
243-
- `.z.pc` is not called on disconnect
244-
- `.z.W` has a view of main thread sockets only
245-
- Cannot send async messages
246-
- Cannot serve HTTP requests
247-
- Views can be recalculated from the main thread only
248-
249240
```q
250241
q)h:hopen 4567
251242
q)h"1+1"
@@ -256,7 +247,6 @@ q)h"a:2"
256247
^
257248
```
258249

259-
260250
:fontawesome-solid-graduation-cap:
261251
[Multithreaded input](../../kb/multithreaded-input.md)
262252

0 commit comments

Comments
 (0)