Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Status of Riven's LibStruct?  (Read 3739 times)
0 Members and 1 Guest are viewing this topic.
Offline Frizzil

Senior Newbie


Medals: 4



« Posted 2016-08-13 20:09:15 »

Does anyone know the current status or details of Riven's "LibStruct" project? (github: https://github.com/riven8192/LibStruct, original forum post: http://www.java-gaming.org/index.php?;topic=34282.0)

Obviously it hasn't been updated in a while, but I would LOVE to integrate this or something similar into my current project. A reply from him himself would be miraculous... (unfortunately PMing appears to be broken atm.)

Specifically, I'm wondering if there are any major caveats as to why I wouldn't use this in Java 8. For larger classes I could see issues, but for simple vector-like objects this would make my life so, SO much easier. Naturally, I'm not really able to wait 2-4 years for Project Valhalla to be released (http://openjdk.java.net/projects/valhalla/). Otherwise, my use cases are: small vector-like objects, and uniform-buffer updates in OpenGL 3+, for which this seems absolutely perfect.

This is, of course, for a game being developed semi-professionally in Java. (Demo: https://youtu.be/dInNbVjta5M) If Riven happens across this, I would love to get in touch with him!

Offline Roquen

JGO Kernel


Medals: 518



« Reply #1 - Posted 2016-08-13 20:54:18 »

I'd say you're chances of him running across this post are quite high (probability approaching 1).
Offline NegativeZero

JGO Kernel


Medals: 357
Exp: 1 month or less


Zero but not.


« Reply #2 - Posted 2016-08-13 21:44:34 »


Good luck with the cancer treatments!
Your engine is very, very pretty!

It's worth noting that Riven in the owner/admin of JGO so it's very likely that he'll come across your post at some point.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Frizzil

Senior Newbie


Medals: 4



« Reply #3 - Posted 2016-08-14 02:52:08 »

Good luck with the cancer treatments!

Ah crap, I forgot I talked about that in the video, haha. Yeah, chemo ended a few months back, scan recently came back clean, so no worries. But thanks!
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2016-08-14 17:12:59 »

persecutioncomplex

LibStruct basically has these advantages:
 - zero-copy
 - zero-garbage
 - convenience (on sourcecode level)

The disadvantages are:
 - struct values are never pushed into registers by HotSpot
 - structs are not eligible for escape analysis
 - struct I/O is never reordered by HotSpot

There are quite a few pitfalls when using LibStruct:
 - a NPE or AIOOBE turns into a segfault/memory-access-violation
 - structs must never be used as objects (like adding them to a Collection, or in general: passing them to a function accepting a java.lang.Object)
 - conceptually wrong struct code but valid Java code can be rather hard to debug, as the JVM typically crashes.



As to come back to the original post: LibStruct is currently frozen, as the number of users is zero (me included).

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Frizzil

Senior Newbie


Medals: 4



« Reply #5 - Posted 2016-08-14 20:00:54 »

I see, well thank you for the insight. I'm basically trying to avoid young-gen-worthy allocations so the GC doesn't invoke, so I think this would do nicely. I may also look into tuning young-gen, but my research on the subject has not convinced me that I can get it reasonably fast (< 2-3 ms).

When you say structs don't get pushed into registers, do you mean that even the individual fields don't get pushed? I assumed that declaring a struct was semantically equivalent to declaring all of its fields in place. Otherwise, I have no expectations of this pushing entire structs into SIMD registers or anything. (Bytecode has no way of representing this, to my knowledge.)

I'm guessing the best way to support OpenGL uniform buffer updates would be to "map" ByteBuffers as the desired structs, purely for the purpose of setting named fields?

Thanks for the hasty response. I get that LibStruct is inherently, er, risky, but I'm amazed that it even exists. I wonder how the folks working Project Valhalla would react if they knew about your library Smiley

EDIT: Also, an amazing idea occurred to me... I'm betting a Minecraft mod that utilized your library could solve a massive amount of the game's performance problems. It'd be a good stability test (lots of users), to see how viable the library is in a production environment.
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2016-08-14 22:10:42 »

When you say structs don't get pushed into registers, do you mean that even the individual fields don't get pushed? I assumed that declaring a struct was semantically equivalent to declaring all of its fields in place. Otherwise, I have no expectations of this pushing entire structs into SIMD registers or anything. (Bytecode has no way of representing this, to my knowledge.)

Let's say  you have this code:
1  
2  
3  
thing.a = vec.x * -1;
thing.b = vec.y * 2;
thing.c = vec.x * -3;


With POJOs,
vec.x
will be stored into a register after the first read, with structs however, the memory (or L1-cache in this case) will be read twice.

As for the reordering: with POJOs, HotSpot will very likely swap line 2 and 3, whereas it won't with structs.



Both factors can result in a slowdown, depending on the bottleneck.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (581 views)
2019-09-04 15:33:17

hadezbladez (5510 views)
2018-11-16 13:46:03

hadezbladez (2402 views)
2018-11-16 13:41:33

hadezbladez (5772 views)
2018-11-16 13:35:35

hadezbladez (1223 views)
2018-11-16 13:32:03

EgonOlsen (4661 views)
2018-06-10 19:43:48

EgonOlsen (5682 views)
2018-06-10 19:43:44

EgonOlsen (3198 views)
2018-06-10 19:43:20

DesertCoockie (4095 views)
2018-05-13 18:23:11

nelsongames (5115 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!