Skip to content

Commit

Permalink
Introduce hash seed to invaldiate caches (enso-org#9082)
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertp authored Feb 16, 2024
1 parent 642d5a6 commit fe0f904
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
4 changes: 4 additions & 0 deletions docs/runtime/ir-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ Every `Persistance` class has a unique identifier. In order to keep definitions
consistent one should not attempt to use smaller `id`s than previously assigned.
One should also not delete any `Persistance` classes.

Additionally, `PerMap.serialVersionUID` version provides a seed to the version
stamp calculated from all `Persistance` classes. Increasing the
`serialVersionUID` will invalidate all caches.

## Loading the IR

Loading the IR is a multi-stage process that involves performing integrity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ import scala.annotation.unused
* @param definedEntities the list of entities defined in the current module
* @param currentModule the module holding these bindings
*/

@SerialVersionUID(
9057L // Use BindingsMap
)
case class BindingsMap(
definedEntities: List[DefinedEntity],
currentModule: ModuleReference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.enso.compiler.core;

import java.io.Serializable;
import java.util.UUID;
import java.util.function.Function;
import org.enso.compiler.core.ir.DiagnosticStorage;
Expand Down Expand Up @@ -28,9 +27,7 @@
*
* <p>See also: Note [IR Equality and hashing]
*/
public interface IR extends Serializable {

long serialVersionUID = 9057L; // Scala to Java
public interface IR {

/**
* Storage for metadata that the node has been tagged with as the result of various compiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import java.util.UUID
* @param passData the pass metadata associated with this node
* @param diagnostics compiler diagnostics for this node
*/
@SerialVersionUID(
9057L // Use BindingsMap
) // prevents reading broken caches, see PR-3692 for details
final case class Module(
imports: List[Import],
exports: List[Export],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.openide.util.lookup.Lookups;

final class PerMap {

private static final int serialVersionUID = 8689; // Use PR number
private static final Collection<? extends Persistance> ALL;

static {
Expand All @@ -20,7 +22,7 @@ final class PerMap {
final int versionStamp;

private PerMap() {
int hash = 0;
int hash = serialVersionUID;
for (var orig : ALL) {
var p = orig.newClone();
var prevId = ids.put(p.id, p);
Expand Down

0 comments on commit fe0f904

Please sign in to comment.