Application startup and remaining-module performance audit¶
Date: 7 November 2026. Scope: cis-api startup, shared enum converters, administration/reference data, historical archive, role mapping, and selected cis-workflow/cis-bff paths. This is a focused audit, not a load-test certification of every endpoint. Reporting work was committed separately as 2f02ba390 before this changeset.
Why startup appears to pause at the converters¶
The JPA attribute converters under cis-api/.../enums/converter and cis-search/.../enums/converters translate enum constants to stored numbers/strings. They contain no repository, JDBC, or network calls. Hibernate invokes their database-column conversion during mapping/bootstrap as well as normal persistence operations. The visible DEBUG messages identify the last logged operation; they do not time the rest of JPA bootstrap.
A fresh Spring context was profiled with BufferingApplicationStartup against disposable Oracle Free 23 and Redis 7 containers, Java 25, Spring Boot 4.1.2, a 1 GiB test JVM heap, and no JaCoCo instrumentation. Container startup and bootstrap SQL completed before the Spring context measurement. No production database was accessed.
Baseline measured steps (inclusive timings; nested steps overlap and must not be summed):
| Step | Time | Evidence |
|---|---|---|
| Spring context refresh | 25.251 s | spring.context.refresh |
| Entity manager factory creation | 7.051 s | beanName=&entityManagerFactory |
| Bean-factory post-processing | 5.155 s | spring.context.beans.post-process |
| Configuration parsing | 4.500 s | 806 parsed configuration classes |
| Dynamic scheduler bean/dependencies | 2.207 s | instantiated even with scheduling disabled |
| Web server creation | 1.657 s | Tomcat factory |
| JPA repository scanning | 0.707 s | 180 repositories |
All converter messages in this run appeared within the same second, between the start and completion of entity-manager-factory initialization. That observation is not a converter microbenchmark, but neither the source nor the timing supports a claim that converters query the database or consume the whole startup delay.
Boot's overall startup message was 25.694 seconds. The roughly two-minute test process also included container provisioning and schema creation; that is not application startup latency. These measurements use the integration profile with external integrations disabled, not the deployed UAT profile.
Post-change context-refresh samples were 25.977 s and 23.537 s. In the final sample, entity-manager-factory creation took 6.495 s and configuration parsing took 4.945 s across 805 classes; the disabled dynamic scheduler was absent. This variation does not establish a consistent startup speedup. JPA/configuration bootstrap remains the main measured work.
Fixes applied in this changeset¶
- Honor disabled scheduling.
DynamicTaskManagernow uses the samecis.scheduling.enabledcondition asSchedulingConfiguration. Previously its ready-event listener and private scheduler bypassed that flag. The two tasks now share one database setting read per poll, scheduler mutation is synchronized, and its private executor shuts down with the context. Start/cancel transitions are logged without a message for every poll. - Preserve migration validation without automatic repair.
PersistenceConfignow calls onlymigrate(). Startup previously ranrepair()against the history table before every migration check. The baseline repair operation itself took only about 58 ms, so this is primarily a correctness fix and removal of unnecessary database work, not the explanation for the multi-second startup delay. Existing migration drift will now fail validation and needs an explicit reviewed migration/recovery procedure; startup no longer silently accepts it. - Remove repetitive logging from hot paths. The production logback configuration defaults the two attribute-converter packages to INFO. Response advice diagnostics moved from two eagerly formatted INFO messages per response to one parameterized TRACE message. Response envelopes and converter behavior are unchanged. Targeted DEBUG/TRACE can still be enabled for diagnosis.
- Bound reference-code lookup at the database.
ListItemServicenow uses a Spring DatafindFirstByListCodeOrderByItemCodeDescprojection. Previously it fetched every code for the list and retained only the first. Prefix, sorting direction, initial code, and activation behavior are preserved. This does not solve the existing concurrent code-allocation race; that requires a separate uniqueness/allocation design. - Add a repeatable startup profiler.
startupPerformanceTestis opt-in and excluded from normal integration execution. It reports the 25 longest Spring steps and verifies disabled scheduling plus the bounded lookup against actual Oracle SQL. It does not expose startup internals through an HTTP endpoint.
High-priority remaining findings¶
Historical Archive: full-table read plus per-row enrichment¶
Evidence: HistoricalRecordsArchiveService.java:43 calls findAll() and then filters workflowId == null in Java. HistoricalRecordsArchiveEnricher.java:36,45,54,63,72 can call repositories five times per row, including two lookups of the same packet. Actual statement counts depend on persistence-context reuse, but the service does not establish a transaction spanning the list and all enrichment.
Recommended next slice: push the workflow-null predicate into the repository; use a read projection with left joins, or collect distinct IDs and load province/list-item/packet references in bounded batches. Preserve missing-reference behavior. Add an independently paginated endpoint before changing the existing response contract; avoid silently truncating legacy responses. Verify returned fields and SQL statement counts on a representative list with repeated and missing references.
Roles/User/Sitemap: eager navigation graph on ordinary role reads¶
Evidence: Roles.java:52 eagerly loads siteMapRoles; SiteMapRole.java:33 eagerly loads each sitemap. SiteRoleService.java:45 loads all roles. Callers such as user registration and user mapping also use the role repository for fields that do not require sitemap content.
Recommended next slice: add scalar projections for ordinary role checks and user mapping; use one explicit fetch graph/query for the sitemap administration view. Verify statement counts and preserve role/access ordering and authorization behavior. A global switch to LAZY without auditing callers risks lazy-loading failures because open-in-view is disabled.
Medium-priority remaining findings¶
- Workflow publish flushes inside its province loop.
cis-workflow/.../WorkflowProcessDraftService.java:110,112callssaveAndFlushtwice per province; the service has no encompassing transaction annotation. Review the publish operation as one transaction and batch persistence, including delete ordering and sequence allocation, with rollback fixtures before changing flush behavior. - Workflow SQL logging is always enabled. All four
cis-workflowapplication YAML files setshow-sql: true; its logback also enables JDBC DEBUG. Align deployment logging with explicit diagnostic flags, then measure log volume and write latency. This is a source-level risk, not a measured production bottleneck. - Startup remains dominated by JPA and configuration work. After correcting the scheduler flag, evaluate unused configuration/module inclusion and Spring AOT against a production-like launch. Keep repository validation at readiness; do not globally enable lazy initialization just to shift errors and latency onto the first request. Measure Oracle metadata/network time and repository query validation before deciding whether either needs further tuning.
Checks and rerun commands¶
.\gradlew.bat :cis-api:test --tests 'com.dw.ngms.cis.configuration.PersistenceConfigTest' --tests 'com.dw.ngms.cis.configuration.schedular.DynamicTaskManagerTest' --tests 'com.dw.ngms.cis.service.ListItemServiceTest'
.\gradlew.bat :cis-api:startupPerformanceTest --rerun-tasks
The profiler requires Docker, uses disposable schema fixtures, and rolls back its reference-data rows. Baseline and post-change measurements are single fresh-context samples and cannot establish a statistically reliable speedup. For deployed diagnosis, collect multiple comparable starts with the same profile, data, JVM resources, database latency, and logging levels. The test report is under cis-api/build/reports/tests/startupPerformanceTest/.
Final verification passed: 207 focused unit tests (including reporting regressions) and both startup/Oracle fixture tests, with no failures or skipped tests. The ancillary contract task also passed its two tests. The initial Oracle fixture failure was corrected by supplying the required parent list-master rows. git diff --check and XML parsing of the production logback configuration passed. No full application-wide test suite or production launch was performed.