You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System commands control the q environment. They have the form:
@@ -138,7 +138,7 @@ q)\B / no longer pending
138
138
_Console maximum rows and columns_
139
139
140
140
```syntax
141
-
\c
141
+
\c
142
142
\c size
143
143
```
144
144
@@ -184,7 +184,7 @@ q)til each 20+til 10
184
184
_HTTP display maximum rows and columns_
185
185
186
186
```syntax
187
-
\C
187
+
\C
188
188
\C size
189
189
```
190
190
@@ -329,16 +329,16 @@ Q manages its own thread-local heap. Objects in q use reference counting. As soo
329
329
330
330
1 (immediate)
331
331
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.
333
333
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.
335
335
If the subsequent attempt fail, the request exits with [`'wsfull`](../basics/errors.md#wsfull).
336
336
337
337
!!! detail "Notes on the allocator"
338
338
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).
342
342
The memory used for the operation is shown via [`\ts`](#ts-time-and-space). Note that more bytes are reported
343
343
that only the pure vector size due to other house keeping, for example the type information.
344
344
```q
@@ -350,26 +350,26 @@ If the subsequent attempt fail, the request exits with [`'wsfull`](../basics/err
350
350
0 16560
351
351
```
352
352
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.
356
356
When an object is de-allocated, its memory slab is returned to the corresponding category’s freelist.
357
-
357
+
358
358
Allocations larger than 64MB are requested from the OS directly, and this is what `-g 1` causes to be immediately returned.
359
-
359
+
360
360
Note that larger allocations do not cause any fragmentation and in case of `-g 1` always immediately return.
361
-
361
+
362
362
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
+
364
364
There are two primary cases of heap fragmentation:
365
-
365
+
366
366
split slab
367
-
367
+
368
368
: 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
+
370
370
leftover objects
371
371
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).
373
373
374
374
The following example shows freeing an object ≥64MB in `deferred` mode, while inspecting memory usage via [`.Q.w[]`](../ref/dotq.md#w-memory-stats):
375
375
```q
@@ -399,10 +399,10 @@ q)a:til 10000000 / need memory ≥64MB to store value again
399
399
q).Q.w[]`used`heap / heap memory has increased (requested from OS) as memory used is more than whats available to use in heap
400
400
134589328 201326592
401
401
```
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.
403
403
In this situation, `immediate` and `deferred` mode operate identically by adding the freed memory to the heap for future use.
404
404
405
-
The following examples shows this effect when running in `immediate mode`.
405
+
The following examples shows this effect when running in `immediate mode`.
406
406
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.
407
407
```q
408
408
q).Q.w[]`used`heap / original memory used and memory reserved by kdb+ at time of test
@@ -433,17 +433,17 @@ _Q for Mortals_
433
433
\l .
434
434
```
435
435
436
-
Where `name` is the name of a
436
+
Where `name` is the name of a
437
437
438
438
- q script, executes the script
439
439
- serialized object, deserializes it into memory as variable `name`
440
440
- directory of a splayed table, maps the table to variable `name`, without loading any columns into memory
441
441
- 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
442
442
- directory containing a kdb+ database, recursively loads whatever it finds there: serialized objects, scripts, splayed tables, etc.
443
443
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.
445
445
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.
447
447
448
448
**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.
449
449
@@ -459,7 +459,6 @@ q)\a / with tables quote and trade
459
459
460
460
If [logging](../kb/logging.md) is enabled, the command [checkpoints](../kb/logging.md#check-pointing-rolling) the `.qdb` file and empties the log file.
461
461
462
-
463
462
!!! danger "Operating systems may create hidden files, such as `DS_Store`, that block `\l` on a directory."
464
463
465
464
:fontawesome-solid-book:
@@ -514,7 +513,7 @@ _Show or set listening port_
514
513
\p [rp,][hostname:][portnumber|servicename]
515
514
```
516
515
517
-
See
516
+
See
518
517
:fontawesome-solid-book-open:
519
518
[Listening port](listening-port.md) for detail.
520
519
@@ -543,7 +542,8 @@ Show or set display precision for floating-point numbers, i.e. the number of dig
543
542
544
543
The default value of `n` is 7 and possible values are integers in the range \[0,17\].
545
544
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
+
547
547
548
548
```q
549
549
q)\P / default
@@ -607,7 +607,7 @@ This should not be executed manually otherwise it can disrupt replication. It is
607
607
\r src dst
608
608
```
609
609
610
-
Rename file `src` to `dst`.
610
+
Rename file `src` to `dst`.
611
611
612
612
It is equivalent to the Unix `mv` command, or the windows `move` command (except that it will not rename to a different disk drive).
The rng in a secondary thread is assigned a seed based on the secondary thread number.
700
700
701
701
In multithreaded input mode, the seed is based on the socket descriptor.
702
-
702
+
703
703
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.
704
704
705
705
@@ -819,7 +819,7 @@ q){x where x like"????"}system"v .h"
819
819
delete a from `.
820
820
```
821
821
822
-
:fontawesome-solid-street-view:
822
+
:fontawesome-solid-street-view:
823
823
_Q for Mortals_
824
824
[§12.5 Expunging from a Context](/q4m3/12_Workspace_Organization/#125-expunging-from-a-context)
825
825
@@ -868,7 +868,7 @@ Since 2017.11.06, `\w` allows the workspace limit to be increased at run-time, i
868
868
[`-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
869
869
with a smaller value. The operation will return the current setting in bytes.
870
870
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.
872
872
873
873
Specifying too large a number will fall back to the same behavior as `\w 0` or `\w 1`.
874
874
@@ -1125,11 +1125,11 @@ q)
1125
1125
1126
1126
## Interrupt and terminate
1127
1127
1128
-
Ctl-c signals an interrupt to the interpreter.
1128
+
Ctl-c signals an interrupt to the interpreter.
1129
1129
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.
1131
1131
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.
0 commit comments