Notifications
Clear all

[Closed] Improve speed of "Create box()"

Messed around a bit trying to make the C# version multi-threaded, but non of the methods I tried looks to really be using multiple CPU cores.

V01: I[/I]

[View Code]( http://www.patan77.com/fastest_attach/genBoxesCParallel_01.txt)  


V02: I[/I]

[View Code]( http://www.patan77.com/fastest_attach/genBoxesCTasks_01.txt)  

V:03 : I[/I]

[View Code]( http://www.patan77.com/fastest_attach/genBoxesCThread_01.txt)  

temp solution for adding UV to the C# version cube:

(n 15 time: 0.109sec) n 50 time: 2.128sec, n 100 Time: 16.59sec Mem: 6007184L)

fn fn_uvSingleMesh inMesh = (
	gc()
	st=timestamp(); sh=heapfree
	with redraw off (
		with undo off (
			local m = uvwmap()
			addmodifier inMesh m
			converttomesh inMesh
			local rng
			local tVert = [0,0]
			for i = 1 to (getNumTVerts inMesh) by 8 do (
				rng = (random 0.0 1.0)
				for j = 1 to 8 do ( 
					tVert.x += 1
					setTVert inMesh tVert.x [rng,rng,0]
				)
			)
		)
	)
	update inMesh
	format "time:% heap:%
" (timestamp()-st) (sh-heapfree)
)
fn_uvSingleMesh $  

C# version boxes with UVs:
(With help from aaandres)

3dsMax2015:
with UV: (n 15 time: 0.008sec Mem: 432L | n 50 time: 0.513sec Mem: 432L)

Edit:
3dsMax2014:
with UV: (n 15 time: 0.007sec Mem: 416L| n 50 time: 0.106sec Mem: 416L)

[View Code]( http://www.patan77.com/fastest_attach/genBoxesWithUV.txt)  

0.513sec for n=50? Don’t you mean n=100?

1 Reply
(@patan77)
Joined: 11 months ago

Posts: 0

No for me n 50 = ~0.5sec and n100 = 4.781sec

I get 0.138sec for n=50 and 1.071 for n=100 with your code.
And my machine is far worse than yours. I’m under 3dsMax 2014 and Windows10.
Let’s see what other users get.

1 Reply
(@patan77)
Joined: 11 months ago

Posts: 0

hmm, its a bit strange:

my specs
CPU: 3930k 4.6ghz
MEM: DDR3 48GB: 4x 8GB 1600mhz + 4x 4GB 1600mhz (different mem types )
GPU: gtx 780 6GB version
SSD: 850 EVO 500GB

3dsMax 2015 windows 8.1

It might be my memory’s that’s the bottleneck, I have added 4x 4GB Mems from my xeon workstation machine so might be running in dual channel mode not quad channel. I have to try remove them and see if it makes any difference.

I’ve just tried an old Xeon E5520 2.27GHz (year 2008), 3dsMax2014 – Windows7.
For n=50, I get 230msec with your code !!??

1 Reply
(@patan77)
Joined: 11 months ago

Posts: 0

Well this were pretty annoying, I removed all my ram then put back only my 8GB sticks making sure they were put in the optimal slots, then rest bios to remove overclock then ran the code with UV got 0.7sec for n50 and ~6sec for n100, so thought maybe one of the mem sticks are broken so ran memory diagnostics and everything was fine, so then I ran tho code in 3ds max 2014 and it got n100 ~1sec… so put back the other mem sticks and also got my overclock back and now on 3Ds max 2014 now I get: n50 105ms and n100 806ms, so apparently 3ds max 2015 is really slow for wherever reason.

EDIT:

3dsMax 2014
Single-threaded:
n50: Time: 0.268sec
n100: Time: 2.02sec

Multi-threaded:
n50: Time: 0.085sec
n100: Time: 0.679sec

3dsMax 2015
Single-threaded:
n50: Time: 3.057sec
n100: Time: 49.758sec

Multi-threaded:
n50: Time: 3.759sec
n100: Time: 129.314sec

3dsMax 2016
Single-threaded:
n50: Time: 2.717sec
n100: Time: 65.513sec

Multi-threaded:
n50: Time: 3.787sec
n100: Time: 129.25sec

Something is wrong with 3dsMax 2015&2016, going from 0.67sec in 2014 to 129sec in 2015&2016, seriously…
Going to have to test 2017 aswell, but guess I’m going back to using 2014 for now -.-

Edit 2:
Viewport performance is way better in 2014 aswell:

Shaded | 1 full screen viewport | n100
2014: 55-70fps

2015: 7-20fps

2016: 20-40fps

New fastest version! [ C# multi-threaded ]

3dsMax 2014
n15: Time: 0.005sec Mem: 416L
n50: Time: 0.027sec Mem: 416L
n100: Time: 0.181sec Mem: 416L

I[/I]

[View Code]( http://www.patan77.com/fastest_attach/genBoxesMultiThreaded.txt)  

This version has a problem with random numbers. Look at the Top view to see the problem.
One solution is to create a ‘ThreadLocal<Random>’ static variable. It won’t affect performance at all.

1 Reply
(@patan77)
Joined: 11 months ago

Posts: 0

Yeah you are right, thought I fixed it by just adding a random seed to each thread, but looks like that trick didn’t work.

Edit : (updated the code with the fix)

The slowdown in Max 2015 and above seems to be related to IList access, as far as I could test. But I can’t figure out where the problem lies.

The performance drop isn’t small.

Does anyone have a clue on what can cause it?

Page 5 / 5