Skip to content

Commit fbcb657

Browse files
authored
Merge pull request #433 from FerencBodon-Kx/DOC-1519-slash-P
DOC-1519-slash-P rewrite misleading sentence about \P
2 parents 2cd58f1 + fb6d811 commit fbcb657

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

docs/basics/syscmds.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ keywords: command, kdb+, q, system
2626
[\p listening port](#p-listening-port) [\\_ hide q code](#_-hide-q-code)
2727
[\P precision](#p-precision) [\\ terminate](#terminate)
2828
[\r replication primary](#r-replication-primary) [\\ toggle q/k](#toggle-qk)
29-
[\r rename](#r-rename) [\\\\ quit](#quit)
29+
[\r rename](#r-rename) [\\\\ quit](#quit)
3030
</div>
3131

3232
System commands control the q environment. They have the form:
@@ -138,7 +138,7 @@ q)\B / no longer pending
138138
_Console maximum rows and columns_
139139

140140
```syntax
141-
\c
141+
\c
142142
\c size
143143
```
144144

@@ -184,7 +184,7 @@ q)til each 20+til 10
184184
_HTTP display maximum rows and columns_
185185

186186
```syntax
187-
\C
187+
\C
188188
\C size
189189
```
190190

@@ -329,16 +329,16 @@ Q manages its own thread-local heap. Objects in q use reference counting. As soo
329329

330330
1 (immediate)
331331

332-
: As memory is returned to the thread-local heap, if the object is ≥64MB then the memory is returned to the OS instead. This has an associated performance overhead. As per `defered mode`, memory used by the heap may be subsequently returned to the OS when either `.Q.gc[]` is called or an allocation fails.
332+
: As memory is returned to the thread-local heap, if the object is ≥64MB then the memory is returned to the OS instead. This has an associated performance overhead. As per `deferred mode`, memory used by the heap may be subsequently returned to the OS when either `.Q.gc[]` is called or an allocation fails.
333333

334-
When q is denied additional address space from the OS, it invokes `.Q.gc[]` and retries the request to the OS.
334+
When q is denied additional address space from the OS, it invokes `.Q.gc[]` and retries the request to the OS.
335335
If the subsequent attempt fail, the request exits with [`'wsfull`](../basics/errors.md#wsfull).
336336

337337
!!! detail "Notes on the allocator"
338338

339-
Q’s allocator bins objects in power-of-two size categories, from 16b (e.g. an atom) to 64MB.
340-
341-
In this example, various vectors of longs (8 bytes per long) are created of different sizes using [`til`](../ref/til.md).
339+
Q’s allocator bins objects in power-of-two size categories, from 16b (e.g. an atom) to 64MB.
340+
341+
In this example, various vectors of longs (8 bytes per long) are created of different sizes using [`til`](../ref/til.md).
342342
The memory used for the operation is shown via [`\ts`](#ts-time-and-space). Note that more bytes are reported
343343
that only the pure vector size due to other house keeping, for example the type information.
344344
```q
@@ -350,26 +350,26 @@ If the subsequent attempt fail, the request exits with [`'wsfull`](../basics/err
350350
0 16560
351351
```
352352

353-
If there is already a slab in the object category’s freelist, it is reused.
354-
If there are no available slabs, a larger slab is recursively split in two until the needed category size is reached.
355-
If there are no free slabs available, a new 64MB slab is requested from the system.
353+
If there is already a slab in the object category’s freelist, it is reused.
354+
If there are no available slabs, a larger slab is recursively split in two until the needed category size is reached.
355+
If there are no free slabs available, a new 64MB slab is requested from the system.
356356
When an object is de-allocated, its memory slab is returned to the corresponding category’s freelist.
357-
357+
358358
Allocations larger than 64MB are requested from the OS directly, and this is what `-g 1` causes to be immediately returned.
359-
359+
360360
Note that larger allocations do not cause any fragmentation and in case of `-g 1` always immediately return.
361-
361+
362362
It is the smaller allocations (<64MB) that typically represent the bulk of a process allocation workload that can cause the heap to become fragmented.
363-
363+
364364
There are two primary cases of heap fragmentation:
365-
365+
366366
split slab
367-
367+
368368
: Suppose that at some point q needed a 32MB allocation. It requested a new 64MB slab from the OS, split it in half, used and freed the object, and returned the two 32MB slabs to the freelist. Now if q needs to allocate 64MB, it will have to make another request to the OS. When `.Q.gc` is called (or an allocation fails), it would attempt to coalesce these two 32MB slabs together back into one 64MB, which would allow it to be returned to the OS (or reused for larger allocations, if the resulting slab is <64MB).
369-
369+
370370
leftover objects
371371

372-
: If most of the objects allocated from a 64MB slab are freed but one remains, the slab still cannot be returned to the OS (or coalesced).
372+
: If most of the objects allocated from a 64MB slab are freed but one remains, the slab still cannot be returned to the OS (or coalesced).
373373

374374
The following example shows freeing an object ≥64MB in `deferred` mode, while inspecting memory usage via [`.Q.w[]`](../ref/dotq.md#w-memory-stats):
375375
```q
@@ -399,10 +399,10 @@ q)a:til 10000000 / need memory ≥64MB to store value again
399399
q).Q.w[]`used`heap / heap memory has increased (requested from OS) as memory used is more than whats available to use in heap
400400
134589328 201326592
401401
```
402-
`Immediate mode` will not return the memory to the OS when several objects less than 64MB each are freed, even though their sum may be more than 64MB.
402+
`Immediate mode` will not return the memory to the OS when several objects less than 64MB each are freed, even though their sum may be more than 64MB.
403403
In this situation, `immediate` and `deferred` mode operate identically by adding the freed memory to the heap for future use.
404404

405-
The following examples shows this effect when running in `immediate mode`.
405+
The following examples shows this effect when running in `immediate mode`.
406406
No memory is returned to the OS on freeing the objects, and only when [`.Q.gc[]`](../ref/dotq.md#gc-garbage-collect) is run is the memory coalesced and freed.
407407
```q
408408
q).Q.w[]`used`heap / original memory used and memory reserved by kdb+ at time of test
@@ -433,17 +433,17 @@ _Q for Mortals_
433433
\l .
434434
```
435435

436-
Where `name` is the name of a
436+
Where `name` is the name of a
437437

438438
- q script, executes the script
439439
- serialized object, deserializes it into memory as variable `name`
440440
- directory of a splayed table, maps the table to variable `name`, without loading any columns into memory
441441
- directory and the value of one of the permitted partition types, the most recent partition directory is inspected for splayed directories and each such directory mapped into memory with the name of the splayed directory
442442
- directory containing a kdb+ database, recursively loads whatever it finds there: serialized objects, scripts, splayed tables, etc.
443443

444-
**Current directory** When a directory is opened, it becomes the current directory.
444+
**Current directory** When a directory is opened, it becomes the current directory.
445445

446-
**Reload current directory** You can reload the current database with `\l .`. This will ignore scripts and reload only data.
446+
**Reload current directory** You can reload the current database with `\l .`. This will ignore scripts and reload only data.
447447

448448
**Never mind the dollars** If a file or directory under the path being loaded has a dollar-sign suffix then it is ignored. e.g. `db/tickdata/myfile$` and `db/tickdata/mydir$` would be ignored on `\l db/tickdata` or on `\l .` if `db/tickdata` is the current directory.
449449

@@ -459,7 +459,6 @@ q)\a / with tables quote and trade
459459

460460
If [logging](../kb/logging.md) is enabled, the command [checkpoints](../kb/logging.md#check-pointing-rolling) the `.qdb` file and empties the log file.
461461

462-
463462
!!! danger "Operating systems may create hidden files, such as `DS_Store`, that block `\l` on a directory."
464463

465464
:fontawesome-solid-book:
@@ -514,7 +513,7 @@ _Show or set listening port_
514513
\p [rp,][hostname:][portnumber|servicename]
515514
```
516515

517-
See
516+
See
518517
:fontawesome-solid-book-open:
519518
[Listening port](listening-port.md) for detail.
520519

@@ -543,7 +542,8 @@ Show or set display precision for floating-point numbers, i.e. the number of dig
543542

544543
The default value of `n` is 7 and possible values are integers in the range \[0,17\].
545544
A value of 0 means use maximum precision.
546-
This is used when exporting to CSV files.
545+
`\P` is applied when [save](../ref/save.md) exports to text files (CSV, json, etc.) and whenever a floating-point number is converted to a string.
546+
547547

548548
```q
549549
q)\P / default
@@ -607,7 +607,7 @@ This should not be executed manually otherwise it can disrupt replication. It is
607607
\r src dst
608608
```
609609

610-
Rename file `src` to `dst`.
610+
Rename file `src` to `dst`.
611611

612612
It is equivalent to the Unix `mv` command, or the windows `move` command (except that it will not rename to a different disk drive).
613613

@@ -699,7 +699,7 @@ q)x:system"S 0N";r:10?10;system"S ",string x;r~10?10
699699
The rng in a secondary thread is assigned a seed based on the secondary thread number.
700700

701701
In multithreaded input mode, the seed is based on the socket descriptor.
702-
702+
703703
Instances started on ports 20000 through 20099 (secondary threads, used with e.g. `q -s -4` have the main thread’s default seed based on the port number.
704704

705705

@@ -819,7 +819,7 @@ q){x where x like"????"}system"v .h"
819819
delete a from `.
820820
```
821821

822-
:fontawesome-solid-street-view:
822+
:fontawesome-solid-street-view:
823823
_Q for Mortals_
824824
[§12.5 Expunging from a Context](/q4m3/12_Workspace_Organization/#125-expunging-from-a-context)
825825

@@ -868,7 +868,7 @@ Since 2017.11.06, `\w` allows the workspace limit to be increased at run-time, i
868868
[`-w` command-line option](cmdline.md#-w-workspace). For example `\w 128` sets the limit to 128MB if the `-w` command line option was specified
869869
with a smaller value. The operation will return the current setting in bytes.
870870

871-
If the system tries to allocate more memory than allowed, it signals `-w abort` and terminates with exit code 1.
871+
If the system tries to allocate more memory than allowed, it signals `-w abort` and terminates with exit code 1.
872872

873873
Specifying too large a number will fall back to the same behavior as `\w 0` or `\w 1`.
874874

@@ -1125,11 +1125,11 @@ q)
11251125

11261126
## Interrupt and terminate
11271127

1128-
Ctl-c signals an interrupt to the interpreter.
1128+
Ctl-c signals an interrupt to the interpreter.
11291129

1130-
Some operations are coded so tightly the interrupt might not be registered.
1130+
Some operations are coded so tightly the interrupt might not be registered.
11311131

1132-
Ctl-z will kill the q session. Nothing in memory is saved.
1132+
Ctl-z will kill the q session. Nothing in memory is saved.
11331133

11341134

11351135
## OS commands

0 commit comments

Comments
 (0)