Skip to content

Replace stats with SMF Type 243 + counters#55

Merged
mgrossmann merged 6 commits intomainfrom
issue-54-simplify-stats-smf
Apr 11, 2026
Merged

Replace stats with SMF Type 243 + counters#55
mgrossmann merged 6 commits intomainfrom
issue-54-simplify-stats-smf

Conversation

@mgrossmann
Copy link
Copy Markdown
Contributor

@mgrossmann mgrossmann commented Apr 11, 2026

Summary

  • Delete httpstat.c (509 LOC) — removes 4-tier time-series arrays (~16 KB RAM), dataset load/save, lock-protected stat updates
  • Rewrite httprepo.c with SMF Type 243 recording via crent370's smf_init()/smf_write() API
  • Configurable SMF level via parmlib: SMF=NONE|ERROR|AUTH|ALL [TYPE=nnn] (default: NONE)
  • Two SMF subtypes: request record (sub=1) and session record (sub=2, only at level ALL)
  • Replace stat arrays with 4 simple counters: total_requests, total_errors, total_bytes_sent, active_connections
  • Per-connection session tracking: connect_time, total_bytes_sent, request_count in HTTPC struct
  • Console: D S shows SMF level/type + counters, S STATS NONE|ERROR|AUTH|ALL [RESET]
  • Net: -880 LOC, ~16 KB RAM freed per server instance

Changes by file

File Change
src/httpstat.c Deleted (509 LOC)
src/httprepo.c SMF request/session records + level check (~150 LOC)
include/httpd.h SMF structs, smf_level/smf_type, HTTPC session fields
include/httpcgi.h HTTPC layout sync (CBUFSIZE 4008→4000)
src/httpd.c connect_time init, startup/shutdown messages
src/httpclos.c active_connections--, session record on close
src/httpcons.c D S + S STATS with SMF levels
src/httpprm.c SMF keyword parsing, defaults
src/httpdsrv.c Counter display replacing stat arrays
samplib/httpprm0 SMF keyword docs, removed old stats keywords
CLAUDE.md Updated open questions + file descriptions
doc/architecture.md Updated diagrams + descriptions

Verified on MVS

  • make build + make link — 112 modules RC=0, 10 load modules linked
  • SMF Type 243 request records (sub=1) in SYS1.MANX — all fields correct
  • SMF session records (sub=2) — connect_time, request_count, total_bytes, duration
  • /F HTTPD,D S shows SMF level and counters
  • /F HTTPD,S STATS ALL / NONE / RESET works
  • Existing functionality (curl, mvsMF) unaffected

Fixes #54

Delete httpstat.c (509 LOC) and rewrite httprepo.c to write SMF Type 243
records per HTTP request via crent370's smf_init()/smf_write() API.
Replace ~16 KB of in-memory time-series arrays with four simple counters
(total_requests, total_errors, total_bytes_sent, active_connections).

- Remove HTTPSTAT struct, 4 stat arrays, dataset load/save
- Remove FILE *stats log file handle
- Remove 6 parmlib keywords (CLIENT_STATS_*_MAX, CLIENT_STATS_DATASET)
- Simplify /F HTTPD,D S to show counter values via WTO
- Simplify /F HTTPD,S STATS to ON|OFF [RESET]
- Track active_connections in httpd.c (accept) and httpclos.c (close)
- Counters always increment; SMF recording controlled by CLIENT_STATS

Fixes #54
@mgrossmann mgrossmann force-pushed the issue-54-simplify-stats-smf branch from 1dd4174 to 7111149 Compare April 11, 2026 08:26
Rename ssi[4] to subsys[8] in smf_httpd_request to allow different
CGI modules to write SMF records with distinct subsystem IDs
(e.g. "HTTPD   ", "MVSMF   ", "HTTPLUA ", "HTTPREXX").
Record size grows from 120 to 124 bytes.

Remove temporary debug wtof() calls added during SMF header analysis.
Add parmlib keyword SMF with levels NONE (default), ERROR, AUTH, ALL:
- NONE: no SMF recording, only counters
- ERROR: write SMF on resp >= 400
- AUTH: write on 401/403 and errors
- ALL: every request (sub=1) + session close records (sub=2)

Optional TYPE=nnn parameter overrides the default SMF type 243.

New HTTPD struct fields: smf_level, smf_type (reuse bytes at 0x67-0x68).
Session record (subtype 2) written in httpclos.c on final disconnect
when level=ALL, includes request_count and total_bytes per connection.

Console commands updated:
- D S shows SMF level and type
- S STATS NONE|ERROR|AUTH|ALL [RESET]
Request record (subtype 1):
- Change resp_code from short to unsigned int, eliminating 2 bytes
  of compiler-inserted padding before bytes_sent
- Change duration_ms to duration_us (microseconds)

Session record (subtype 2):
- Fill connect_time with SMF time (1/100s since midnight) at accept
- Fill duration_us from session elapsed time
- Fill total_bytes from new httpc->total_bytes_sent accumulator
  (not reset on keep-alive, only on new connection)

HTTPC struct (stays 4096 bytes):
- Replace request_count (unsigned short) + unused3 with three
  unsigned fields: connect_time, total_bytes_sent, request_count
- CBUFSIZE shrinks from 4008 to 4000 bytes (buf starts at 0x60)
- Update httpcgi.h to match
Compute session duration from connect_time to current time instead
of httpc->end - httpc->start (which only reflects the last request
due to keep-alive resets). Remove debug WTO.

Previous commit changed HTTPC struct layout but only recompiled 2
of 112 modules — all modules now rebuilt with correct field offsets.
@mgrossmann mgrossmann merged commit d851864 into main Apr 11, 2026
1 check failed
@mgrossmann mgrossmann deleted the issue-54-simplify-stats-smf branch April 11, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify stats to basic counters + SMF Type 243

1 participant