Skip to content

Commit c4373b8

Browse files
committed
log touchups
1 parent 0dfedd8 commit c4373b8

11 files changed

Lines changed: 36 additions & 48 deletions

File tree

cache/__tests__/cache-metrics-worst-case.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ test_create_endpoint_empty() {
10681068
echo "{\"type\":\"CreatePerfTest\",\"timestamp\":$(date +%s%3N),\"random\":$RANDOM}"
10691069
}
10701070

1071-
log_info "Testing create with empty cache (100 operations - 50 for each delete test)..."
1071+
log_info "Testing create with empty cache (100 operations)..."
10721072

10731073
# Call function directly (not in subshell) so CREATED_IDS changes persist
10741074
run_write_performance_test "create" "create" "POST" "generate_create_body" 100
@@ -1142,7 +1142,7 @@ test_update_endpoint_empty() {
11421142
return
11431143
fi
11441144

1145-
log_info "Testing update with empty cache ($NUM_ITERATIONS iterations on same object)..."
1145+
log_info "Testing update with empty cache ($NUM_ITERATIONS iterations)..."
11461146

11471147
declare -a empty_times=()
11481148
local empty_total=0
@@ -1216,7 +1216,7 @@ test_update_endpoint_full() {
12161216
return
12171217
fi
12181218

1219-
log_info "Testing update with full cache (${CACHE_FILL_SIZE} entries, $NUM_ITERATIONS iterations on same object)..."
1219+
log_info "Testing update with full cache (${CACHE_FILL_SIZE} entries, $NUM_ITERATIONS iterations)..."
12201220
echo "[INFO] Using unique type 'WORST_CASE_WRITE_UNIQUE_99999' to force full cache scan with no invalidations..."
12211221

12221222
declare -a full_times=()

cache/__tests__/cache-metrics.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ test_create_endpoint_empty() {
10941094
echo "{\"type\":\"CreatePerfTest\",\"timestamp\":$(date +%s%3N),\"random\":$RANDOM}"
10951095
}
10961096

1097-
log_info "Testing create with empty cache (100 operations - 50 for each delete test)..."
1097+
log_info "Testing create with empty cache (100 operations)..."
10981098

10991099
# Call function directly (not in subshell) so CREATED_IDS changes persist
11001100
run_write_performance_test "create" "create" "POST" "generate_create_body" 100
@@ -1167,7 +1167,7 @@ test_update_endpoint_empty() {
11671167
return
11681168
fi
11691169

1170-
log_info "Testing update with empty cache ($NUM_ITERATIONS iterations on same object)..."
1170+
log_info "Testing update with empty cache ($NUM_ITERATIONS iterations)..."
11711171

11721172
declare -a empty_times=()
11731173
local empty_total=0
@@ -1241,7 +1241,7 @@ test_update_endpoint_full() {
12411241
return
12421242
fi
12431243

1244-
log_info "Testing update with full cache (${CACHE_FILL_SIZE} entries, $NUM_ITERATIONS iterations on same object)..."
1244+
log_info "Testing update with full cache (${CACHE_FILL_SIZE} entries, $NUM_ITERATIONS iterations)..."
12451245

12461246
declare -a full_times=()
12471247
local full_total=0

cache/docs/CACHE_METRICS_REPORT.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# RERUM Cache Metrics & Functionality Report
22

3-
**Generated**: Fri Oct 24 20:39:26 UTC 2025
3+
**Generated**: Fri Oct 24 16:26:17 CDT 2025
44
**Test Duration**: Full integration and performance suite
55
**Server**: http://localhost:3001
66

77
---
88

99
## Executive Summary
1010

11-
**Overall Test Results**: 37 passed, 0 failed, 0 skipped (37 total)
11+
**Overall Test Results**: 32 passed, 0 failed, 0 skipped (32 total)
1212

1313
### Cache Performance Summary
1414

1515
| Metric | Value |
1616
|--------|-------|
1717
| Cache Hits | 3 |
18-
| Cache Misses | 1010 |
18+
| Cache Misses | 1007 |
1919
| Hit Rate | 0.30% |
2020
| Cache Size | 999 entries |
2121
| Invalidations | 7 |
@@ -33,7 +33,7 @@
3333
| `/history` | ✅ Functional | Get object version history |
3434
| `/since` | ✅ Functional | Get objects modified since timestamp |
3535
| `/create` | ✅ Functional | Create new objects |
36-
| `/update` | ✅ Functional | Update existing objects |
36+
| `/update` | ⚠️ Partial Failures (2/50) | Update existing objects |
3737
| `/patch` | ✅ Functional | Patch existing object properties |
3838
| `/set` | ✅ Functional | Add new properties to objects |
3939
| `/unset` | ✅ Functional | Remove properties from objects |
@@ -48,12 +48,12 @@
4848

4949
| Endpoint | Cold Cache (DB) | Warm Cache (Memory) | Speedup | Benefit |
5050
|----------|-----------------|---------------------|---------|---------|
51-
| `/query` | 526 | N/A | N/A | N/A |
52-
| `/search` | 110 | N/A | N/A | N/A |
53-
| `/searchPhrase` | 34 | N/A | N/A | N/A |
54-
| `/id` | 416 | N/A | N/A | N/A |
55-
| `/history` | 734 | N/A | N/A | N/A |
56-
| `/since` | 724 | N/A | N/A | N/A |
51+
| `/query` | 444 | N/A | N/A | N/A |
52+
| `/search` | 516 | N/A | N/A | N/A |
53+
| `/searchPhrase` | 64 | N/A | N/A | N/A |
54+
| `/id` | 495 | N/A | N/A | N/A |
55+
| `/history` | 862 | N/A | N/A | N/A |
56+
| `/since` | 866 | N/A | N/A | N/A |
5757

5858
**Interpretation**:
5959
- **Cold Cache**: First request hits database (cache miss)
@@ -69,13 +69,13 @@
6969

7070
| Endpoint | Empty Cache | Full Cache (1000 entries) | Overhead | Impact |
7171
|----------|-------------|---------------------------|----------|--------|
72-
| `/create` | 22ms | 24ms | +2ms |Negligible |
73-
| `/update` | 424ms | 428ms | +4ms |Negligible |
74-
| `/patch` | 426ms | 425ms | -1ms | ✅ None |
75-
| `/set` | 447ms | 442ms | -5ms | ✅ None |
76-
| `/unset` | 427ms | 426ms | -1ms | ✅ None |
77-
| `/delete` | 445ms | 428ms | -17ms | ✅ None |
78-
| `/overwrite` | 438ms | 425ms | -13ms |None |
72+
| `/create` | 57ms | 56ms | -1ms |None |
73+
| `/update` | 470ms | N/A | N/A |Write-only |
74+
| `/patch` | 1078ms | 475ms | -603ms | ✅ None |
75+
| `/set` | 476ms | 475ms | -1ms | ✅ None |
76+
| `/unset` | 485ms | 899ms | +414ms | ⚠️ Moderate |
77+
| `/delete` | 517ms | 680ms | +163ms | ⚠️ Moderate |
78+
| `/overwrite` | 475ms | 477ms | +2ms |Negligible |
7979

8080
**Interpretation**:
8181
- **Empty Cache**: Write with no cache to invalidate
@@ -98,7 +98,7 @@
9898

9999
**Cache Costs (Writes)**:
100100
- Average overhead per write: ~-4ms
101-
- Overhead percentage: ~-1%
101+
- Overhead percentage: ~0%
102102
- Net cost on 1000 writes: ~-4000ms
103103
- Tested endpoints: create, update, patch, set, unset, delete, overwrite
104104

@@ -111,17 +111,17 @@ For a workload with:
111111

112112
```
113113
Without Cache:
114-
800 reads × 526ms = 420800ms
115-
200 writes × 22ms = 4400ms
116-
Total: 425200ms
114+
800 reads × 444ms = 355200ms
115+
200 writes × 57ms = 11400ms
116+
Total: 366600ms
117117
118118
With Cache:
119119
560 cached reads × 5ms = 2800ms
120-
240 uncached reads × 526ms = 126240ms
121-
200 writes × 24ms = 4800ms
122-
Total: 133840ms
120+
240 uncached reads × 444ms = 106560ms
121+
200 writes × 56ms = 11200ms
122+
Total: 120560ms
123123
124-
Net Improvement: 291360ms faster (~69% improvement)
124+
Net Improvement: 246040ms faster (~68% improvement)
125125
```
126126

127127
---
@@ -132,8 +132,8 @@ Net Improvement: 291360ms faster (~69% improvement)
132132

133133
The cache layer provides:
134134
1. **Significant read performance improvements** (0ms average speedup)
135-
2. **Minimal write overhead** (-4ms average, ~-1% of write time)
136-
3. **All endpoints functioning correctly** (37 passed tests)
135+
2. **Minimal write overhead** (-4ms average, ~0% of write time)
136+
3. **All endpoints functioning correctly** (32 passed tests)
137137

138138
### 📊 Monitoring Recommendations
139139

@@ -164,7 +164,7 @@ Consider tuning based on:
164164
- Server: http://localhost:3001
165165
- Test Framework: Bash + curl
166166
- Metrics Collection: Millisecond-precision timing
167-
- Test Objects Created: 202
167+
- Test Objects Created: 198
168168
- All test objects cleaned up: ✅
169169

170170
**Test Coverage**:
@@ -176,6 +176,6 @@ Consider tuning based on:
176176

177177
---
178178

179-
**Report Generated**: Fri Oct 24 20:39:26 UTC 2025
179+
**Report Generated**: Fri Oct 24 16:26:17 CDT 2025
180180
**Format Version**: 1.0
181181
**Test Suite**: cache-metrics.sh

controllers/crud.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const create = async function (req, res, next) {
4141
delete provided["@context"]
4242

4343
let newObject = Object.assign(context, { "@id": process.env.RERUM_ID_PREFIX + id }, provided, rerumProp, { "_id": id })
44-
console.log("CREATE")
4544
try {
4645
let result = await db.insertOne(newObject)
4746
res.set(utils.configureWebAnnoHeadersFor(newObject))
@@ -63,7 +62,6 @@ const create = async function (req, res, next) {
6362
* The return is always an array, even if 0 or 1 objects in the return.
6463
* */
6564
const query = async function (req, res, next) {
66-
console.log("QUERY TO MONGODB")
6765
res.set("Content-Type", "application/json; charset=utf-8")
6866
let props = req.body
6967
const limit = parseInt(req.query.limit ?? 100)
@@ -93,7 +91,6 @@ const query = async function (req, res, next) {
9391
* Note /v1/id/{blank} does not route here. It routes to the generic 404
9492
* */
9593
const id = async function (req, res, next) {
96-
console.log("_id TO MONGODB")
9794
res.set("Content-Type", "application/json; charset=utf-8")
9895
let id = req.params["_id"]
9996
try {

controllers/delete.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,9 @@ const deleteObj = async function(req, res, next) {
8686
next(createExpressError(err))
8787
return
8888
}
89-
//204 to say it is deleted and there is nothing in the body
90-
console.log("Object deleted: " + preserveID)
9189
// Store the deleted object for cache invalidation middleware to use for smart invalidation
9290
res.locals.deletedObject = safe_original
91+
//204 to say it is deleted and there is nothing in the body
9392
res.sendStatus(204)
9493
return
9594
}

controllers/overwrite.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const overwrite = async function (req, res, next) {
2323
let agentRequestingOverwrite = getAgentClaim(req, next)
2424
const receivedID = objectReceived["@id"] ?? objectReceived.id
2525
if (receivedID) {
26-
console.log("OVERWRITE")
2726
let id = parseDocumentID(receivedID)
2827
let originalObject
2928
try {

controllers/patchUnset.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ const patchUnset = async function (req, res, next) {
9191
if(_contextid(patchedObject["@context"])) delete patchedObject.id
9292
delete patchedObject["@context"]
9393
let newObject = Object.assign(context, { "@id": process.env.RERUM_ID_PREFIX + id }, patchedObject, rerumProp, { "_id": id })
94-
console.log("PATCH UNSET")
9594
try {
9695
let result = await db.insertOne(newObject)
9796
if (alterHistoryNext(originalObject, newObject["@id"])) {

controllers/patchUpdate.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ const patchUpdate = async function (req, res, next) {
9090
if(_contextid(patchedObject["@context"])) delete patchedObject.id
9191
delete patchedObject["@context"]
9292
let newObject = Object.assign(context, { "@id": process.env.RERUM_ID_PREFIX + id }, patchedObject, rerumProp, { "_id": id })
93-
console.log("PATCH UPDATE")
9493
try {
9594
let result = await db.insertOne(newObject)
9695
if (alterHistoryNext(originalObject, newObject["@id"])) {

controllers/putUpdate.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const putUpdate = async function (req, res, next) {
6363
delete objectReceived["@context"]
6464

6565
let newObject = Object.assign(context, { "@id": process.env.RERUM_ID_PREFIX + id }, objectReceived, rerumProp, { "_id": id })
66-
console.log("UPDATE")
6766
try {
6867
let result = await db.insertOne(newObject)
6968
if (alterHistoryNext(originalObject, newObject["@id"])) {
@@ -122,7 +121,6 @@ async function _import(req, res, next) {
122121
delete objectReceived["@context"]
123122

124123
let newObject = Object.assign(context, { "@id": process.env.RERUM_ID_PREFIX + id }, objectReceived, rerumProp, { "_id": id })
125-
console.log("IMPORT")
126124
try {
127125
let result = await db.insertOne(newObject)
128126
res.set(utils.configureWebAnnoHeadersFor(newObject))

controllers/release.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ const release = async function (req, res, next) {
7171
next(createExpressError(err))
7272
return
7373
}
74-
console.log("RELEASE")
7574
if (null !== originalObject){
7675
safe_original["__rerum"].isReleased = new Date(Date.now()).toISOString().replace("Z", "")
7776
safe_original["__rerum"].releases.replaces = previousReleasedID
@@ -108,7 +107,6 @@ const release = async function (req, res, next) {
108107
//result didn't error out, the action was not performed. Sometimes, this is a neutral thing. Sometimes it is indicative of an error.
109108
}
110109
res.set(utils.configureWebAnnoHeadersFor(releasedObject))
111-
console.log(releasedObject._id+" has been released")
112110
releasedObject = idNegotiation(releasedObject)
113111
releasedObject.new_obj_state = JSON.parse(JSON.stringify(releasedObject))
114112
res.location(releasedObject[_contextid(releasedObject["@context"]) ? "id":"@id"])

0 commit comments

Comments
 (0)