Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3% speedup with LazyMap and MetadataStorage #8359

Merged
merged 18 commits into from
Nov 27, 2023
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cd5e645
Make java.util.Map lazy. Try to make immutable Scala map lazy.
JaroslavTulach Nov 21, 2023
d7f9af5
Attempt to create immutable map delegate
JaroslavTulach Nov 22, 2023
f9c34a9
Fix the proxy map to be immutable and lazy
hubertp Nov 22, 2023
f428331
Hexadecimal version looks more professional
JaroslavTulach Nov 23, 2023
3ca2d66
Support serialization of singletons
JaroslavTulach Nov 23, 2023
af04b8e
Generate @Override annotation
JaroslavTulach Nov 23, 2023
228a03f
Read MetadataStorage lazily
JaroslavTulach Nov 23, 2023
cac8910
Enough to use constructor
JaroslavTulach Nov 23, 2023
b8d5efd
Drop caches and reparse when deserialization of BindingsMap yields an…
JaroslavTulach Nov 23, 2023
d8148c1
Avoid deprecated method
JaroslavTulach Nov 23, 2023
cd6c0c6
Let getBindingsMap() recover from cache loading errors
JaroslavTulach Nov 23, 2023
826dcee
SerializerTest needs FullyQualifiedNames serialization
JaroslavTulach Nov 23, 2023
ca5c256
Reverting cd6c0c6e4689c374aecacda52e329ce0557a0e51 as it causes failu…
JaroslavTulach Nov 23, 2023
8bd6adc
More robust ImportResolver
JaroslavTulach Nov 24, 2023
68e057f
Display error when the execution isn't Success
JaroslavTulach Nov 24, 2023
1b3db21
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Benchm…
JaroslavTulach Nov 25, 2023
44b37c7
Benchmark on files that are already prepared in the repository
JaroslavTulach Nov 25, 2023
868793a
Merge remote-tracking branch 'origin/wip/jtulach/BenchmarkStartup_832…
JaroslavTulach Nov 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reverting cd6c0c6 as it causes failure in CacheInvalidationTest
  • Loading branch information
JaroslavTulach committed Nov 23, 2023
commit ca5c2560f8a78f9aa8e1266364708ccf5fcf3e2b
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package org.enso.compiler.phase

import org.enso.compiler.Compiler
import org.enso.compiler.context.CompilerContext.Module
import org.enso.compiler.core.Implicits.AsMetadata
import org.enso.compiler.core.ir.{Module => IRModule}
import org.enso.compiler.core.ir.Name
import org.enso.compiler.core.ir.expression.errors
@@ -15,9 +16,11 @@ import org.enso.compiler.data.BindingsMap.{
Type
}
import org.enso.compiler.core.CompilerError
import org.enso.compiler.pass.analyse.BindingAnalysis
import org.enso.editions.LibraryName
import org.enso.polyglot.CompilationStage
import scala.collection.mutable
import java.io.IOException

/** Runs imports resolution. Starts from a given module and then recursively
* collects all modules that are reachable from it.
@@ -44,9 +47,28 @@ class ImportResolver(compiler: Compiler) {
): (List[Module], List[Module]) = {

def analyzeModule(current: Module): List[Module] = {
val context = compiler.context
val ir = context.getIr(current)
val currentLocal = current.getBindingsMap()
val context = compiler.context
val (ir, currentLocal) =
try {
val ir = context.getIr(current)
val currentLocal = ir.unsafeGetMetadata(
BindingAnalysis,
"Non-parsed module used in ImportResolver"
)
(ir, currentLocal)
} catch {
case _: IOException =>
context.updateModule(
current,
u => {
u.ir(null)
u.compilationStage(CompilationStage.INITIAL)
u.invalidateCache()
}
)
compiler.ensureParsed(current)
return analyzeModule(current)
}
// put the list of resolved imports in the module metadata
if (
context
Original file line number Diff line number Diff line change
@@ -374,20 +374,9 @@ public QualifiedName getName() {
@Override
public BindingsMap getBindingsMap() {
if (module.getIr() != null) {
for (;;) {
try {
var meta = module.getIr().passData();
var pass = meta.get(BindingAnalysis$.MODULE$);
emitIOException();
return (BindingsMap) pass.get();
} catch (IOException ex) {
module.unsafeSetIr(null);
module.unsafeSetCompilationStage(CompilationStage.INITIAL);
var context = EnsoContext.get(null);
module.getCache().invalidate(context);
context.getCompiler().ensureParsed(this);
}
}
var meta = module.getIr().passData();
var pass = meta.get(BindingAnalysis$.MODULE$);
return (BindingsMap) pass.get();
} else {
return bindings;
}
@@ -458,7 +447,4 @@ public String toString() {
return sb.toString();
}
}

private static void emitIOException() throws IOException {
}
}