mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +08:00
perf(cron): share global concurrency budget and streamline execution
Share durable permits across manual, scheduled and recovered runs, prioritize short ready tasks with aging, and record global queue occupancy. Reduce launch, log polling, dashboard and SQLite overhead while preserving transactional receipts, cancellation, recovery and script hook compatibility. Keep ordinary CRUD in ORM and bound SQL on measured execution hot paths. Fix supervisor descendant tracking, asynchronous log draining, concurrent log directory creation, Linux fallback launches and snapshot clock rollback. Include regression coverage, SQL audits and evolution/review documentation. Validation: five review rounds; local full suite 1478 passed, 28 platform skips; dev suites 415 passed, no failures/skips; backend types and formatting passed.
This commit is contained in:
1 parent
cddabbaf0e
commit
2f01f756d7
74 files changed
+6891
-837
No files matched your search
@@ -8,6 +8,7 @@ import { slotId } from '../cron/history';
|
||||
import { runCron } from '../cron/execution/runCron';
|
||||
import Logger from '../loaders/logger';
|
||||
import { t, tf } from '../shared/i18n';
|
||||
import { resumeAcceptedCrons } from '../cron/scheduling/resumeAcceptedCrons';
|
||||
|
||||
// Validate the entire batch before replacing any existing jobs.
|
||||
const isValidCronField = (cron: string): boolean => {
|
||||
@@ -77,6 +78,11 @@ const addCron = (
|
||||
const jobs: CronJob[] = [];
|
||||
definitions.set(jobs, signature);
|
||||
prepared.set(item.id, jobs);
|
||||
if (call.request.replace && savePlan) {
|
||||
recoveries.push(() =>
|
||||
resumeAcceptedCrons(item, () => scheduleStacks.get(item.id) === jobs),
|
||||
);
|
||||
}
|
||||
for (const [ruleIndex, schedule] of [
|
||||
item.schedule,
|
||||
...(item.extra_schedules || []).map((x) => x.schedule),
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import type {
|
||||
UntypedServiceImplementation,
|
||||
sendUnaryData,
|
||||
} from '@grpc/grpc-js';
|
||||
import { ApiService } from '../protos/api';
|
||||
|
||||
// Registration/health never need the script API's HTTP-oriented services.
|
||||
// Keep their dependency graph out of an ordinary scheduler's resident heap.
|
||||
// Dynamic import shares initialization across simultaneous first calls; the
|
||||
// normal handlers retain validation, callback errors and service singletons.
|
||||
export function lazyApiHandlers(): UntypedServiceImplementation {
|
||||
return Object.fromEntries(
|
||||
Object.keys(ApiService).map((method) => [
|
||||
method,
|
||||
(call: unknown, callback: sendUnaryData<unknown>) => {
|
||||
void import('./api')
|
||||
.then((handlers) => {
|
||||
const handler = handlers[method as keyof typeof ApiService];
|
||||
return handler(call as never, callback);
|
||||
})
|
||||
.catch(callback);
|
||||
},
|
||||
]),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user