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

Unable to distribute simulation batches #1939

Open
kelvin-olaiya opened this issue Feb 7, 2023 · 11 comments
Open

Unable to distribute simulation batches #1939

kelvin-olaiya opened this issue Feb 7, 2023 · 11 comments

Comments

@kelvin-olaiya
Copy link
Contributor

kelvin-olaiya commented Feb 7, 2023

I had a look at the current state of the alchemist-grid module.
I've problems in trying to distribute batches on a single node cluster (aka, the cluster is my laptop).

What i did was:

  1. Start Alchemist in server mode. After reading the Apache Ignite documentation, I understand that i need to provide a configuration file with Alchemist -s CLI option. This is the configuration file i used:
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="workDirectory" value="/home/kelvin/Development/ignite"/>
    </bean>
</beans>
  1. Launch Alchemist in distributed batch mode, providing the same configuration file to the -d cli option. (Distributed simulation)

Trying doing the latter results in errors that seem to have to do with serialization. Here you can see the error log.

@DanySK
Copy link
Member

DanySK commented Feb 7, 2023

Apparently an object is not serializable: how does Ignite serialize?

@kelvin-olaiya
Copy link
Contributor Author

As far I underdand, it uses it's Binary Marshaller

@DanySK
Copy link
Member

DanySK commented Feb 7, 2023

Can you deepen the reason why it does refuse to serialize? It looks like it's failing at serializing Kotlin's lambda expressions - maybe we can program it?

@kelvin-olaiya
Copy link
Contributor Author

Ok, I'll try to debug

@kelvin-olaiya
Copy link
Contributor Author

Most of the serialization exceptions seem to origin from classes whose fields in some ways end up dealing with org.danilopianini.jirf.FunctionEdge. I guess the problem may be that it does not implement Serializable.

Other classes with similar issue are:

  • org.danilopianini.jirf.FactoryImpl
  • it.unibo.alchemist.loader.m2m.Context
  • org.jgrapht.graph.DefaultDirectedGraph (although this one extends a class who does implement Serializable)
  • it.unibo.alchemist.loader.m2m.SimulationModel$fromMap$3

And then there's another kind of exception regarding which I could not find so many information.

java.lang.UnsupportedOperationException: can't get field offset on a hidden class: private final kotlin.jvm.functions.Function1 it.unibo.alchemist.loader.m2m.ObjectFactory$$Lambda$145/0x0000000801176228.arg$1

@DanySK
Copy link
Member

DanySK commented Feb 8, 2023

Okay, we must change the way we serialize, then, it's too much stuff to make Serializable. Also, it may be the case that Ignite internally does not use the Java serialization (and would be right in doing so).
We should send away only the environment, and the environment should not bring a Java Implicit Reflective Factory within, nor the YAML-to-Alchemist model-to-model stuff.

I think that the "strange thing" you see is a Kotlin default argument value.

@kelvin-olaiya
Copy link
Contributor Author

I tried to avoid sending away the Loader by making the field in which it is stored transient and store in each RemoteSimulation an InitializedEnvironment. Most of the previous exceptions are gone, but now there's a problem with the serialization of classes with companion objects. Here's the error log.

@DanySK
Copy link
Member

DanySK commented Feb 13, 2023

Can we replace the serializer of ignite with something else?

@kelvin-olaiya
Copy link
Contributor Author

kelvin-olaiya commented Feb 13, 2023

Yes, there's a method to set a (i believe custom) Marshaller but, it is deprecated:

Deprecated. Since 2.1. Some Ignite features will not work if non-null marshaller is set (IgniteCache.withKeepBinary(), .NET, CPP, ODBC)
Sets marshaller to use within grid.

Javadoc

@kelvin-olaiya
Copy link
Contributor Author

Okay, we must change the way we serialize, then, it's too much stuff to make Serializable. Also, it may be the case that Ignite internally does not use the Java serialization (and would be right in doing so). We should send away only the environment, and the environment should not bring a Java Implicit Reflective Factory within, nor the YAML-to-Alchemist model-to-model stuff.

@DanySK I'm working on the distribution of simulations, still having issues with serialization. I'm avoiding using the default Java serialization by using protocol buffers. The doubt that I now have is: to be able to serialize any Environment and/or Exporter (contained in an InitializedEnvironment) using protobuf, or any other framework, I should define a custom serializer for every specific implementation, right? (It seems to me like it would take a lot of effort, I want to be sure I'm not taking the wrong path).

@DanySK
Copy link
Member

DanySK commented Aug 31, 2023

I think that you should have your custom exporter and throw errors if any other is being used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants