Skip to content

Commit

Permalink
remove StementsVolatileCache for perf reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Jun 19, 2023
1 parent 2e8d575 commit da8c1da
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 115 deletions.
14 changes: 1 addition & 13 deletions src/Psalm/Internal/Provider/StatementsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class StatementsProvider

private ?FileStorageCacheProvider $file_storage_cache_provider = null;

private StatementsVolatileCache $statements_volatile_cache;

/**
* @var array<string, array<string, bool>>
*/
Expand Down Expand Up @@ -97,7 +95,6 @@ public function __construct(
$this->parser_cache_provider = $parser_cache_provider;
$this->this_modified_time = filemtime(__FILE__);
$this->file_storage_cache_provider = $file_storage_cache_provider;
$this->statements_volatile_cache = StatementsVolatileCache::getInstance();
}

/**
Expand Down Expand Up @@ -132,20 +129,11 @@ public function getStatementsForFile(
if (!$this->parser_cache_provider
|| (!$config->isInProjectDirs($file_path) && strpos($file_path, 'vendor'))
) {
$cache_key = "{$file_content_hash}:{$analysis_php_version_id}";
if ($this->statements_volatile_cache->has($cache_key)) {
return $this->statements_volatile_cache->get($cache_key);
}

$progress->debug('Parsing ' . $file_path . "\n");

$has_errors = false;

$stmts = self::parseStatements($file_contents, $analysis_php_version_id, $has_errors, $file_path);

$this->statements_volatile_cache->set($cache_key, $stmts);

return $stmts;
return self::parseStatements($file_contents, $analysis_php_version_id, $has_errors, $file_path);
}

$stmts = $this->parser_cache_provider->loadStatementsFromCache(
Expand Down
100 changes: 0 additions & 100 deletions src/Psalm/Internal/Provider/StatementsVolatileCache.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/Psalm/Internal/RuntimeCaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Psalm\Internal\Provider\FileReferenceProvider;
use Psalm\Internal\Provider\FileStorageProvider;
use Psalm\Internal\Provider\StatementsProvider;
use Psalm\Internal\Provider\StatementsVolatileCache;
use Psalm\Internal\Scanner\ParsedDocblock;
use Psalm\Internal\Type\TypeTokenizer;
use Psalm\IssueBuffer;
Expand Down Expand Up @@ -42,6 +41,5 @@ public static function clearAll(): void
StatementsProvider::clearLexer();
StatementsProvider::clearParser();
ParsedDocblock::resetNewlineBetweenAnnotations();
StatementsVolatileCache::getInstance()->clearCache();
}
}

0 comments on commit da8c1da

Please sign in to comment.