Repository navigation
Speed up server bootstrap and startup - #8371
Conversation
|
Speedup: PostgreSQL foreign-key lookup Fresh-database bootstrap on a local dev server (macOS, 131 modules), same tree with and without the change; JFR socket time on the Module Upgrade thread:
Per call, the JDBC driver's query costs about 4.2 ms, mostly planning a nine-relation join, against about 0.3 ms for the new query, timed across all 1,837 tables of a populated database. The two queries returned identical rows for every FK in that database. Whole-bootstrap time (49.3 s before, 48.4 s after) was dominated by run-to-run noise in script and |
|
Speedup: startup view check Routine restarts (no deploy) on a local dev server:
About 1.9 s saved per restart. The new check answers the same question (is a view declared in schema.xml missing from the database?) from one list of table names per schema instead of full per-table metadata. |
|
Speedup: parallel audit provider initialization Local dev server (macOS, 131 modules, 57 audit tables). Times are for the Audit Log startup listener and come from the server log:
About 5.5 s is saved per fresh bootstrap. The rest of the Module Upgrade difference is run-to-run noise in other phases. JFR shows the workers mostly waiting on Postgres, with under 1 s of Java-side contention (per-transaction cache creation and connection checkout), which caps the speedup near 3x rather than 8x. On TeamCity BVT-A the serial listener took 12.5 s (~350 ms per table), so the same ratio would save about 8 s per suite. |
…t re-extraction edge cases to_regclass() throws when the role lacks USAGE on the schema, where pgjdbc's getImportedKeys() does not.
| private static final Logger _log = LogManager.getLogger(TableXmlUtils.class); | ||
|
|
||
| // schema.xml-only tableDbType for objects whose type differs between databases; no DatabaseTableType counterpart | ||
| private static final String UNKNOWN_TABLE_TYPE = "UNKNOWN"; |
There was a problem hiding this comment.
FYI: Now that we only support one database, I think we can get rid of UNKNOWN_TABLE_TYPE. Maybe for a different branch.
|
Manual testing looks good. I started up multiple times on my standard dev database as well as a new bootstrapped database. I compared timings from the very first log line ("Executing...main()") to "Module startup complete". My baseline was two minutes. First startup after building the change showed no improvement (two minutes). All subsequent startups were just under a minute, so twice as fast. Except for a bootstrap startup, which was still fast, at 1:21. No idea why that first startup was slower. |
## Rationale This PR shortens server startup by cutting time spent in class loading and module extraction, part of getting TeamCity BVT suites to their first test sooner. Measured speedups for each change are in the PR comments. Deploys still rewrite every module archive, so the first restart after a deploy still checks every module; that build-side cause is LabKey/internal-issues#1936. ## Related Pull Requests - LabKey/platform#8371 ## Changes - When the webapp supplies no classes of its own, answer Tomcat's class-loader lookups without touching the disk - When a module archive changes, rewrite only the files whose content changed instead of deleting and re-extracting the whole module - Extract the largest module archives first so a big one can't start last and stretch the extraction phase
Rationale
This PR shortens server bootstrap and routine startup, part of getting TeamCity BVT suites to their first test sooner. Measured speedups for each change are in the PR comments.
Related Pull Requests
Changes
Testing
New
JdbcMetaDataTestFK equivalence test passed on a local server; newTableXmlUtils.TestCasehas not run yet. NewModuleArchiveTestCasere-extraction test, which covers the extraction change in LabKey/server#1562, passed in a standalone JUnit run. Fresh-database bootstraps and routine restarts ran locally without errors.Tasks