Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
875e34f
di.eodtime: read the clock once in getdailyadjustment
alowrydi Oct 19, 2026
cc5aac6
di.pubsub: read the filters column TorQ sends in filtered subscriptions
alowrydi Oct 19, 2026
1187c80
di.merge: restore TorQ merge.q failure and attribute behaviour
alowrydi Oct 19, 2026
0d460cb
di.timer: log failed jobs through the injected logger; jobs reschedul…
alowrydi Oct 19, 2026
16d7232
di.timer: store params as a list, disable at maxtime and rescan as To…
alowrydi Oct 20, 2026
0f7d914
di.timer: add addjob.once and removefunc, as TorQ's .timer.once and .…
alowrydi Oct 20, 2026
0cc02d3
di.torq.servers: add startupdepcycles and startupdependent, as TorQ's…
alowrydi Oct 20, 2026
ae3d204
Merge branch 'main' into feature-framework-polishing
alowrydi Oct 20, 2026
4a23758
di.torq.config: run its test fixtures under a per-run directory
alowrydi Oct 20, 2026
d3ee4b4
di.timer: timespan periods, mode and dupcheck checks, legacy first-ru…
alowrydi Oct 20, 2026
6298ab5
di.torq: stamp q's -t interval into config as timerms
alowrydi Oct 20, 2026
20b45a7
di.torq.proc.segmentedtp: batch every -t ms, as TorQ's .z.ts
alowrydi Oct 20, 2026
bd5442f
di.torq.proc.chainedtp: accept a sub-second pubinterval, as TorQ's ch…
alowrydi Oct 20, 2026
51745be
di.torq.proc.tickerplant: -t decides batched or immediate, as TorQ's …
alowrydi Oct 20, 2026
c7d7413
di.dbwrite: savedown hooks and TorQ's default sort, as dbwriteutils.q
alowrydi Oct 20, 2026
6e7cf94
di.torq.proc.wdb: save down hooks through di.dbwrite; postreplay unpr…
alowrydi Oct 20, 2026
6f2bbbf
di.torq.proc.tickerlogreplay: save down hooks through di.dbwrite, rea…
alowrydi Oct 20, 2026
aac042a
di.torq.proc.rdb: save down hooks through di.dbwrite; keep g# after t…
alowrydi Oct 20, 2026
59abed1
di.compression: worker processes compress a table each, as TorQ #732;…
alowrydi Oct 20, 2026
99a4b72
di.torq.proc.housekeeping: TorQ's job csv format and action names; rm…
alowrydi Oct 20, 2026
3a12e2f
di.torq.servers: addh, refreshattributes, gethpbytype, root gethandle…
alowrydi Oct 20, 2026
3370059
di.eodtime: readers for the roll and data timezone and roll offset, a…
alowrydi Oct 20, 2026
f97837a
di.torq.config: getconfig and getconfigfile over the two roots, as To…
alowrydi Oct 20, 2026
84bad6e
di.torq, di.torq.config: -parentproctype tier for settings and app co…
alowrydi Oct 20, 2026
4941b05
di.torq.proc.gateway: getdata behind the eod reload gate; log line sa…
alowrydi Oct 20, 2026
5e8b444
di.torq.proc.gateway: single-type queries run during the eod reload, …
alowrydi Oct 20, 2026
4c507a2
di.torq.servers: test fixture on OS-assigned ports with a listener check
alowrydi Oct 20, 2026
6cdfcd1
di.torq.proc.tickerplant: upd rolls the day first when past the roll,…
alowrydi Oct 22, 2026
389f56b
di.torq.proc.tickerlogreplay: upd and save down hooks from config, as…
alowrydi Oct 22, 2026
4f150ed
di.torq.proc.wdb: doc, sortcsv fallback is di.dbwrite's sym-then-time…
alowrydi Oct 22, 2026
f628a50
di.dbwrite: doc, built-in default sort is p# on sym, sorted by sym th…
alowrydi Oct 22, 2026
2143e10
di.torq.proc.tickerplant: rolltimezone/datatimezone/rolltimeoffset re…
alowrydi Oct 23, 2026
ee3ea38
di.torq.proc.gateway: synccallsallowed reaches di.asyncdispatch as a …
alowrydi Oct 23, 2026
430fc1f
di.torq.proc.gateway: fixture rows no longer depend on the time of day
alowrydi Oct 27, 2026
7b04806
di.subscriptions: checksubscriptionperiod accepts TOML values
alowrydi Oct 27, 2026
36414a9
di.torq.proc.tickerplant: rolltimeoffset accepts TOML values
alowrydi Oct 27, 2026
0639b21
di.torq.proc.segmentedtp: [eodtime] section accepts TOML values
alowrydi Oct 27, 2026
98dc9b0
Merge branch 'main' into feature-framework-polishing
alowrydi Oct 28, 2026
885698f
di.torq: find the framework checkout through QPATH when TORQXHOME is …
alowrydi Oct 28, 2026
276cb89
di.torq: frameworkhome searches where use does, skipping empty QPATH …
alowrydi Oct 28, 2026
785d95f
di.torq: frameworkhome skips the $QHOME/mod fallback when QHOME is un…
alowrydi Oct 28, 2026
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
16 changes: 8 additions & 8 deletions di/asyncdispatch/asyncdispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,28 @@ ad.execqueryto[0Ni;shardquery;servertypes;raze;(`da.shardresult;reqid);0Wn;0b]
Scan the queue for queries past their timeout, send a timeout error to each client, and mark them complete. Wire into your gateway's timer — every few seconds is typical.
```q
// in gateway timer
timer.addjob.default[`asyncdispatch.checktimeout;{ad.checktimeout[]};();5i;1]
timer.addjob.default[`asyncdispatch.checktimeout;{ad.checktimeout[]};();0D00:00:05;1]
```

### `removequeries[age]`
Purge completed `queryqueue` rows older than `age`. Prevents unbounded growth.
```q
// default age is querykeeptime (0D00:30)
timer.addjob.default[`asyncdispatch.removequeries;{ad.removequeries[0D00:30]};();300i;1]
timer.addjob.default[`asyncdispatch.removequeries;{ad.removequeries[0D00:30]};();0D00:05;1]
```

### `removeinactive[age]`
Purge `servers` rows for backends that have been disconnected longer than `age`. Prevents unbounded growth.
```q
// default age is clearinactivetime (0D01:00)
timer.addjob.default[`asyncdispatch.removeinactive;{ad.removeinactive[0D01:00]};();300i;1]
timer.addjob.default[`asyncdispatch.removeinactive;{ad.removeinactive[0D01:00]};();0D00:05;1]
```

### `removeclients[age]`
Purge `clients` rows older than `age`. The `clients` table is appended to on every client connect (`addclientdetails`) for audit and is not otherwise pruned, so wire this into the timer to prevent unbounded growth. Choose `age` to match your audit retention requirements.
```q
// retain one day of client audit history
timer.addjob.default[`asyncdispatch.removeclients;{ad.removeclients[1D]};();300i;1]
timer.addjob.default[`asyncdispatch.removeclients;{ad.removeclients[1D]};();0D00:05;1]
```

### `setformatresponse[f]`
Expand Down Expand Up @@ -210,10 +210,10 @@ ad.addserver[hopen`:backend2:5002;`hdb]
.z.pc:{ad.removeserverhandle[.z.w];ad.removeclienthandle[.z.w]}

// wire housekeeping into the gateway timer
timer.addjob.default[`asyncdispatch.checktimeout;{ad.checktimeout[]};();5i;1]
timer.addjob.default[`asyncdispatch.removequeries;{ad.removequeries[0D00:30]};();300i;1]
timer.addjob.default[`asyncdispatch.removeinactive;{ad.removeinactive[0D01:00]};();300i;1]
timer.addjob.default[`asyncdispatch.removeclients;{ad.removeclients[1D]};();300i;1]
timer.addjob.default[`asyncdispatch.checktimeout;{ad.checktimeout[]};();0D00:00:05;1]
timer.addjob.default[`asyncdispatch.removequeries;{ad.removequeries[0D00:30]};();0D00:05;1]
timer.addjob.default[`asyncdispatch.removeinactive;{ad.removeinactive[0D01:00]};();0D00:05;1]
timer.addjob.default[`asyncdispatch.removeclients;{ad.removeclients[1D]};();0D00:05;1]

// a client calls this asynchronously:
// execquery dispatches to rdb and hdb in parallel, razes results, replies to client
Expand Down
2 changes: 2 additions & 0 deletions di/compression/compression.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Flexibility to compress different tables/columns with different compression parameters
- Preview available before compression to display files to be compressed and how
- Summary statistics for each file returned after compression/decompression complete
- With worker threads (`-s` above 0) files compress in parallel; with worker processes (`-s` below 0) each worker compresses and verifies one table, as TorQ

---

Expand Down Expand Up @@ -69,6 +70,7 @@ depth, 10,default, 1, 17, 8
|`compressmaxage` | Compress files according to config up to the specified max age |
|`docompression` | Compress all files in hdb according to compressioncsv config |
|`getstatstab` | get function to retrieve summary stats post compression |
|`compress` | `[file;algo;blocksize;level;size]` compress (algo 0: decompress) one file to `file_kdbtempzip`, leaving the original in place |

---

Expand Down
4 changes: 2 additions & 2 deletions di/compression/compression.q
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ showcomp:{[hdbpath;csvpath;maxage]

compressfromtable:{[table]
statstab::([] file:`$(); algo:`int$(); compressedLength:`long$();uncompressedLength:`long$());
/ Check if process is single threaded - if multi then compress in parallel then clean up after
/ Check if process is single threaded - if multi then compress in parallel then clean up after; worker processes (s<0) take a table each, as TorQ #732
/ Add metrics on any files due to be compressed to be used afterwards for comparison
table:update compressionvaluepre:{(-21!x)`compressedLength}'[fullpath] from table;
$[0= system"s";
singlethreadcompress[table];
multithreadcompress[table]];
$[0<system "s";multithreadcompress[table];{[x;y] compressfromtable select from x where table=y}[table;] peach distinct table`table]];
/ Update the stats tab table after the compression
{statstabupdate[x`fullpath;x`calgo;x`currentsize;x`compressionvaluepre]} each table
};
Expand Down
2 changes: 1 addition & 1 deletion di/compression/init.q
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\l ::compression.q

export:([init;showcomp;getcompressioncsv;compressmaxage;docompression;getstatstab])
export:([init;showcomp;getcompressioncsv;compressmaxage;docompression;getstatstab;compress])
13 changes: 13 additions & 0 deletions di/compression/test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,17 @@ true,0,0,q,30~count z:cmp.getstatstab[],1,,Checking rest of files have been deco
true,0,0,q,0i~sum 0<(select from cmp.getstatstab[] where algo=0)`compressionratio,1,,Negative compression ratio for decompression
true,0,0,q,0i~sum exec distinct algo from cmp.getstatstab[],1,,Only algo 0 (decompression) required here

comment,,,,,,,worker processes (s below 0): each worker compresses and cleans one table, as TorQ #732
run,0,0,q,"system ""l di/compression/test.q""",1,,load fixture helpers
run,0,0,q,startworkers[],1,,start two worker processes with di.compression loaded
run,0,0,q,WR:workerrun[],1,,compress a two-table hdb with s -2 over the workers
true,0,0,q,`ok~WR`result,1,,compression over worker processes completes
true,0,0,q,0=WR`mainclean,1,,no cleancompressed runs on the main process: each worker cleans its own table (old code: 6 on main)
true,0,0,q,all 2i=WR`algos,1,,every file ends gzip compressed
true,0,0,q,6=WR`stats,1,,statstab has a row per file
run,0,0,q,stopworkers[],1,,stop the workers

comment,,,,,,,single-file compress (as legacy housekeeping's kdbzip calls it)
true,0,0,q,all value onefile[],1,,"compress[f;2;17;4;hcount f] writes f_kdbtempzip gzip 17 4 with the same contents, leaving f uncompressed"

after,0,0,q,system"rm cmpMockBadConfig.csv;rm cmpMockParams.csv;rm decompMockParams.csv;rm -r cmpTestHDB",1,,Clearing up on-disk mock data
61 changes: 61 additions & 0 deletions di/compression/test.q
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/ fixture helpers for di.compression's worker-process and single-file tests. Assumes cwd is the kdbx-modules repo root.
/ two real worker q processes on ephemeral ports serve peach with \s -2; each writes its port to a file.

WDIR:"cmpWorkers_",string .z.i;
WPORTS:();
WH:();

/ a one-partition hdb with two tables of three columns, and a csv that gzips everything
mkworkerhdb:{[]
d:hsym`$WDIR,"/hdb";
{[d;t] (` sv .Q.par[d;2026.01.01;t],`) set .Q.en[d;([]time:2026.01.01D0+til 1000;sym:1000?`a`b`c;price:1000?100f)]}[d] each `trade`quote;
(hsym`$WDIR,"/params.csv") 0: ("table,minage,column,calgo,cblocksize,clevel";"default,0,default,2,17,6");
};

/ the port files the workers have written
portfiles:{[] ` sv/: (hsym`$WDIR),/:k where (k:key hsym`$WDIR) like "port_*"};

/ start two workers with di.compression loaded and wait for their ports
startworkers:{[]
system "mkdir -p ",WDIR;
(hsym`$WDIR,"/worker.q") 0: (
"cmp:use`di.compression;";
"cmp.init enlist[`log]!enlist `info`warn`error!3#enlist {[c;m]};";
"(hsym`$\"",WDIR,"/port_\",string .z.i) 0: enlist string system\"p\";");
{[x] system "sleep 120 | ",(first .z.X)," ",WDIR,"/worker.q -p 0W -q >/dev/null 2>&1 &"} each 1 2;
/ wait up to 10s for both port files
{[x] system "sleep 0.1"; x+1}/[{(x<100) and 2>count portfiles[]};0];
`WPORTS set "J"$first each read0 each portfiles[];
`WH set hopen each WPORTS;
};

/ compress the hdb with \s -2 over the workers, counting cleancompressed calls on this process
CLEANS:0;
workerrun:{[]
Comment thread
alowrydi marked this conversation as resolved.
Resolved
mkworkerhdb[];
orig:.m.di.0compression.cleancompressed;
.m.di.0compression.cleancompressed:{[o;f;a] @[`.;`CLEANS;+;1]; o[f;a]}[orig];
.z.pd:{`u#WH};
system "s -2";
r:@[{cmp.docompression[hsym`$WDIR,"/hdb";hsym`$WDIR,"/params.csv"];`ok};::;{x}];
system "s 0";
.m.di.0compression.cleancompressed:orig;
f:raze {p:.Q.par[hsym`$WDIR,"/hdb";2026.01.01;x]; ` sv/: p,/:key[p] except `.d} each `trade`quote;
`result`mainclean`algos`stats!(r;CLEANS;{(-21!x)`algorithm} each f;count cmp.getstatstab[])
};

stopworkers:{[]
{neg[x] "exit 0"; neg[x][]} each WH;
system "rm -rf ",WDIR;
};

/ the single-file compress legacy housekeeping's kdbzip calls: .cmp.compress[f;2;17;4;hcount f] (housekeeping.q:64)
onefile:{[]
f:hsym`$WDIR,"_one";
f set v:100000?100f;
cmp.compress[f;2;17;4;hcount f];
t:hsym`$(string f),"_kdbtempzip";
r:`original`temp`same!(0=count -21!f;2 17 4i~(-21!t)`algorithm`logicalBlockSize`zipLevel;v~get t);
hdel each (f;t);
r
};
2 changes: 1 addition & 1 deletion di/dataaccess/dataaccess.q
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,5 @@ init:{[deps]
set[`.dataaccess.shardresult;shardresult];
set[`.dataaccess.sharderror;sharderror];
.z.m.log[`info][`init;"di.dataaccess initialised"];
(.z.m.timer`addjob)[`dataaccesspurge;removerequests;enlist .z.m.requestkeeptime;1800;1h;()!()];
(.z.m.timer`addjob)[`dataaccesspurge;removerequests;enlist .z.m.requestkeeptime;0D00:30;1h;()!()];
};
10 changes: 7 additions & 3 deletions di/dbwrite/dbwrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Write, sort, and attribute utilities for kdb+ processes that persist data to disk (rdb, wdb, tickerlogreplay).

A **config table** (`tabname`,`att`,`column`,`sort`) drives which columns are sorted and which attributes are applied per table. Load it once with `readcsv` (from a CSV) or `setconfig` (from an in-memory table); `sort` and `savedown` read from module state automatically. A table with no explicit entry falls back to a `default` row; if no config has been loaded, the built-in default (sort every table by `time` ascending) applies.
A **config table** (`tabname`,`att`,`column`,`sort`) drives which columns are sorted and which attributes are applied per table. Load it once with `readcsv` (from a CSV) or `setconfig` (from an in-memory table); `sort` and `savedown` read from module state automatically. A table with no explicit entry falls back to a `default` row; if no config has been loaded, the built-in default (`p#` on `sym`, sorted by `sym` then `time`) applies.

---

Expand Down Expand Up @@ -68,6 +68,8 @@ default,,time,1
| `sort[tabname;dirs]` | Sort on-disk partition(s) for a table and apply attributes per stored config |
| `savedown[dir;part;tabname;data]` | Write an in-memory table to an HDB partition, sort it, then run gc |
| `appenddown[dir;part;tabname;data]` | Append rows to an existing partition (no sort) |
| `manipulate[t;x]` | Apply the table's `savedownmanipulation` function, as TorQ's `.save.manipulate`; keeps `x` if it fails |
| `postreplay[d;p]` | Call the `postreplay` hook after a partition is written, as TorQ's `.save.postreplay` |
| `applyattr[dloc;colname;att]` | Apply a single kdb+ attribute to an on-disk column |
| `gc[]` | Run `.Q.gc[]` and log memory stats before and after |

Expand All @@ -77,6 +79,8 @@ default,,time,1

Wire injected dependencies. Must be called before any other function. Also resets the stored sort config to `(::)`.

Optional keys, as TorQ's `.save` hooks: `savedownmanipulation` (dict of table!function, applied to the data before `savedown`/`appenddown` enumerate it) and `postreplay` (`{[d;p]}`, called by writers through `postreplay` once a partition is written). Each is set only when its key is passed, so a later `init` without it keeps the hook; the defaults are `()!()` and `{[d;p]}`.

| Arg | Type | Description |
|---|---|---|
| `deps` | dict | Must contain `` `log `` → `` `info`warn`error!(infofn;warnfn;errfn) `` |
Expand Down Expand Up @@ -128,7 +132,7 @@ dbwrite.getconfig[]

### `sort[tabname;dirs]`

Sort and apply attributes to the on-disk partition(s) for one table, using the config stored by `readcsv` or `setconfig`. Falls back to the built-in default (sort by `time` ascending) if no config has been loaded.
Sort and apply attributes to the on-disk partition(s) for one table, using the config stored by `readcsv` or `setconfig`. Falls back to the built-in default, TorQ's `config/sort.csv` (`p#` on `sym`, sorted by `sym` then `time`), if no config has been loaded. A table without `sym` logs the sort and attribute errors and is written unsorted, as in TorQ.

| Parameter | Type | Description |
|---|---|---|
Expand Down Expand Up @@ -208,5 +212,5 @@ The suite injects binary mock loggers (`{[c;m] ...}`): a no-op logger, and a cap
## Exported symbols

```q
export:([init;readcsv;setconfig;getconfig;sort;applyattr;savedown;appenddown;gc])
export:([init;readcsv;setconfig;getconfig;sort;applyattr;savedown;appenddown;manipulate;postreplay;gc;version])
```
24 changes: 20 additions & 4 deletions di/dbwrite/dbwrite.q
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
/ attributes that may legitimately appear in a config (empty leaves a column unattributed)
validatts:``p`s`g`u;

/ built-in fallback config - sort every table by time ascending when no config is supplied
defaultparams:([] tabname:enlist`default; att:enlist`; column:enlist`time; sort:enlist 1b);
/ built-in fallback config, TorQ's config/sort.csv: p# on sym, sorted by sym then time
defaultparams:([] tabname:`default`default; att:`p`; column:`sym`time; sort:11b);

/ save down hooks, as TorQ's .save.savedownmanipulation and .save.postreplay; init sets them only when passed
savedownmanipulation:()!();
posthook:{[d;p]};

init:{[deps]
/ wire the injected logger - required, no silent fallback. deps: a dict with a `log key
Expand All @@ -24,8 +28,20 @@ init:{[deps]
.z.m.logwarn:deps[`log]`warn;
.z.m.logerr:deps[`log]`error;
.z.m.sortconfig:(::);
if[`savedownmanipulation in key deps;.z.m.savedownmanipulation:deps`savedownmanipulation];
if[`postreplay in key deps;.z.m.posthook:deps`postreplay];
};

/ apply the table's savedownmanipulation, if any, keeping the data on failure, as TorQ's .save.manipulate
manipulate:{[t;x]
$[t in key .z.m.savedownmanipulation;
@[.z.m.savedownmanipulation t;x;{[x;e] .z.m.logerr[`manipulate;"save down manipulation failed : ",e];x}[x]];
x]
};

/ call the postreplay hook after a partition is written, as TorQ's .save.postreplay
postreplay:{[d;p] .z.m.posthook[d;p]};

readcsv:{[file]
/ read a sort-config csv and store it in .z.m.sortconfig; used by sort and savedown
/ the csv must have the columns tabname,att,column,sort (in any order)
Expand Down Expand Up @@ -196,7 +212,7 @@ savedown:{[dir;part;tabname;data]
/ enumerates syms against the hdb sym file; sorting and attributes are driven by .z.m.sortconfig
.z.m.loginfo[`savedown;"saving ",string[tabname]," partition ",string[part]," to ",string dir];
path:` sv (.Q.par[dir;part;tabname];`);
path set .Q.en[dir;data];
path set .Q.en[dir;manipulate[tabname;data]];
sort[tabname;path];
.z.m.loginfo[`savedown;"finished saving ",string tabname];
gc[];
Expand All @@ -212,7 +228,7 @@ appenddown:{[dir;part;tabname;data]
.z.m.logerr[`appenddown;err:"di.dbwrite: appenddown partition does not exist at ",string path];
'err;
];
.[path;();,;.Q.en[dir;data]];
.[path;();,;.Q.en[dir;manipulate[tabname;data]]];
.z.m.loginfo[`appenddown;"finished appending ",string tabname];
};

Expand Down
2 changes: 1 addition & 1 deletion di/dbwrite/init.q
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
/ BOTH the file (pre-load manifest walk) and this export (post-load session audit).
version:first read0`:::VERSION

export:([init;readcsv;setconfig;getconfig;sort;applyattr;savedown;appenddown;gc;version])
export:([init;readcsv;setconfig;getconfig;sort;applyattr;savedown;appenddown;manipulate;postreplay;gc;version])
Loading