package updates, first pass at render performance

updated dependencies to the latest versions

also took a swing at rendering performance, which was pretty basic. it
was fine for sites with not that many pages, but it gets a bit stick
above 50

as of right now, performance has been improved slighthy by forcing some
garbage collection, rendering 65 pages in under 30 seconds with 256MB
available.

the issue seems to the speed of initial page collections from the
directories and then converting them to objects that the system can use.
going to explore some options to optimize that particular script

also removed page load from PageRepository instantion because when the
app loads, it was calling that class as part of the start of process and
loading pages everytime no matter what page was being looked at.
removing that made non page sections snappier
This commit is contained in:
RXP 2025-06-17 18:24:53 -06:00
parent 9064d6008b
commit cec992ccd4
Signed by: ro
GPG key ID: 85BF909846273553
5 changed files with 404 additions and 361 deletions

View file

@ -16,7 +16,7 @@ use Carbon\Carbon;
class PageRepository implements PageRepositoryInterface
{
protected $content;
protected $setttings;
protected $settings;
protected $paginate;
protected $pages;
protected $docs;
@ -37,17 +37,19 @@ class PageRepository implements PageRepositoryInterface
$this->docs = $docService;
$this->sort = $sortingService;
$this->render = $renderService;
$this->pages = $this->content->loadAllPages();
//change this because every time the class is created, it loads all pages, which kills
//performance site wide since it's being called by a service provider
//$this->pages = $this->content->loadAllPages();
}
public function getAll()
{
return $this->pages;
return $this->content->loadAllPages();
}
public function getById($id)
{
$page = $this->pages->where('id', $id)->first();
$page = $this->content->loadAllPages()->where('id', $id)->first();
//quick check to see if layout is set
$page['layout'] == '' ? $page['layout'] = 'page' : $page['layout'] = $page['layout'];
return $page;
@ -55,7 +57,7 @@ class PageRepository implements PageRepositoryInterface
public function getByUuid($uuid)
{
$page = $this->pages->where('uuid', $uuid)->first();
$page = $this->content->loadAllPages()->where('uuid', $uuid)->first();
//quick check to see if layout is set
$page['layout'] == '' ? $page['layout'] = 'page' : $page['layout'] = $page['layout'];
return $page;
@ -63,7 +65,7 @@ class PageRepository implements PageRepositoryInterface
public function getBySlug($slug)
{
$page = $this->pages->where('slug', $slug)->first();
$page = $this->content->loadAllPages()->where('slug', $slug)->first();
//quick check to see if layout is set
$page['layout'] == '' ? $page['layout'] = 'page' : $page['layout'] = $page['layout'];
return $page;
@ -71,7 +73,7 @@ class PageRepository implements PageRepositoryInterface
public function delete($page)
{
return $this->editPage($page, $this->pages->where('uuid', $page->uuid)->first(), 'delete');
return $this->editPage($page, $this->content->loadAllPages()->where('uuid', $page->uuid)->first(), 'delete');
}
public function create($page)
@ -81,7 +83,7 @@ class PageRepository implements PageRepositoryInterface
public function update($page)
{
return $this->editPage($page, $this->pages->where('uuid', $page->uuid)->first(), 'update');
return $this->editPage($page, $this->content->loadAllPages()->where('uuid', $page->uuid)->first(), 'update');
}
public function getGroup($num, $limit, $sort = "all")

View file

@ -9,6 +9,9 @@ class AssetService
protected $themeTestImagePath;
protected $themeTestCSSPath;
protected $themeTestScriptsPath;
protected $themeCSSPath;
protected $themeImagePath;
protected $themeScriptsPath;
protected $themes;
protected $currentTheme;
@ -34,8 +37,8 @@ class AssetService
$imagePath = '';
$cssPath = '';
$scriptPath = '';
($live) ? $imagePath = $this->themeImagePath : $imagePath = $this->themeTestImagePath;
($live) ? $cssPath = $this->themeCSSPath : $cssPath = $this->themeTestCSSPath;
($live) ? $imagePath = $this->themeImagePath : $imagePath = $this->themeTestImagePath;
($live) ? $cssPath = $this->themeCSSPath : $cssPath = $this->themeTestCSSPath;
($live) ? $scriptPath = $this->themeScriptsPath : $scriptPath = $this->themeTestScriptsPath;
//get current theme
foreach (

View file

@ -31,6 +31,7 @@ class RenderService
public function publishAll()
{
$message = [];
$result = [];
$dynamicRender = $this->settings->getGlobal()['dynamicRender'];
if (isset($dynamicRender) && $dynamicRender === 'true') {
$message = [
@ -39,9 +40,14 @@ class RenderService
];
} else {
try {
$this->archive();
$this->tags();
$this->pages();
$result = $this->archive();
if ($result['status'] == 'archive_complete') {
$result = $this->tags();
if ($result['status'] == 'tags_complete') {
$this->pages();
}
}
$message = [
'message' => 'Site Rendered. GOOD EFFORT',
'type' => 'RENDER_SUCCESS',
@ -68,6 +74,12 @@ class RenderService
->with($pageData)
->render()
);
$done = [
'status' => 'archive_complete',
];
return $done;
}
public function tags()
@ -99,6 +111,14 @@ class RenderService
->render()
);
}
unset($data);
$done = [
'status' => 'tags_complete',
];
return $done;
}
public function pages()
@ -127,6 +147,7 @@ class RenderService
}
}
File::put($location, view($template)->with($pageData)->render());
unset($pageData);
}
}
}

View file

@ -17,9 +17,30 @@ class ContentService
{
protected $files = [];
protected $config = [];
protected $environment;
protected $converter;
protected $pageCount = "";
public function __construct()
{
//set up conversion handler
$this->environment = new Environment($this->config);
$this->environment->addExtension(new CommonMarkCoreExtension());
// Add the extension
$this->environment->addExtension(new FrontMatterExtension());
//Add Strikethrough rendering
$this->environment->addExtension(new StrikethroughExtension());
//add attributes to elements in markdown
$this->environment->addExtension(new AttributesExtension());
//add table rendering
$this->environment->addExtension(new TableExtension());
// Instantiate the converter engine and start converting some Markdown!
$this->converter = new MarkdownConverter($this->environment);
$this->loadPages(env('PAGES_PATH'));
}
@ -34,32 +55,16 @@ class ContentService
foreach ($files as $file) {
$this->files[] = $file;
}
$this->pageCount = count($this->files);
}
public function loadAllPages()
{
$environment = new Environment($this->config);
$environment->addExtension(new CommonMarkCoreExtension());
// Add the extension
$environment->addExtension(new FrontMatterExtension());
//Add Strikethrough rendering
$environment->addExtension(new StrikethroughExtension());
//add attributes to elements in markdown
$environment->addExtension(new AttributesExtension());
//add table rendering
$environment->addExtension(new TableExtension());
// Instantiate the converter engine and start converting some Markdown!
$converter = new MarkdownConverter($environment);
$contents = [];
foreach ($this->files as $file) {
//get meta and html from file
$result = $converter->convertToHtml(file_get_contents($file));
$result = $this->converter->convert(file_get_contents($file));
$meta = [];
if ($result instanceof RenderedContentWithFrontMatter) {
$meta = $result->getFrontMatter();
@ -87,6 +92,7 @@ class ContentService
$laundry = new HtmlSanitizer($soap);
$scrubbed = $laundry->sanitize($result->getContent());
unset($result);
if (isset($meta['feature'])) {
$featureList = explode(',', $meta['feature']);
} else {
@ -123,7 +129,6 @@ class ContentService
}
}
}
//sort attributes into page object
$page = [
'id' => $meta['id'],
@ -164,6 +169,8 @@ class ContentService
if (!$found) {
array_push($contents, $page);
}
unset($file);
gc_collect_cycles();
}
$collection = collect($contents);
$sorted = $collection->sortBy([

666
composer.lock generated

File diff suppressed because it is too large Load diff