Skip to content

Commit

Permalink
Merge pull request #2498 from RaiderIO/development
Browse files Browse the repository at this point in the history
Release v11.3.1 - Performance optimizations and bugfixes
  • Loading branch information
Wotuu authored Sep 19, 2024
2 parents 673b5ef + 7c59db1 commit 89085ca
Show file tree
Hide file tree
Showing 28 changed files with 245 additions and 52 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected function schedule(Schedule $schedule): void
}

// Ensure redis remains healthy
$schedule->command('redis:clearidlekeys', ['seconds' => 3600 * 12])->hourly();
$schedule->command('redis:clearidlekeys', ['seconds' => 900])->everyFifteenMinutes();

// Aggregate all metrics so they're nice and snappy to load
$schedule->command('metric:aggregate')->everyFiveMinutes();
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/Ajax/AjaxDungeonRouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,12 @@ public function htmlsearch(AjaxDungeonRouteSearchFormRequest $request, Expansion
'ratings', 'routeattributes', 'dungeon', 'dungeon.activeFloors', 'mappingVersion'])
->join('dungeons', 'dungeon_routes.dungeon_id', 'dungeons.id')
->join('mapping_versions', 'mapping_versions.dungeon_id', 'dungeons.id')
->when($expansion !== null, static fn(Builder $builder) => $builder->where('dungeons.expansion_id', $expansion->id))
->when($season !== null, static fn(Builder $builder) => $builder->join('season_dungeons', 'season_dungeons.dungeon_id', '=', 'dungeon_routes.dungeon_id')
->where('season_dungeons.season_id', $season->id))
->when($expansion !== null, static fn(Builder $builder) =>
$builder->where('dungeons.expansion_id', $expansion->id)
)
->when($season !== null, static fn(Builder $builder) =>
$builder->where('season_id', $season->id)
)
// Only non-try routes, combine both where() and whereNull(), there are inconsistencies where one or the
// other may work, this covers all bases for both dev and live
->where(static function ($query) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ protected function applyFilter(Builder $subBuilder, $columnData, $order, $genera
if ($explode[0] === 'season') {
$seasonId = $explode[1];
// Joins need to be added to the main builder
$this->getDtHandler()->getBuilder()
->join('season_dungeons', 'season_dungeons.season_id', '=', DB::raw($seasonId));
$subBuilder->whereColumn('dungeon_routes.dungeon_id', '=', 'season_dungeons.dungeon_id');
$subBuilder->where('dungeon_routes.season_id', $seasonId);
} else if ($explode[0] === 'expansion') {
$subBuilder->where('dungeons.expansion_id', $explode[1]);
} else {
Expand Down
8 changes: 4 additions & 4 deletions app/Models/Expansion.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @property Carbon $updated_at
*
* @property Collection<Dungeon> $dungeons
* @property TimewalkingEvent|null $timewalkingevent
* @property TimewalkingEvent|null $timewalkingEvent
*
* @method static Builder active()
*
Expand All @@ -45,7 +45,7 @@ class Expansion extends CacheModel

public $hidden = ['id', 'icon_file_id', 'created_at', 'updated_at'];

public $with = ['timewalkingevent'];
public $with = ['timewalkingEvent'];

protected $dates = [
// 'released_at',
Expand Down Expand Up @@ -111,7 +111,7 @@ public function seasons(): HasMany
return $this->hasMany(Season::class);
}

public function timewalkingevent(): HasOne
public function timewalkingEvent(): HasOne
{
return $this->hasOne(TimewalkingEvent::class);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ public function scopeInactive(Builder $query): Builder

public function hasTimewalkingEvent(): bool
{
return $this->timewalkingevent instanceof TimewalkingEvent;
return $this->timewalkingEvent instanceof TimewalkingEvent;
}

public function hasDungeonForGameVersion(GameVersion $gameVersion): bool
Expand Down
9 changes: 5 additions & 4 deletions app/Service/Cache/CacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ public function clearIdleKeys(?int $seconds = null): int
sprintf('/%s[a-zA-Z0-9]{40}(?::[a-z0-9]{40})*/', $prefix),
];

$deletedKeysCountTotal = $deletedKeysCount = 0;
try {
$this->log->clearIdleKeysStart($seconds);
$i = 0;
$nextKey = 0;
$deletedKeysCount = 0;
$i = 0;
$nextKey = 0;

do {
$result = Redis::command('SCAN', [$nextKey]);
Expand Down Expand Up @@ -205,12 +205,13 @@ public function clearIdleKeys(?int $seconds = null): int

$i++;
if ($i % 1000 === 0) {
$deletedKeysCountTotal += $deletedKeysCount;
$this->log->clearIdleKeysProgress($i, $deletedKeysCount);
$deletedKeysCount = 0;
}
} while ($nextKey > 0);
} finally {
$this->log->clearIdleKeysEnd();
$this->log->clearIdleKeysEnd($deletedKeysCountTotal);
}

return $deletedKeysCount;
Expand Down
4 changes: 2 additions & 2 deletions app/Service/Cache/Logging/CacheServiceLogging.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function clearIdleKeysProgress(int $index, int $deletedKeysCount): void
$this->debug(__METHOD__, get_defined_vars());
}

public function clearIdleKeysEnd(): void
public function clearIdleKeysEnd(int $deletedKeysCount): void
{
$this->end(__METHOD__);
$this->end(__METHOD__, get_defined_vars());
}
}
2 changes: 1 addition & 1 deletion app/Service/Cache/Logging/CacheServiceLoggingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public function clearIdleKeysFailedToDeleteAllKeys(int $amount, int $total): voi

public function clearIdleKeysProgress(int $index, int $deletedKeysCount): void;

public function clearIdleKeysEnd(): void;
public function clearIdleKeysEnd(int $deletedKeysCount): void;
}
6 changes: 4 additions & 2 deletions app/Service/MDT/MDTExportStringService.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,15 @@ public function getEncodedString(Collection $warnings): string
{
// $lua = $this->_getLua();

$affixes = $this->dungeonRoute->affixes;

$mdtObject = [
//
'objects' => $this->extractObjects($warnings),
// M+ level
'difficulty' => $this->dungeonRoute->level_min,
'week' => $this->dungeonRoute->affixGroups->isEmpty() ? 1 :
Conversion::convertAffixGroupToWeek($this->dungeonRoute->affixes->first()),
'week' => $this->dungeonRoute->affixGroups->isEmpty() || $affixes->isEmpty() ? 1 :
Conversion::convertAffixGroupToWeek($affixes->first()),
'value' => [
'currentDungeonIdx' => $this->dungeonRoute->dungeon->mdt_id,
'selection' => [],
Expand Down
2 changes: 1 addition & 1 deletion config/horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
'connection' => 'redis',
'queue' => [sprintf('%s-production-thumbnail', env('APP_TYPE'))],
'balance' => 'simple',
'processes' => 6,
'processes' => 3,
'tries' => 1,
],
'supervisor-thumbnail-api' => [
Expand Down
6 changes: 3 additions & 3 deletions config/keystoneguru.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@
'refresh_min' => 30,

/**
* The amount of days where the thumbnail gets refreshed anyways regardless of other rules.
* The amount of days when the thumbnail gets refreshed anyways regardless of other rules.
*/
'refresh_anyways_days' => 30,

/**
* The amount of hours where a thumbnail refresh must be in the queue for before it is re-queued
* The amount of hours when a thumbnail refresh must be in the queue for before it is re-queued
*/
'refresh_requeue_hours' => 12,

Expand All @@ -190,7 +190,7 @@
/**
* The maximum amount of thumbnails that will be queued in a single run.
*/
'refresh_outdated_count' => 300,
'refresh_outdated_count' => 150,
],

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
/** @noinspection SqlWithoutWhere */
DB::update('
UPDATE `users` SET `locale` = REPLACE(`locale`, "-", "_")
');

Schema::table('users', function (Blueprint $table) {
$table->string('locale')->default('en_US')->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('locale')->default('en-US')->change();
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('team_users', function (Blueprint $table) {
$table->dropIndex(['user_id']);

$table->index(['user_id', 'role']);
$table->index('role');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('team_users', function (Blueprint $table) {
$table->index('user_id');

$table->dropIndex(['user_id', 'role']);
$table->dropIndex('role');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('releases', function (Blueprint $table) {
$table->index(['spotlight', 'created_at']);
$table->index(['created_at']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('releases', function (Blueprint $table) {
$table->dropIndex(['created_at']);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('floors', function (Blueprint $table) {
$table->index(['index']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('floors', function (Blueprint $table) {
$table->dropIndex(['index']);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('metrics', function (Blueprint $table) {
$table->dropIndex(['model_id', 'model_class']);
$table->index(['model_id', 'model_class', 'category', 'tag'], 'compound');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('metrics', function (Blueprint $table) {
$table->dropIndex('compound');
$table->index(['model_id', 'model_class']);
});
}
};
Loading

0 comments on commit 89085ca

Please sign in to comment.