GithubHelp home page GithubHelp logo

Performance about flix HOT 9 CLOSED

flix avatar flix commented on May 20, 2024
Performance

from flix.

Comments (9)

magnus-madsen avatar magnus-madsen commented on May 20, 2024

The new plan is not to do A normal form, since the JVM bytecode is stack based, and that is easier to generate straight from an AST.

I am going to be creating and moving some more complete programs, to experiment on, into the examples/domains/ folder.

These should make for good compilation targets.

from flix.

magnus-madsen avatar magnus-madsen commented on May 20, 2024

I want to give a few pointers on what I think is important for the CodeGen:

  1. Attach debug information (e.g. filename, line no, col no) to generated class(es). This will be immensely useful for debugging and profiling.
  2. Don't worry about the performance of the CodeGenerator. Use all available help facilities from ASM5. This includes letting it calculate max variables and frames, but also running with all the checkers.
  3. Focus on generating the code. We will figure out how to execute it later. Probably we will decorate one of our ASTs with references to the code loaded via reflection. You should still be able to write tests though. Just write a simple wrapper around a class loader.
  4. If longs are too troublesome, then you can start with Ints. I will leave this choice to you. Ultimately we probably have Longs, or both Int and Longs.
  5. Use the CodeGenIR AST and modified it to have what you need. Once you have a reasonable implementation, we can write a simple translation from TypedAst to it. (For a subset of expressions at first).

Less important, but "nice-to-have" in the future:

  1. Instead of generating one class with names like Belnap$Leq, we should map the Flix namespaces to Java packages, so A::B::C::Leq would create packages A and B, with class C and method Leq on C.

from flix.

magnus-madsen avatar magnus-madsen commented on May 20, 2024

Oh, and I forgot, and this is important:

Make sure the CodeGen is functional. Thus, I think it is better to explicitly pass around the Class/Method visitors. Unless you see a strong reason not to.

from flix.

mhyee avatar mhyee commented on May 20, 2024

Don't worry about the performance of the CodeGenerator. Use all available help facilities from ASM5. This includes letting it calculate max variables and frames, but also running with all the checkers.

I'll need to look into this (maybe later), but it seems that the stack and frame computation runs after the CheckClassAdapter. So I have to put large bogus numbers (and hope they're large enough) to ensure the CheckClassAdapter doesn't crash. These bogus numbers are then overwritten by the actual numbers.

Make sure the CodeGen is functional. Thus, I think it is better to explicitly pass around the Class/Method visitors. Unless you see a strong reason not to.

I don't see a reason not to, but I'm curious, what's the reason for explicitly passing the visitors around?

from flix.

magnus-madsen avatar magnus-madsen commented on May 20, 2024

I don't see a reason not to, but I'm curious, what's the reason for explicitly passing the visitors around?

Mostly to ensure that Flix can be instantiated multiple times in the same JVM, and in the future to ensure that we can even run the same Flix instance in parallel. Thus staying as close as possible to functional programming is preferable.

from flix.

magnus-madsen avatar magnus-madsen commented on May 20, 2024

I think we will have the following (backend) IRs:

  • SimplifiedIR - The TypedAst with match, switch, and other high-level constructs eliminated. Variables are numbered etc.
  • ReducedIR - The SimplifiedIR with partial evaluation applied. E.g. constant expressions are folded. Functions may be inlined, etc. The compiler will generate code from this IR.
  • ExecutableIR - The only mutable AST/IR. Decorated with the code generator from the compiler. (We can make it so that if a function was not compiled, then it is interpreted. I think that would be nice). This IR uses arrays, mutable var's that hold references to IndexedRelation and IndexedStore. Rules may hold mutable cost and queries plans, etc. etc. The same ExecutableIR cannot be evaluated twice.

from flix.

magnus-madsen avatar magnus-madsen commented on May 20, 2024

(Note to self: Where are the data types packed? In the ReducedIR or in a separate IR?)

from flix.

magnus-madsen avatar magnus-madsen commented on May 20, 2024

I think we can get rid of ReducedIR. At least for now. Instead we should just merge ReducedIR and SimplifiedIR into one thing.

We will still have ExecutableIR though, which should be the output of the CodeGen phase.

Lets make this change together.

from flix.

mhyee avatar mhyee commented on May 20, 2024

Closing this and opening fine-grained issues instead.

from flix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.