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
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,21 @@ class ImportResolver(compiler: Compiler) {
val mod = name.parts.dropRight(1).map(_.name).mkString(".")
compiler.getModule(mod).flatMap { mod =>
compiler.ensureParsed(mod)
mod
.getBindingsMap()
.definedEntities
var b = mod.getBindingsMap()
if (b == null) {
compiler.context.updateModule(
mod,
{ u =>
u.invalidateCache()
u.ir(null)
u.compilationStage(CompilationStage.INITIAL)
}
)
compiler.ensureParsed(mod)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reparse without caching when lazy deserialization fails.

b = mod.getBindingsMap()
}

b.definedEntities
.find(_.name == tp)
.collect { case t: Type =>
ResolvedType(ModuleReference.Concrete(mod), t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.enso.pkg.Package;
import org.enso.pkg.QualifiedName;
import org.enso.polyglot.CompilationStage;
import org.enso.polyglot.LanguageInfo;
import org.enso.polyglot.data.TypeGraph;

import com.oracle.truffle.api.TruffleFile;
Expand Down Expand Up @@ -374,12 +375,19 @@ public QualifiedName getName() {
@Override
public BindingsMap getBindingsMap() {
if (module.getIr() != null) {
var meta = module.getIr().passData();
var pass = meta.get(BindingAnalysis$.MODULE$);
return (BindingsMap) pass.get();
} else {
return bindings;
try {
var meta = module.getIr().passData();
var pass = meta.get(BindingAnalysis$.MODULE$);
emitIOException();
return (BindingsMap) pass.get();
} catch (IOException ex) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lazy deserialization of BindingsMap may fail: https://github.com/enso-org/enso/actions/runs/6974085571/job/18979188994?pr=8359#step:10:1073 - don't propagate the IOException further.

var logger = TruffleLogger.getLogger(LanguageInfo.ID, org.enso.interpreter.runtime.Module.class);
var msg = "Cannot read BindingsMap for " + getName() + ": " + ex.getMessage();
logger.log(Level.SEVERE, msg);
logger.log(Level.FINE, msg, ex);
}
}
return bindings;
}

@Override
Expand Down Expand Up @@ -447,4 +455,7 @@ public String toString() {
return sb.toString();
}
}

private static void emitIOException() throws IOException {
}
}
Loading