Skip to content

Commit 705a8ab

Browse files
clean up readme
1 parent 4a82199 commit 705a8ab

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

README.md

+42-22
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
1-
To run normally:
1+
# Serverless Online Judge (Rust)
2+
3+
From the Competitive Programming Initiative. A successor to https://github.com/cpinitiative/online-judge.
4+
5+
## Goal
6+
7+
To create a low-cost, reliable, and fast online judge that:
8+
9+
- Supports C++, Java, Python, and possibly other languages
10+
- Can be used to run code against many test cases in parallel
11+
- Can be extended to support graders, scorers, and interactive problems
12+
13+
Notably, the following are not goals of this project:
14+
15+
- *Is not necessarily consistent*. This is because AWS Lambda can run on different CPU architectures. Since USACO problems generally aren't too sensitive to time constraints, we are OK with this.
16+
- *Is not necessarily secure*. Malicious code will not harm other AWS resources, but could theoretically return falsified results.
17+
18+
This online judge is meant to be used with the USACO Guide IDE or USACO Guide Groups, so the experience is optimized to make honest users happy most of the time rather than catch malicious users (i.e. we would rather grade problems faster even if that means malicious users can access expected output).
19+
20+
## Development
21+
22+
Install Rust, Cargo, and project depenencies.
23+
24+
### Running in development
225

326
```
427
cargo lambda watch
528
```
629

730
And POST `http://localhost:9000/compile-and-execute`.
831

9-
To test base docker image (useful for determining what packages need to be installed)
32+
### Deploying
33+
34+
Continuous deployment is set up with Github Actions; all you need to do is push to main.
35+
36+
### Miscellaneous Commands
37+
38+
39+
To test base docker image (useful for determining what packages need to be installed):
1040

1141
```
1242
docker run --rm -it --platform linux/amd64 --entrypoint /bin/bash public.ecr.aws/lambda/python:3.12
1343
```
1444

15-
To build and test dockerfile locally
45+
To build and test dockerfile locally:
1646

1747
```
1848
cargo lambda build
@@ -28,7 +58,7 @@ curl "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
2858
# to get format for ^: https://github.com/brefphp/local-api-gateway/blob/main/src/apiGateway.ts
2959
```
3060

31-
To upload to ECR
61+
To upload to ECR:
3262

3363
```
3464
# Login to AWS ECR
@@ -47,14 +77,9 @@ To deploy lambda for the first time:
4777
- Set timeout to 30 seconds
4878
- Set memory to 1769 MB (1 vCPU)
4979

80+
### Todo
5081

51-
---
52-
53-
file stuff: relaxed permissions
54-
55-
---
56-
57-
Todo: Note that there are actually two CPUs -- AMD and Intel -- so timings are not consistent. With this, I saw 1.93 and also 1.30:
82+
Note that there are actually two CPUs -- AMD and Intel -- so timings are not consistent. With this, I saw 1.93 and also 1.30:
5883

5984
```
6085
double x; cin >> x; int y = x; for (int i = 0; i < y; i++) x += sqrt(x); cout << x << endl;
@@ -83,32 +108,27 @@ double x; cin >> x; int y = x; for (int i = 0; i < y; i++) x += sqrt(x); cout <<
83108

84109
Should benchmark this to determine how off the timings are / whether we can just add a multiplicative factor to it.
85110

86-
---
87111

88-
misc todos
112+
We can also get improved error messages. This is an example of what Leetcode tells you:
89113

90-
```
91114

92-
// want smth like
115+
```
93116
/*
94117
Line 15: Char 8: runtime error: signed integer overflow: 2147483647 + 2147483647 cannot be represented in type 'int' (solution.cpp)
95118
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior solution.cpp:15:8
96119
*/
97-
// which is what leetcode gives you
98120
```
99121

100-
Better logging: https://docs.aws.amazon.com/lambda/latest/dg/rust-logging.html
122+
We should have better logging: https://docs.aws.amazon.com/lambda/latest/dg/rust-logging.html
101123

102-
utf8 encoding regression test:
124+
We should add tests. Here's an utf8 encoding regression test:
103125

104126
```
105-
// Source: https://usaco.guide/general/io
106-
107-
#include <bits/stdc++.h>
127+
#include <iostream>
108128
using namespace std;
109129
110130
int main() {
111131
char c = 128;
112-
cout << c << endl;
132+
cout << c << endl; // this shouldn't crash the lambda funciton
113133
}
114134
```

0 commit comments

Comments
 (0)