perf(core): 서빙 API 부팅 비용 최적화 (information_schema 가드 + 훅/오토로드/config 캐시)
매 요청 균일하게 발생하던 부팅 오버헤드를 4개 축에서 제거한다. - 설치 완료 상태에서 매 요청 반복되던 information_schema 조회(알림·본인인증 테이블 hasTable)를 installer_completed 가드로 스킵. 미설치 환경은 기존 hasTable 폴백 유지. - 코어+모듈+플러그인 정적 훅 매핑을 bootstrap/cache/hooks.php 에 사전 계산해 매 요청 디렉토리 스캔·리플렉션·클래스 로딩을 제거(route:cache 동형). 등록↔발화 계약·매핑 바이트 동일. 확장/코어 변경 시 자동 재생성, 캐시 부재·손상은 스캔 폴백. - 확장 소스(Modules\*/Plugins\*)를 autoload-extensions.php 의 classmap 에 편입해 findFile 파일시스템 스캔을 제거(느린 FS·cold OPcache 환경 직격). 클래스 로딩은 여전히 lazy, PSR-4 폴백 유지. - config 캐시를 변경 지점(설정 저장/코어·확장 업데이트/APP_KEY 재생성/설치 완료)에서 clear 후 즉시 재생성하도록 ConfigCacheHelper 로 일원화. clear 만 하고 방치돼 캐시가 영구 비활성으로 남던 성능 손실 제거. HookCacheManager::read 요청당 1회 로드(memo)로 중복 파싱 제거. 부팅 매핑 fingerprint 스캔↔캐시 완전 동일(229 action + 35 filter). 신규/수정 8개 스위트 54 pass. 순수 내부 부팅 인프라 — 확장 공개 표면·훅 계약 불변.
This commit is contained in:
1 parent
deacbc7b66
commit
c08dae7cb0
41 files changed
+2590
-131
No files matched your search
+22
-9
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
// 설치 완료 여부 확인
|
||||
$installedFlagPath = __DIR__ . '/../storage/app/g7_installed';
|
||||
$envPath = __DIR__ . '/../.env';
|
||||
$installedFlagPath = __DIR__.'/../storage/app/g7_installed';
|
||||
$envPath = __DIR__.'/../.env';
|
||||
|
||||
// 설치 확인: g7_installed 파일 또는 .env의 INSTALLER_COMPLETED
|
||||
$isInstalled = file_exists($installedFlagPath) || (
|
||||
@@ -11,11 +11,11 @@ $isInstalled = file_exists($installedFlagPath) || (
|
||||
);
|
||||
|
||||
// 미설치 시 /install로 리다이렉트
|
||||
if (!$isInstalled) {
|
||||
$installUrl = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') . '/install';
|
||||
if (! $isInstalled) {
|
||||
$installUrl = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/install';
|
||||
echo '<script>
|
||||
alert("G7 최초 사용을 위해 설치 절차가 필요합니다. 설치 화면으로 이동합니다.");
|
||||
window.location.href="' . htmlspecialchars($installUrl) . '";
|
||||
window.location.href="'.htmlspecialchars($installUrl).'";
|
||||
</script>';
|
||||
exit;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ if (file_exists($extensionAutoloadFile)) {
|
||||
$extensionAutoloads = require $extensionAutoloadFile;
|
||||
|
||||
// PSR-4 네임스페이스 등록
|
||||
if (!empty($extensionAutoloads['psr4'])) {
|
||||
if (! empty($extensionAutoloads['psr4'])) {
|
||||
foreach ($extensionAutoloads['psr4'] as $namespace => $paths) {
|
||||
// 경로가 배열인 경우와 문자열인 경우 모두 처리
|
||||
$paths = (array) $paths;
|
||||
@@ -55,8 +55,21 @@ if (file_exists($extensionAutoloadFile)) {
|
||||
}
|
||||
}
|
||||
|
||||
// 확장 소스 classmap 등록 (FQCN → 절대경로).
|
||||
// findFile 이 파일시스템 스캔(is_dir/file_exists stat) 없이 in-memory 맵에서 즉시
|
||||
// 경로를 반환하도록 한다. cold OPcache / 느린 파일시스템 환경의 findFile 비용 제거.
|
||||
// 클래스 로딩은 여전히 lazy — 실제 사용 시점에만 include. classmap 미포함 클래스는
|
||||
// 위 PSR-4 등록으로 폴백(안전망).
|
||||
if (! empty($extensionAutoloads['src_classmap'])) {
|
||||
$absoluteClassmap = [];
|
||||
foreach ($extensionAutoloads['src_classmap'] as $fqcn => $relPath) {
|
||||
$absoluteClassmap[$fqcn] = __DIR__.'/../'.$relPath;
|
||||
}
|
||||
$loader->addClassMap($absoluteClassmap);
|
||||
}
|
||||
|
||||
// Classmap 파일 로드 (module.php, plugin.php)
|
||||
if (!empty($extensionAutoloads['classmap'])) {
|
||||
if (! empty($extensionAutoloads['classmap'])) {
|
||||
foreach ($extensionAutoloads['classmap'] as $file) {
|
||||
$absolutePath = __DIR__.'/../'.$file;
|
||||
if (file_exists($absolutePath)) {
|
||||
@@ -66,7 +79,7 @@ if (file_exists($extensionAutoloadFile)) {
|
||||
}
|
||||
|
||||
// Files 로드 (헬퍼 함수 등)
|
||||
if (!empty($extensionAutoloads['files'])) {
|
||||
if (! empty($extensionAutoloads['files'])) {
|
||||
foreach ($extensionAutoloads['files'] as $file) {
|
||||
$absolutePath = __DIR__.'/../'.$file;
|
||||
if (file_exists($absolutePath)) {
|
||||
@@ -76,7 +89,7 @@ if (file_exists($extensionAutoloadFile)) {
|
||||
}
|
||||
|
||||
// Vendor autoloads 로드 (모듈/플러그인의 composer 의존성)
|
||||
if (!empty($extensionAutoloads['vendor_autoloads'])) {
|
||||
if (! empty($extensionAutoloads['vendor_autoloads'])) {
|
||||
foreach ($extensionAutoloads['vendor_autoloads'] as $vendorAutoload) {
|
||||
$absolutePath = __DIR__.'/../'.$vendorAutoload;
|
||||
if (file_exists($absolutePath)) {
|
||||
|
||||
@@ -1491,6 +1491,28 @@ if (!function_exists('clearCacheSSE')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('optimizeConfigCacheSSE')) {
|
||||
/**
|
||||
* 설치 완료 직후 config 캐시를 최초 생성한다.
|
||||
*
|
||||
* complete_flag 이후에 실행되어 installer_completed=true 상태에서 캐시를 만들며,
|
||||
* 이 지점이 없으면 설치는 config:cache 가 꺼진(매 요청 config 재파싱) 상태로 종료된다.
|
||||
* best_effort — 실패해도 설치 자체는 완료 처리한다(비캐시 부팅은 정상 동작).
|
||||
*
|
||||
* @return array 태스크 실행 결과
|
||||
*/
|
||||
function optimizeConfigCacheSSE(): array
|
||||
{
|
||||
return executeArtisanCommandSSE(
|
||||
artisanCommand: 'config:cache',
|
||||
taskId: 'config_cache',
|
||||
taskNameKey: 'task_config_cache',
|
||||
successMsgKey: 'log_config_cache_success',
|
||||
errorMsgKey: 'error_config_cache_failed'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('createSettingsJsonSSE')) {
|
||||
function createSettingsJsonSSE(): array
|
||||
{
|
||||
@@ -1757,6 +1779,9 @@ if (!function_exists('runInstallationTasks')) {
|
||||
$tasks[] = ['id' => 'create_settings_json', 'function' => 'createSettingsJsonSSE'];
|
||||
$tasks[] = ['id' => 'cache_clear', 'function' => 'clearCacheSSE'];
|
||||
$tasks[] = ['id' => 'complete_flag', 'function' => 'setInstallationCompleteSSE'];
|
||||
// complete_flag(installer_completed=true) 이후에 config 캐시를 최초 생성해야
|
||||
// 설치가 config:cache 켜진 상태로 시작한다. best_effort — 실패해도 설치는 완료.
|
||||
$tasks[] = ['id' => 'config_cache', 'function' => 'optimizeConfigCacheSSE', 'best_effort' => true];
|
||||
|
||||
foreach ($tasks as $task) {
|
||||
if (checkAbortStatusSSE()) {
|
||||
|
||||
@@ -270,6 +270,7 @@ return [
|
||||
'task_cache_clear' => 'Cleaning Up Temporary Files',
|
||||
'task_create_settings_json' => 'Creating Settings Files',
|
||||
'task_complete_flag' => 'Finalizing Installation',
|
||||
'task_config_cache' => 'Building Configuration Cache',
|
||||
'task_unknown' => 'Unknown Task',
|
||||
|
||||
// Task Group Names
|
||||
@@ -371,9 +372,11 @@ return [
|
||||
|
||||
// Error Messages - Worker (Cache)
|
||||
'error_cache_clear_failed' => 'Cache clearing failed',
|
||||
'error_config_cache_failed' => 'Configuration cache build failed',
|
||||
|
||||
// Log Messages - Worker (Cache)
|
||||
'log_cache_clear_success' => 'Cache clearing completed',
|
||||
'log_config_cache_success' => 'Configuration cache built',
|
||||
|
||||
// Error Messages - Worker (Settings JSON)
|
||||
'error_settings_json_failed' => 'Settings file creation failed',
|
||||
|
||||
@@ -270,6 +270,7 @@ return [
|
||||
'task_cache_clear' => '임시 파일 정리',
|
||||
'task_create_settings_json' => '설정 파일 생성',
|
||||
'task_complete_flag' => '설치 완료 처리',
|
||||
'task_config_cache' => '설정 캐시 생성',
|
||||
'task_unknown' => '알 수 없는 작업',
|
||||
|
||||
// 작업 그룹명
|
||||
@@ -371,9 +372,11 @@ return [
|
||||
|
||||
// 에러 메시지 - Worker (Cache)
|
||||
'error_cache_clear_failed' => '캐시 클리어에 실패했습니다',
|
||||
'error_config_cache_failed' => '설정 캐시 생성에 실패했습니다',
|
||||
|
||||
// 로그 메시지 - Worker (Cache)
|
||||
'log_cache_clear_success' => '캐시 클리어 완료',
|
||||
'log_config_cache_success' => '설정 캐시 생성 완료',
|
||||
|
||||
// 에러 메시지 - Worker (Settings JSON)
|
||||
'error_settings_json_failed' => '설정 파일 생성에 실패했습니다',
|
||||
|
||||
Reference in new issue
Block a user