Happened today on Vox Codei, when launching IDE test case:
ERROR: ld.so: object ‘/usr/lib/coreutils/libstdbuf.so’ from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Then got a timeout.
Happened today on Vox Codei, when launching IDE test case:
ERROR: ld.so: object ‘/usr/lib/coreutils/libstdbuf.so’ from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Then got a timeout.
u can call GC.collect() by yourself
I sure can, but this action can take up to dozens of MS, that makes your program timeout.
I decided to print out JVM options from the running code of the Smash the code AI puzzle (not the contest) and got this:
-Xmx512m, -Xms32m, -Xss128k
The available max memory seems different from what is written on this page: https://www.codingame.com/faq
Also it seems like there is place for improvement of GC parameters but until then - initializing a huge memory buffer as suggested by Neumann seems reasonable.
Hey.
I have some kind of performance issues (or maybe just broken code): I have a class ‘GameState’ which can be deeply cloned.
On my local PC which runs hardcore VM I can do about 15-20k calls to clone()/ms (inside VM) while on CG’s servers I can barely do 1500 .clones()/ms. (which is 10 times slower)
I am looking for advice on possible solutions (which can speed up my cloning by 10x) or any info that can lead me there and also I am curious about real environment used for sandboxing.
Is there a memory access patterns that I should avoid? Or any hints about memry management that are useful to know?
@MaximeC @SaiksyApo can you share some info about sandbox env?
The definition of those params being:
-Xms set initial Java heap size
-Xmx set maximum Java heap size
-Xss set java thread stack size
Is the “place for improvement” you mentionned located in the big difference between 32 (initial) and 512 (max) ?
The point in initializing a huge memory buffer would be to raise the heap size close to the 512 right from the beginning ?
Any advice how to best perform this init ?
Yes, the easiest place of improvement is to increase Xms, see below why.
Yes, by initializing a huge memory from the start you’re telling the JVM that you actually need more memory so it is supposed to readjust its default GC settings. You can find a hint how to do this by reading Neumann comment #4 above.
To test how JVM settings affect performance I created a dummy test based on a skeleton of Smash the code contest solution which follows a pattern suitable for most of the multiplayer contest - specifically there are some global state objects which should never be GCed (usually their number is very small) and a huge amount of objects which are generated in the game loop which are not supposed to live long and should be GCed very quickly. The test runs for 3 minutes - a typical max game time
Here’s my test class
public class JVMTest { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); in.nextLine(); SimulatorMetric simulatorMetric = new SimulatorMetric(); List<Block> globalState = new ArrayList<>(); initGlobalState(globalState); long start = System.currentTimeMillis(); long end = start + 3 * 60 * 1000; long acceptedDelay = 100L; long iterationMaxRun = 93L; long startIteration; while ((startIteration = System.currentTimeMillis()) < end) { long endIteration = startIteration + iterationMaxRun; Board board = readBoard(); simulatorMetric.simulateBoard(board, endIteration); if (System.currentTimeMillis() > startIteration + acceptedDelay) { throw new RuntimeException("Unexpected delay found after"); } waitOpponentMove(); } System.out.println("Min iterations simulated per run: " + simulatorMetric.minIterations); System.out.println("Max iterations simulated per run: " + simulatorMetric.maxIterations); System.out.println("Average iterations per all runs: " + simulatorMetric.avgIterations); } private static void initGlobalState(List<Block> globalState) { for (int i = 0; i < 200; i++) { globalState.add(new Block()); } } private static Board readBoard() { return new Board(); } private static void waitOpponentMove() throws InterruptedException { Thread.sleep(100L); } private static class Board { private Block[][] grid = new Block[12][6]; public Board() { for (int i = 0; i < 12; i++) { for (int j = 0; j < 6; j++) { grid[i][j] = new Block(); } } } public void addBlock(Block block) { } } private static class Block { private long row; private long column; private long color; } private static class SimulatorMetric { private long minIterations = Long.MAX_VALUE; private long maxIterations = 0L; private long avgIterations = 0L; private long numberOfCalls = 0L; private void simulateBoard(Board board, long endTime) { long iterations = 0L; while (System.currentTimeMillis() < endTime) { board.addBlock(new Block()); iterations++; } if (iterations < minIterations) { minIterations = iterations; } if (iterations > maxIterations) { maxIterations = iterations; } numberOfCalls++; avgIterations = (avgIterations * (numberOfCalls - 1) + iterations) / numberOfCalls; } } }
And here are the results I got
Results of one test:
Min iterations simulated per run: 2267946
Max iterations simulated per run: 4463943
Average iterations per all runs: 3303737
Results of one test:
Min iterations simulated per run: 2296191
Max iterations simulated per run: 4457412
Average iterations per all runs: 3310138
Results of one test:
Min iterations simulated per run: 2354515
Max iterations simulated per run: 4492568
Average iterations per all runs: 3292464
Results of one test:
Min iterations simulated per run: 1322192 (must be due to the time when 30-40ms GC kicked in)
Max iterations simulated per run: 4488003
Average iterations per all runs: 3312208
Results of one test:
Min iterations simulated per run: 1719210
Max iterations simulated per run: 5230574
Average iterations per all runs: 3452837
Results of one test:
Min iterations simulated per run: 2699521
Max iterations simulated per run: 4490146
Average iterations per all runs: 3325435
Conclusions:
I also had this problems multiple times today … always on init before my first turn startet …
[quote]ERROR: ld.so: object ‘/usr/lib/coreutils/libstdbuf.so’ from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread
[/quote]
i.e.
That is a different problem, most likely caused by a bug in their virtual platforms. It only happens in the IDE though, so that’s not a big deal.
the replays i posted are ranking games …
I got one today @MaximeC, but this time it was a normal play action in Tron not a ranking game
if it happens again i’ll add a replay here
@MaximeC got another OutOfMemory
ERROR: ld.so: object ‘/usr/lib/coreutils/libstdbuf.so’ from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread
And another replay for @MaximeC
ERROR: ld.so: object ‘/usr/lib/coreutils/libstdbuf.so’ from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread
Just got something sounding similar but not the same
ERROR: ld.so: object ‘/usr/lib/coreutils/libstdbuf.so’ from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Error occurred during initialization of VM
Cannot create VM thread. Out of system resources.
Me too i usually encounter this problem.
ERROR: ld.so: object ‘/usr/lib/coreutils/libstdbuf.so’ from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at java.lang.ref.Finalizer.(Finalizer.java:226)
It seems to appear also on server when we submit our code. In codebusters multiplayer game i lose some games where my busters never move. I do not think it’s a timeout as i can’t reproduce in the IDE.
In code of rings game i have to submit 3-4 times before all tests pass.
This bug is really annoying as we lose some time and possibly ranks in multiplayer games.
I confirm the bug. A quick fix is to restart the faulty servers but that’s only temporary. We’re currently working on a long term fix ;).
Ok then i stop my reports until you tell us here that you have fixed it