prosyslab-classroom / is593-language-based-security

28 stars 6 forks source link

[HW6] How can I make the top-down algorithm faster? #41

Closed KunJeong closed 4 years ago

KunJeong commented 4 years ago

Hi. My current top-down algorithm finds a solution at 6 mins 30 secs for example3, which doesn't feel like a "safe" time, since we should terminate in 10 mins for all test cases. This feels especially long compared to bottom-up, which takes under three seconds for every case.

I've tried various pruning/optimization techniques, such as 1) restricting the grammar in the unrolling stage, 2) creating a "simplifying" algorithm to simplify the program before checking equivalence / adding to the queue, 3) depth comparisons to "balance" unrolling, 4) changing most of the code and API calls to be tail-recursive as well as 5) the basic equivalence checking for various mathematically equivalent structures. However, more sophisticated algorithms don't help the execution time very much, they often increase the time instead because of the added complexity.

Could you give some tips on how to shorten the execution time (which optimizations to focus on, which to ignore, etc.)? Would it be better to focus on improving the equivalence checking instead of trying these new approaches, like the original algorithm from the slides? Or are there other pruning techniques that I should explore?

Also, I'm curious about the bottom-up algorithm being so much faster, and whether it is possible to achieve such an execution time with the top-down algorithm.

Thank you.

KihongHeo commented 4 years ago

Hi. Amazing. You are like making an optimizing compiler. I should definitely run a competition for this from next year's lecture.

Because implementing all such pruning techniques is also a part of this homework, here I will just give very low-level or very high-level. If needed we can discuss more in this thread.

In general, bottom-up and top-down are incomparable (no one completely outperforms the other). But in our homework, bottom-up may be much faster, because 1) program size is very small, and 2) currently we don't consider very powerful pruning/searching techniques for the top-down much, such as

If you are interested in, you can visit the Sygus competition (https://sygus.org), an annual program synthesis competition.

KihongHeo commented 4 years ago

FYI, my top-down synthesizer takes 92 sec on our lab server (Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz)

hyunsikjeong commented 4 years ago

I implemented my own normalization and memoization method like mentioned above, then added a simple algorithm to remove redundant cases. Currently I got 1m 4s on my personal computer (Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz), and 1m 14s on the class VM. 😃

I think both of them helps a lot in improving speed, thank you professor.

KihongHeo commented 4 years ago

@jhs7jhs Amazing news!

Anyone who can beat Hyunsik's performance, let us know. Very interesting to see that.

KunJeong commented 4 years ago

@KihongHeo I thought I had hit a wall with 90~100s on my local machine, but checking on VM gives me 58s... guess I should have worked on VM from the beginning 😅 This homework is way too fun.

Medowhill commented 4 years ago

My synthesizer with a top-down algorithm requires 0.097 seconds for example3 on the provided VM.

KunJeong commented 4 years ago

@Medowhill wow..unbelievable. Could you share some insights, maybe after the due date?

Medowhill commented 4 years ago

Sure, I'll be very glad to do so.

KihongHeo commented 4 years ago

Amazing result! I am very happy to hear that. It would be awesome to have an "invited talk" by the winner, but we don't have a time slot.

Jaemin, can you share your experience with other students on the KLMS board after the deadline? I want to make this Github board public after the semester. So, this board may not be a good choice for next semester.

tomtomjhj commented 4 years ago

I'm getting 0.06s. In my case, a simple technique not mentioned in this thread resulted in a huge performance boost.

KihongHeo commented 4 years ago

Very good to hear that.

I hope many students join the "<0.1" club!

Medowhill commented 4 years ago

@KihongHeo Alright. It would be nice if anyone who wants to share one's strategy writes a post on KLMS after the due date.

hyunsikjeong commented 4 years ago

Students can submit the homework after the deadline with score deduction. It should be three days after the deadline day. I'm not trying to improve mine because it seems safe to get full score (😅) and I have other homeworks/projects/jobs to do, but still interested in this topic.

KihongHeo commented 4 years ago

Sounds good. It would be very interesting to see many idea from you folks.

For someone who needs more fun, I made an "adversarial" random program generator. It can randomly generate programs and csv files. You can see how far your synthesizer can go. I hope to hear more amazing news from you folks.

hyunsukimsokcho commented 4 years ago

0.03..

KihongHeo commented 4 years ago

Welcome aboard.